18 #ifndef INCLUDED_MATHS_RANDOM 19 #define INCLUDED_MATHS_RANDOM 46 c = state[(index + 13) & 15];
47 b = a ^ c ^ (a << 16) ^ (c << 15);
48 c = state[(index + 9) & 15];
50 a = state[
index] = b ^ c;
51 d = a ^ ((a << 5) & 0xDA442D24UL);
52 index = (index + 15) & 15;
54 state[
index] = a ^ b ^ d ^ (a << 2) ^ (b << 18) ^ (c << 28);
64 state[0] = value & mask;
66 state[i] = (1812433253UL * (state[i - 1] ^ (state[i - 1] >> 30)) + i) & mask;
83 return std::numeric_limits<uint32_t>::min();
88 return std::numeric_limits<uint32_t>::max();
110 template<
class CharT,
class Traits>
111 friend std::basic_ostream<CharT, Traits>&
112 operator<<(std::basic_ostream<CharT, Traits>& os,
const WELL512&
rng)
114 os <<
rng.index <<
" ";
116 os <<
rng.state[i] <<
" ";
120 template<
class CharT,
class Traits>
121 friend std::basic_istream<CharT, Traits>&
124 is >> rng.
index >> std::ws;
126 is >> rng.
state[i] >> std::ws;
131 #endif // INCLUDED_MATHS_RANDOM uint32_t state[16]
Definition: Random.h:30
#define ARRAY_SIZE(name)
Definition: code_annotation.h:336
friend bool operator==(const WELL512 &x, const WELL512 &y)
Definition: Random.h:93
friend std::basic_istream< CharT, Traits > & operator>>(std::basic_istream< CharT, Traits > &is, WELL512 &rng)
Definition: Random.h:122
void seed(uint32_t value)
Definition: Random.h:58
Random number generator with period 2^{512}-1; effectively a better version of MT19937 (smaller state...
Definition: Random.h:27
boost::mt19937 rng
Random number generator (Boost Mersenne Twister)
Definition: Noise.cpp:34
uint32_t min() const
Definition: Random.h:81
void seed(uint32_t values[16])
Definition: Random.h:69
uint32_t operator()()
Definition: Random.h:39
uint32_t max() const
Definition: Random.h:86
unsigned int uint32_t
Definition: wposix_types.h:53
WELL512()
Definition: Random.h:34
uint32_t result_type
Definition: Random.h:79
uint32_t index
Definition: Random.h:31
friend bool operator!=(const WELL512 &x, const WELL512 &y)
Definition: Random.h:103