- // Return double in between [0,1). Keep full 53 bit mantissa
- // double frand () { return (int64_t)(rand64()>>11) * (1.0/(67108864.0*134217728.0)); }
+ // Init seed and scramble a few rounds
+ void raninit(uint64_t seed) {
+
+ s.a = 0xf1ea5eed;
+ s.b = s.c = s.d = seed;
+ for (uint64_t i = 0; i < 8; i++)
+ rand64();
+ }
+
+public:
+ // Instance seed random or implicite
+ RKISS() { ::srand(uint32_t(time(NULL))); raninit(uint64_t(::rand())); }
+
+ // Return random number of type T (must be castable from uint64_t)
+ template<typename T>
+ T rand() { return T(rand64()); }