43 #if !defined(LIBCOYOTL_MTWISTER_H) 44 #define LIBCOYOTL_MTWISTER_H 67 friend class LOOP1<0>;
71 static const size_t N = 624;
72 static const size_t M = 397;
74 static const uint32_t MATRIX_A = 0x9908b0dfUL;
75 static const uint32_t UPPER_MASK = 0x80000000UL;
76 static const uint32_t LOWER_MASK = 0x7fffffffUL;
82 uint32_t m_multiplier;
104 virtual void init(uint32_t seed);
123 #if defined(USE_METATEMP) 128 inline static void EXEC(uint32_t * a)
130 uint32_t y = (a[i] & mtwister::UPPER_MASK) | (a[i+1] & mtwister::LOWER_MASK);
131 a[i] = a[i + 397] ^ (y >> 1) ^ ((y & 1) ? mtwister::MATRIX_A : 0);
140 inline static void EXEC(uint32_t * a)
142 uint32_t y = (a[226] & mtwister::UPPER_MASK) | (a[227] & mtwister::LOWER_MASK);
143 a[226] = a[623] ^ (y >> 1) ^ ((y & 1) ? mtwister::MATRIX_A : 0);
151 inline static void EXEC(uint32_t * a)
153 uint32_t y = (a[i] & mtwister::UPPER_MASK) | (a[i+1] & mtwister::LOWER_MASK);
154 a[i] = a[i - 227] ^ (y >> 1) ^ ((y & 1) ? mtwister::MATRIX_A : 0);
163 inline static void EXEC(uint32_t * a)
165 uint32_t y = (a[623] & mtwister::UPPER_MASK) | (a[0] & mtwister::LOWER_MASK);
166 a[623] = a[396] ^ (y >> 1) ^ ((y & 1) ? mtwister::MATRIX_A : 0);
uint32_t get_rand()
Get the next integer.
virtual void init(uint32_t seed)
Initializes the generator with "seed".
mtwister()
Default constructor, reading seed from/dev/urandom or the time.
Definition: mtwister.h:65
Implements the Mersenne Twister, a peudorandom number generator.
Definition: mtwister.h:63
An abstract definition of a peudorandom number generator.
Definition: prng.h:54