19 #ifndef RANDOM_H_INCLUDED 20 #define RANDOM_H_INCLUDED 61 Random(std::uint64_t seed = 0);
80 static_assert(0 < MAX && MAX < std::numeric_limits<std::uint32_t>::max(),
"randfix out of range");
83 static_assert(MAX != 2,
"don't isolate the LSB with xoroshiro128+");
123 return std::numeric_limits<result_type>::min();
133 return std::numeric_limits<result_type>::max();
153 std::uint64_t
gen(
void);
160 inline std::uint32_t Random::randfix<2>() {
161 return (
gen() > (std::numeric_limits<std::uint64_t>::max() / 2));
std::uint64_t randuint64()
Generate raw random number.
Definition: Random.cpp:70
std::uint64_t result_type
Definition: Random.h:114
static Random & get_Rng(void)
Get a copy of the current thread.
Definition: Random.cpp:35
RNG based on Xoroshiro128+.
Definition: Random.h:46
Random()=delete
Free the pointed object.
static constexpr result_type max()
Max integer value, part of UniformRandomBitGenerator interface.
Definition: Random.h:132
std::uint64_t m_s[2]
Definition: Random.h:155
static constexpr result_type min()
Min integer value, part of UniformRandomBitGenerator interface.
Definition: Random.h:122
std::uint32_t randfix()
Check that the random number will be generated in a correct range, then generate it.
Definition: Random.h:79
void seedrandom(std::uint64_t s)
Initialize state of xoroshiro128+ by transforming the seed with the splitmix64 algorithm.
Definition: Random.cpp:81
std::uint64_t gen(void)
Generate random generated number with Xoroshiro128+.
Definition: Random.cpp:53
result_type operator()()
Generate a raw random number, part of UniformRandomBitGenerator interface.
Definition: Random.h:142
A set of useful method and class.
Definition: Random.cpp:33