initGenrand method

void initGenrand(
  1. int? s
)

Implementation

void initGenrand(int? s) {
  s = s ?? DateTime.now().millisecond;

  //c//mt[0]= s & 0xffffffff;
  mt[0] = unsigned32(s & 0xffffffff);
  for (mti = 1; mti < N; mti++) {
    mt[mti] =
        //c//(1812433253 * (mt[mti-1] ^ (mt[mti-1] >> 30)) + mti);
        addition32(
            multiplication32(
                1812433253, unsigned32(mt[mti - 1] ^ (mt[mti - 1] >> 30))),
            mti);
    /* See Knuth TAOCP Vol2. 3rd Ed. P.106 for multiplier. */
    /* In the previous versions, MSBs of the seed affect   */
    /* only MSBs of the array mt[].                        */
    /* 2002/01/09 modified by Makoto Matsumoto             */
    //c//mt[mti] &= 0xffffffff;
    mt[mti] = unsigned32(mt[mti] & 0xffffffff);
    // print("init_seed  index=$mti  ${mt[mti]}");
    /* for >32 bit machines */
  }
}