4 int RANDOM_DEFAULT_SEED;
9 RANDOM_DEFAULT_SEED = 0;
13 public void random_alloc() {
14 init_genrand(this.RANDOM_DEFAULT_SEED);
17 /* initializes mt[N] with a seed */
18 public void init_genrand(int s) {
19 mt[0]= ((long)s) & 0xFFFFFFFFL;
20 for (int mti=1; mti<624; mti++) {
21 mt[mti] = (1812433253L * (mt[mti-1] ^ (mt[mti-1] >> 30)) + ((long)mti));
22 /* See Knuth TAOCP Vol2. 3rd Ed. P.106 for multiplier. */
23 /* In the previous versions, MSBs of the seed affect */
24 /* only MSBs of the array mt[]. */
25 /* 2002/01/09 modified by Makoto Matsumoto */
26 mt[mti] &= 0xFFFFFFFFL;
27 /* for >32 bit machines */
32 public void random_seed(int seed) {
36 public long random_generate() {
37 long x= genrand_int32()&0xFFFFFFFFL;
38 System.out.println(x);
42 public long posrandom_generate() {
43 long r=genrand_int32();
50 public long genrand_int32() {
55 if (mti >= 624) { /* generate N words at one time */
58 if (mti == 624+1) { /* if init_genrand() has not been called, */
59 init_genrand(5489); /* a default initial seed is used */
62 for (kk=0;kk<(624-397);kk++) {
63 y = (mt[kk]&0x80000000L)|(mt[kk+1]&0x7fffffffL);
64 mt[kk] = mt[kk+397] ^ (y >> 1) ^ ((y & 0x1)==0 ? 0L:0x9908b0dfL);
66 for (;kk<(624-1);kk++) {
67 y = (mt[kk]&0x80000000L)|(mt[kk+1]&0x7fffffffL);
68 mt[kk] = mt[kk+(397-624)] ^ (y >> 1) ^ ((y & 0x1)==0 ? 0L:0x9908b0dfL);
70 y = (mt[624-1]&0x80000000L)|(mt[0]&0x7fffffffL);
71 mt[624-1] = mt[397-1] ^ (y >> 1) ^ ((y & 0x1)==0 ? 0L:0x9908b0dfL);
80 y ^= (y << 7) & 0x9d2c5680L;
81 y ^= (y << 15) & 0xefc60000L;