12 #ifndef ETEQ_RANDOM_HPP 13 #define ETEQ_RANDOM_HPP 19 using EngineT = std::default_random_engine;
23 using GenF = std::function<T()>;
29 template <typename T, typename std::enable_if<std::is_integral<T>::value>::type* =
nullptr>
30 T
unif (
const T& a,
const T& b)
32 std::uniform_int_distribution<T> dist(a, b);
37 template <typename T, typename std::enable_if<!std::is_integral<T>::value>::type* =
nullptr>
38 T
unif (
const T& a,
const T& b)
40 std::uniform_real_distribution<T> dist(a, b);
45 template <typename T, typename std::enable_if<std::is_integral<T>::value>::type* =
nullptr>
48 std::uniform_int_distribution<T> dist(a, b);
53 template <typename T, typename std::enable_if<!std::is_integral<T>::value>::type* =
nullptr>
56 std::uniform_real_distribution<T> dist(a, b);
61 template <typename T, typename std::enable_if<!std::is_integral<T>::value>::type* =
nullptr>
64 std::normal_distribution<T> dist(mean, stdev);
70 #endif // ETEQ_RANDOM_HPP Definition: constant.hpp:17
GenF< T > unif_gen(const T &a, const T &b)
Return uniformly generator function that produces numbers between a and b (integers only) ...
Definition: random.hpp:46
std::default_random_engine EngineT
RNG engine used.
Definition: random.hpp:19
GenF< T > norm_gen(T mean, T stdev)
Return normally generator function that produces numbers with mean and stdev (decimals only) ...
Definition: random.hpp:62
T unif(const T &a, const T &b)
Return uniformly generated number between a and b (integers only)
Definition: random.hpp:30
std::function< T()> GenF
Function that returns a generated number.
Definition: random.hpp:23
EngineT & get_engine(void)
Return global random generator.