48 #include "rrExporter.h"
58 MTRand_int32(
const unsigned long* array,
int size) { seed(array, size); init =
true; }
60 void seed(
unsigned long);
61 void seed(
const unsigned long*,
int size);
63 unsigned long operator()() {
return rand_int32(); }
67 unsigned long rand_int32()
const;
72 static unsigned long state[];
76 unsigned long twiddle(
unsigned long,
unsigned long)
const;
77 void gen_state()
const;
84 inline unsigned long MTRand_int32::twiddle(
unsigned long u,
unsigned long v)
const {
85 return (((u & 0x80000000UL) | (v & 0x7FFFFFFFUL)) >> 1)
86 ^ ((v & 1UL) ? 0x9908B0DFUL : 0x0UL);
89 inline unsigned long MTRand_int32::rand_int32()
const {
90 if (p == n) gen_state();
93 unsigned long x = state[p++];
95 x ^= (x << 7) & 0x9D2C5680UL;
96 x ^= (x << 15) & 0xEFC60000UL;
107 double operator()()
const {
108 return static_cast<double>(rand_int32()) * (1. / 4294967296.); }
111 void operator=(
const MTRand&);
121 double operator()() {
122 return static_cast<double>(rand_int32()) * (1. / 4294967295.); }
135 double operator()() {
136 return (
static_cast<double>(rand_int32()) + .5) * (1. / 4294967296.); }
149 double operator()() {
150 return (
static_cast<double>(rand_int32() >> 5) * 67108864. +
151 static_cast<double>(rand_int32() >> 6)) * (1. / 9007199254740992.); }