| 1 |
#ifndef MT19937AR_H |
| 2 |
#define MT19937AR_H |
| 3 |
|
| 4 |
// Refactoring of |
| 5 |
// |
| 6 |
// A C-program for MT19937, with initialization improved 2002/1/26. |
| 7 |
// Coded by Takuji Nishimura and Makoto Matsumoto. |
| 8 |
// |
| 9 |
// to make it thread safe and (hopefully) more portable. |
| 10 |
// |
| 11 |
// 20040421, bpw |
| 12 |
|
| 13 |
// bri.h contains the function prototypes, but we hide the structure and |
| 14 |
// implementation here. |
| 15 |
// |
| 16 |
#include "../util.h" |
| 17 |
|
| 18 |
/* Period parameters */ |
| 19 |
#define MT_N 624 |
| 20 |
#define MT_M 397 |
| 21 |
#define MT_MATRIX_A 0x9908b0dfUL /* constant vector a */ |
| 22 |
#define MT_UPPER_MASK 0x80000000UL /* most significant w-r bits */ |
| 23 |
#define MT_LOWER_MASK 0x7fffffffUL /* least significant r bits */ |
| 24 |
|
| 25 |
|
| 26 |
struct mtctx { |
| 27 |
// The array for the state vector |
| 28 |
// |
| 29 |
uint32 mt[MT_N]; |
| 30 |
|
| 31 |
// The ordinal of the first uninitialized element -- |
| 32 |
// mti = N+1 -> element N is uninitialized |
| 33 |
// |
| 34 |
uint32 mti; |
| 35 |
|
| 36 |
// Something |
| 37 |
// mag01[x] = x * MT_MATRIX_A for x=0,1 |
| 38 |
// |
| 39 |
uint32 mag01[2]; |
| 40 |
}; |
| 41 |
|
| 42 |
// This is declared in util.h |
| 43 |
// |
| 44 |
//typedef struct mt mt_s; |
| 45 |
|
| 46 |
|
| 47 |
#endif // MT19937AR_H |