43 for (
int i = 0; i < key.size(); ++i) {
48 init(19650218UL, key);
64 std::ifstream in_file(filename.c_str());
71 for (
int i = 0; i <
N; ++i) {
103 std::ofstream out_file(filename.c_str());
110 for (
int i = 0; i <
N; ++i) {
111 out_file <<
m_state[i] << std::endl;
114 out_file <<
m_left << std::endl;
132 for (
int j = 1; j <
N; ++j) {
144 int key_length = key.size();
146 for (
int k =
N > key_length ?
N : key_length; k; --k) {
159 if (j >= key_length) j = 0;
162 for (
int k =
N - 1; k; --k) {
184 for (
int j =
N -
M + 1; --j; ++p) {
185 *p = p[
M] ^
twist(p[0], p[1]);
187 for (
int j =
M; --j; ++p) {
188 *p = p[
M -
N] ^
twist(p[0], p[1]);
199 const unsigned long mtrx_a = 0x9908b0dfUL;
200 const unsigned long umask = 0x80000000UL;
201 const unsigned long lmask = 0x7fffffffUL;
203 unsigned long maxbits = (u & umask) | (v & lmask);
205 return (maxbits >> 1) ^ (v & 1UL ? mtrx_a : 0UL);
214 unsigned long y = *
m_next++;
218 y ^= (y << 7) & 0x9d2c5680UL;
219 y ^= (y << 15) & 0xefc60000UL;
236 static const double factor = 1.0 / 4294967295.0;
238 return static_cast<double>(
randInt32() * factor);
245 static const double factor = 1.0 / 4294967296.0;
247 return static_cast<double>(
randInt32() * factor);
254 static const double factor = 1.0 / 4294967296.0;
256 return static_cast<double>((
randInt32() + 0.5) * factor);
265 static const double factor = 1.0 / 9007199254740992.0;
267 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.