- // Instance seed random or implicite
- RKISS() { ::srand ( (uint32_t)time(NULL) ); raninit ( (uint64_t)::rand() ); }
- // RKISS( uint64_t s ) { raninit ( s ); }
-
- // (Re)init seed
- // void init ( uint64_t seed ) { raninit ( seed ); }
-
- // Return 32 bit unsigned integer in between [0,2^32-1]
- uint32_t rand32 () { return (uint32_t) rand64 (); }
-
- // Return 64 bit unsigned integer in between [0,2^64-1]
- uint64_t rand64 () {
- const uint64_t e = s.a - ((s.b<<7) | (s.b>>57));
- s.a = s.b ^ ((s.c<<13) | (s.c>>51));
- s.b = s.c + ((s.d<<37) | (s.d>>27));
- s.c = s.d + e;
- return s.d = e + s.a;
- }
-
- // Return double in between [0,1). Keep full 53 bit mantissa
- // double frand () { return (int64_t)(rand64()>>11) * (1.0/(67108864.0*134217728.0)); }