#ifndef DNN_UTILS_H #define DNN_UTILS_H #include #include #include namespace dnn { template struct has_coordinates { template ().coordinate(std::declval()...) )> static std::true_type test(int); template static std::false_type test(...); static constexpr bool value = decltype(test(0))::value; }; template void random_shuffle(RandomIt first, RandomIt last, UniformRandomNumberGenerator& g, const SwapFunctor& swap) { size_t n = last - first; boost::uniform_int uniform(0,n); for (size_t i = n-1; i > 0; --i) swap(first[i], first[uniform(g,i+1)]); // picks a random number in [0,i] range } template void random_shuffle(RandomIt first, RandomIt last, UniformRandomNumberGenerator& g) { typedef decltype(*first) T; random_shuffle(first, last, g, [](T& x, T& y) { std::swap(x,y); }); } } #endif