17 #ifdef USE_FACTORY_AUTOREGISTER
19 bool init = RandomNumbers_MT19937::register_factory();
51 for (
int i = 0; i < key.size(); ++i) {
56 init(19650218UL, key);
72 std::ifstream in_file(filename.c_str());
79 for (
int i = 0; i <
N; ++i) {
111 std::ofstream out_file(filename.c_str());
118 for (
int i = 0; i <
N; ++i) {
119 out_file <<
m_state[i] << std::endl;
122 out_file <<
m_left << std::endl;
140 for (
int j = 1; j <
N; ++j) {
152 int key_length = key.size();
154 for (
int k =
N > key_length ?
N : key_length; k; --k) {
167 if (j >= key_length) j = 0;
170 for (
int k =
N - 1; k; --k) {
192 for (
int j =
N -
M + 1; --j; ++p) {
193 *p = p[
M] ^
twist(p[0], p[1]);
195 for (
int j =
M; --j; ++p) {
196 *p = p[
M -
N] ^
twist(p[0], p[1]);
207 const unsigned long mtrx_a = 0x9908b0dfUL;
208 const unsigned long umask = 0x80000000UL;
209 const unsigned long lmask = 0x7fffffffUL;
211 unsigned long maxbits = (u & umask) | (v & lmask);
213 return (maxbits >> 1) ^ (v & 1UL ? mtrx_a : 0UL);
222 unsigned long y = *
m_next++;
226 y ^= (y << 7) & 0x9d2c5680UL;
227 y ^= (y << 15) & 0xefc60000UL;
244 static const double factor = 1.0 / 4294967295.0;
246 return static_cast<double>(
randInt32() * factor);
253 static const double factor = 1.0 / 4294967296.0;
255 return static_cast<double>(
randInt32() * factor);
262 static const double factor = 1.0 / 4294967296.0;
264 return static_cast<double>((
randInt32() + 0.5) * factor);
273 static const double factor = 1.0 / 9007199254740992.0;
275 return (a * 67108864.0 + b) * factor;
void detailed(const char *format,...)
static const std::string class_name
void general(const char *format,...)
unsigned long twist(unsigned long u, unsigned long v) const
double randDouble1() const
double randDouble3() const
static int broadcast(size_t size, void *data, int sender)
Bridge::VerboseLevel m_vl
void init(unsigned long s)
void write_file(const std::string &)
RandomNumbers_MT19937(int s)
unsigned long randInt32() const
void read_file(const std::string &)
save and load random number status.
void crucial(const char *format,...)
void reset(unsigned long seed)
reset state with new seed.
double randDouble2() const
static bool is_primary()
check if the present node is primary in small communicator.