21 #pragma warning(disable : 4146) 26 inline uint32_t
hiBit(
const uint32_t u) {
return u & 0x80000000UL; }
27 inline uint32_t
loBit(
const uint32_t u) {
return u & 0x00000001UL; }
28 inline uint32_t
loBits(
const uint32_t u) {
return u & 0x7fffffffUL; }
29 inline uint32_t
mixBits(
const uint32_t u,
const uint32_t v)
33 inline uint32_t
twist(
const uint32_t m,
const uint32_t s0,
const uint32_t s1)
35 return m ^ (
mixBits(s0, s1) >> 1) ^ (-
loBit(s1) & 0x9908b0dfUL);
48 y ^= (y << 7) & 2636928640U;
49 y ^= (y << 15) & 4022730752U;
72 for (
int i = N - M; i--; ++p) *p =
twist(p[M], p[0], p[1]);
73 for (
int i = M; --i; ++p) *p =
twist(p[M - N], p[0], p[1]);
82 for (uint32_t i = 1; i < 624; i++)
83 m_MT[i] = static_cast<uint32_t>(
84 1812433253 * (
m_MT[i - 1] ^ (
m_MT[i - 1] >> 30)) + i);
A namespace of pseudo-random numbers generators of diferent distributions.
uint32_t drawUniform32bit()
Generate a uniformly distributed pseudo-random number using the MT19937 algorithm, in the whole range of 32-bit integers.
uint32_t loBit(const uint32_t u)
std::uniform_int_distribution< uint64_t > m_uint64
std::normal_distribution< double > m_normdistribution
A thred-safe pseudo random number generator, based on an internal MT19937 randomness generator...
static CRandomGenerator randomGenerator
uint32_t hiBit(const uint32_t u)
uint64_t drawUniform64bit()
Returns a uniformly distributed pseudo-random number by joining two 32bit numbers from drawUniform32b...
uint32_t mixBits(const uint32_t u, const uint32_t v)
void randomize()
Randomize the generators, based on std::random_device.
std::uniform_int_distribution< uint32_t > m_uint32
uint32_t twist(const uint32_t m, const uint32_t s0, const uint32_t s1)
Generator_MT19937 m_MT19937
Data used internally by the MT19937 PRNG algorithm.
void seed(const uint32_t seed)
CRandomGenerator & getRandomGenerator()
A static instance of a CRandomGenerator class, for use in single-thread applications.
uint32_t loBits(const uint32_t u)
double drawGaussian1D_normalized()
Generate a normalized (mean=0, std=1) normally distributed sample.