Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#ifndef P2_H
#define P2_H
#include <cassert>
#include <sstream>
#include <string>
#include <vector>
class P2 {
public:
static void PR_init(std::stringstream& ss,
int seed,
int num_generals,
int num_planets,
int num_deployments,
int arrival_rate);
// Don't need to read further than this, unless you want to learn about
// Mersenne Twister implementation
private:
/**
* mt.h: Mersenne Twister header file
*
* Jason R. Blevins <jrblevin@sdf.lonestar.org>
* Durham, March 7, 2007
*/
/**
* Mersenne Twister.
*
* M. Matsumoto and T. Nishimura, "Mersenne Twister: A
* 623-dimensionally equidistributed uniform pseudorandom number
* generator", ACM Trans. on Modeling and Computer Simulation Vol. 8,
* No. 1, January pp.3-30 (1998).
*
* http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/emt.html.
*/
class MersenneTwister
{
public:
MersenneTwister(void);
~MersenneTwister(void);
void print(void);
void init_genrand(unsigned long s);
unsigned long genrand_int32(void);
private:
static const int N = 624;
static const int M = 397;
// constant vector a
static const unsigned long MATRIX_A = 0x9908b0dfUL;
// most significant w-r bits
static const unsigned long UPPER_MASK = 0x80000000UL;
// least significant r bits
static const unsigned long LOWER_MASK = 0x7fffffffUL;
unsigned long* mt_; // the state vector
int mti_; // mti == N+1 means mt not initialized
unsigned long* init_key_; // Storage for the seed vector
int key_length_; // Seed vector length
unsigned long s_; // Seed integer
bool seeded_by_array_; // Seeded by an array
bool seeded_by_int_; // Seeded by an integer
};
};
#endif