19 #ifndef RANDOM_H_INCLUDED 20 #define RANDOM_H_INCLUDED 55 Random(std::uint64_t seed = 0);
74 static_assert(0 < MAX && MAX < std::numeric_limits<std::uint32_t>::max(),
"randfix out of range");
77 static_assert(MAX != 2,
"don't isolate the LSB with xoroshiro128+");
117 return std::numeric_limits<result_type>::min();
127 return std::numeric_limits<result_type>::max();
147 std::uint64_t gen(
void);
149 std::uint64_t m_s[2];
154 inline std::uint32_t Random::randfix<2>() {
155 return (gen() > (std::numeric_limits<std::uint64_t>::max() / 2));
std::uint64_t randuint64()
Generate raw random number.
Definition: Random.cpp:64
std::uint64_t result_type
Definition: Random.h:108
static Random & get_Rng(void)
Get a copy of the current thread.
Definition: Random.cpp:29
RNG based on Xoroshiro128+.
Definition: Random.h:40
Random()=delete
Free the pointed object.
static constexpr result_type max()
Max integer value, part of UniformRandomBitGenerator interface.
Definition: Random.h:126
static constexpr result_type min()
Min integer value, part of UniformRandomBitGenerator interface.
Definition: Random.h:116
std::uint32_t randfix()
Check that the random number will be generated in a correct range, then generate it.
Definition: Random.h:73
void seedrandom(std::uint64_t s)
Initialize state of xoroshiro128+ by transforming the seed with the splitmix64 algorithm.
Definition: Random.cpp:75
result_type operator()()
Generate a raw random number, part of UniformRandomBitGenerator interface.
Definition: Random.h:136
A set of useful method and class.
Definition: Random.cpp:27