7 #ifndef __FWTOOLS_RANDOM_GENERATOR_HPP__ 8 #define __FWTOOLS_RANDOM_GENERATOR_HPP__ 10 #include <fwCore/base.hpp> 12 #include <boost/concept_check.hpp> 13 #include <boost/mpl/if.hpp> 14 #include <boost/random/mersenne_twister.hpp> 15 #include <boost/random/uniform_int.hpp> 16 #include <boost/random/uniform_real.hpp> 17 #include <boost/random/variate_generator.hpp> 21 #include <type_traits> 38 T getValue(T min, T max, std::uint32_t seedVal = std::time(NULL))
41 typedef typename ::boost::mpl::if_<
42 std::is_floating_point<T>,
43 ::boost::uniform_real<>,
44 ::boost::uniform_int<>
47 ::boost::mt19937 seed(seedVal);
48 DistroType dist(min, max);
49 ::boost::variate_generator< ::boost::mt19937&, DistroType > random(seed, dist);
63 template <
typename T,
typename CONTAINER>
64 void fillContainer(T min, T max, CONTAINER& randContainer, std::uint32_t seedVal = std::time(NULL))
67 SLM_ASSERT(
"Container type not same as T", (std::is_same< T, typename CONTAINER::value_type>::value) );
68 typedef typename ::boost::mpl::if_<
69 std::is_floating_point<T>,
70 ::boost::uniform_real<>,
71 ::boost::uniform_int<>
74 ::boost::mt19937 seed(seedVal);
75 DistroType dist(min, max);
76 ::boost::variate_generator< ::boost::mt19937&, DistroType > random(seed, dist);
77 std::generate(randContainer.begin(), randContainer.end(), random);
83 #endif //__FWTOOLS_RANDOM_GENERATOR_HPP__
#define SLM_ASSERT(message, cond)
work like 'assert' from 'cassert', with in addition a message logged by spylog (with FATAL loglevel) ...