31 static const unsigned SIZE = 624;
38 #define M32(x) (0x80000000 & x) // 32nd Most Significant Bit 39 #define L31(x) (0x7FFFFFFF & x) // 31 Least Significant Bits 40 #define ODD(x) (x & 1) // Check if number is odd 42 #define UNROLL(expr) \ 43 y = M32(MT[i]) | L31(MT[i+1]); \ 44 MT[i] = MT[expr] ^ (y>>1) ^ MATRIX[ODD(y)]; \ 47 #define MD_UINT32_MAX std::numeric_limits<uint32_t>::max() 69 static const uint32_t MATRIX[2] = {0, 0x9908b0df};
73 while ( i < (
DIFF - 1 ) )
87 while ( i < ( SIZE - 1 ) )
111 extern "C" void seed( uint32_t value )
148 for (
unsigned i = 1; i <
SIZE; ++i )
149 MT[i] = 0x6c078965 * (
MT[i-1] ^
MT[i-1] >> 30 ) + i;
161 y ^= y << 7 & 0x9d2c5680;
162 y ^= y << 15 & 0xefc60000;
188 return static_cast<int>( 0x7FFFFFFF &
rand_u32() );
193 seed( static_cast<uint32_t>( value ) );
static void generate_numbers()
static const unsigned PERIOD
void seed(uint32_t value)
void mt_srand(unsigned value)
static const unsigned DIFF
static const unsigned SIZE