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 MD_UINT32_MAX std::numeric_limits<uint32_t>::max()
64 static const uint32_t MATRIX[2] = {0, 0x9908b0df};
65 register uint32_t y, i;
68 for ( i = 0; i <
DIFF; ++i )
83 y = M32(MT[i]) | L31(MT[i+1]); \
84 MT[i] = MT[i-DIFF] ^ (y>>1) ^ MATRIX[ODD(y)]; \
88 for ( i = DIFF; i < (
SIZE - 1 ); )
108 extern "C" void seed( uint32_t value )
145 for (
register unsigned i = 1; i <
SIZE; ++i )
146 MT[i] = 0x6c078965 * (
MT[i-1] ^
MT[i-1] >> 30 ) + i;
154 register uint32_t y =
MT[
index];
158 y ^= y << 7 & 0x9d2c5680;
159 y ^= y << 15 & 0xefc60000;
185 return static_cast<int>( 0x7FFFFFFF &
rand_u32() );
190 seed( static_cast<uint32_t>( value ) );