64 #define MATRIX_A 0xB5026F5AA96619E9ULL
65 #define UM 0xFFFFFFFF80000000ULL
66 #define LM 0x7FFFFFFFULL
70 static uint64_t mt[NN];
75 void init_genrand(uint64_t seed)
78 for (mti=1; mti<NN; mti++)
79 mt[mti] = (6364136223846793005ULL * (mt[mti-1] ^ (mt[mti-1] >> 62)) + mti);
85 void init_by_array(uint64_t init_key[],
int key_length)
88 init_genrand(19650218ULL);
90 k = (NN>key_length ? NN : key_length);
92 mt[i] = (mt[i] ^ ((mt[i-1] ^ (mt[i-1] >> 62)) * 3935559000370003845ULL))
95 if (i>=NN) { mt[0] = mt[NN-1]; i=1; }
96 if (j>=key_length) j=0;
98 for (k=NN-1; k; k--) {
99 mt[i] = (mt[i] ^ ((mt[i-1] ^ (mt[i-1] >> 62)) * 2862933555777941757ULL))
102 if (i>=NN) { mt[0] = mt[NN-1]; i=1; }
109 uint64_t genrand_int64(
void)
113 static uint64_t mag01[2]={0ULL, MATRIX_A};
120 init_genrand(5489ULL);
122 for (i=0;i<NN-MM;i++) {
123 x = (mt[i]&UM)|(mt[i+1]&LM);
124 mt[i] = mt[i+MM] ^ (x>>1) ^ mag01[(
int)(x&1ULL)];
127 x = (mt[i]&UM)|(mt[i+1]&LM);
128 mt[i] = mt[i+(MM-NN)] ^ (x>>1) ^ mag01[(int)(x&1ULL)];
130 x = (mt[NN-1]&UM)|(mt[0]&LM);
131 mt[NN-1] = mt[MM-1] ^ (x>>1) ^ mag01[(
int)(x&1ULL)];
138 x ^= (x >> 29) & 0x5555555555555555ULL;
139 x ^= (x << 17) & 0x71D67FFFEDA60000ULL;
140 x ^= (x << 37) & 0xFFF7EEE000000000ULL;
147 int64_t genrand_int63(
void)
149 return (int64_t)(genrand_int64() >> 1);
153 double genrand_real1(
void)
155 return (genrand_int64() >> 11) * (1.0/9007199254740991.0);
159 double genrand_real2(
void)
161 return (genrand_int64() >> 11) * (1.0/9007199254740992.0);
165 double genrand_real3(
void)
167 return ((genrand_int64() >> 12) + 0.5) * (1.0/4503599627370496.0);
171 double genrand_res53(
void)
173 return (genrand_int64() >> 11) * (1.0/9007199254740992.0);