| 86 |
|
|
| 87 |
|
//Methods |
| 88 |
|
public: |
| 89 |
< |
MTRand( const uint32& oneSeed, nstrides = 1, stride = 0); // initialize with a simple uint32 |
| 90 |
< |
MTRand( uint32 *const bigSeed, uint32 const seedLength = N, nstrides = 1, stride = 0); // or an array |
| 91 |
< |
MTRand(nstrides = 1, stride = 0); // auto-initialize with /dev/urandom or time() and clock() |
| 89 |
> |
MTRand( const uint32& oneSeed, int nstrides = 1, int stride = 0); // initialize with a simple uint32 |
| 90 |
> |
MTRand( uint32 *const bigSeed, uint32 const seedLength = N, int nstrides = 1, int stride = 0); // or an array |
| 91 |
> |
MTRand(int nstrides = 1, int stride = 0); // auto-initialize with /dev/urandom or time() and clock() |
| 92 |
|
|
| 93 |
|
// Do NOT use for CRYPTOGRAPHY without securely hashing several returned |
| 94 |
|
// values together, otherwise the generator state can be learned after |
| 189 |
|
// Pull a 32-bit integer from the generator state |
| 190 |
|
// Every other access function simply transforms the numbers extracted here |
| 191 |
|
|
| 192 |
< |
uint32 ranNums[nstrides]; |
| 192 |
> |
uint32 ranNums[nstrides_]; |
| 193 |
|
|
| 194 |
< |
for (int i = 0; i < nstrides; ++i) { |
| 194 |
> |
for (int i = 0; i < nstrides_; ++i) { |
| 195 |
|
if( left == 0 ) { |
| 196 |
|
reload(); |
| 197 |
|
} |
| 203 |
|
s1 ^= (s1 >> 11); |
| 204 |
|
s1 ^= (s1 << 7) & 0x9d2c5680UL; |
| 205 |
|
s1 ^= (s1 << 15) & 0xefc60000UL; |
| 206 |
< |
ranNums[i] = s1 ^ (s1 >> 18) ); |
| 206 |
> |
ranNums[i] = s1 ^ (s1 >> 18); |
| 207 |
|
} |
| 208 |
|
|
| 209 |
< |
return ranNums[stride]; |
| 209 |
> |
return ranNums[stride_]; |
| 210 |
|
} |
| 211 |
|
|
| 212 |
|
inline MTRand::uint32 MTRand::randInt( const uint32& n ) |