25 #define MATRIX_A 0x9908b0dfUL
26 #define UPPER_MASK 0x80000000UL
27 #define LOWER_MASK 0x7fffffffUL
29 static unsigned long mt[
N];
35 mt[0]= s & 0xffffffffUL;
43 mt[
mti] &= 0xffffffffUL;
57 k = (
N>key_length ?
N : key_length);
59 mt[
i] = (
mt[
i] ^ ((
mt[i-1] ^ (
mt[i-1] >> 30)) * 1664525UL))
61 mt[
i] &= 0xffffffffUL;
63 if (i>=
N) {
mt[0] =
mt[
N-1]; i=1; }
64 if (j>=key_length) j=0;
67 mt[
i] = (
mt[
i] ^ ((
mt[i-1] ^ (
mt[i-1] >> 30)) * 1566083941UL))
69 mt[
i] &= 0xffffffffUL;
71 if (i>=
N) {
mt[0] =
mt[
N-1]; i=1; }
81 static unsigned long mag01[2]={0x0UL,
MATRIX_A};
90 for (kk=0;kk<
N-
M;kk++) {
92 mt[kk] =
mt[kk+
M] ^ (y >> 1) ^ mag01[y & 0x1UL];
96 mt[kk] =
mt[kk+(M-
N)] ^ (y >> 1) ^ mag01[y & 0x1UL];
99 mt[N-1] =
mt[M-1] ^ (y >> 1) ^ mag01[y & 0x1UL];
108 y ^= (y << 7) & 0x9d2c5680UL;
109 y ^= (y << 15) & 0xefc60000UL;
146 return(a*67108864.0+
b)*(1.0/9007199254740992.0);
154 unsigned long init[4]={0x123, 0x234, 0x345, 0x456}, length=4;
156 printf(
"1000 outputs of genrand_int32()\n");
157 for (i=0; i<1000; i++) {
159 if (i%5==4) printf(
"\n");
161 printf(
"\n1000 outputs of genrand_real2()\n");
162 for (i=0; i<1000; i++) {
164 if (i%5==4) printf(
"\n");