55 MTRand_int32(
const unsigned long* array,
int size) { seed(array, size); init =
true; }
57 void seed(
unsigned long);
58 void seed(
const unsigned long*,
int size);
60 unsigned long operator()() {
return rand_int32(); }
64 unsigned long rand_int32();
66 static const int n = 624, m = 397;
68 static unsigned long state[n];
72 unsigned long twiddle(
unsigned long,
unsigned long);
80 inline unsigned long MTRand_int32::twiddle(
unsigned long u,
unsigned long v) {
81 return (((u & 0x80000000UL) | (v & 0x7FFFFFFFUL)) >> 1)
82 ^ ((v & 1UL) ? 0x9908B0DFUL : 0x0UL);
85 inline unsigned long MTRand_int32::rand_int32() {
86 if (p == n) gen_state();
89 unsigned long x = state[p++];
91 x ^= (x << 7) & 0x9D2C5680UL;
92 x ^= (x << 15) & 0xEFC60000UL;
103 double operator()() {
104 return static_cast<double>(rand_int32()) * (1. / 4294967296.); }
107 void operator=(
const MTRand&);
117 double operator()() {
118 return static_cast<double>(rand_int32()) * (1. / 4294967295.); }
131 double operator()() {
132 return (static_cast<double>(rand_int32()) + .5) * (1. / 4294967296.); }
145 double operator()() {
146 return (static_cast<double>(rand_int32() >> 5) * 67108864. +
147 static_cast<double>(rand_int32() >> 6)) * (1. / 9007199254740992.); }