Bridge++
Ver. 1.1.x
Main Page
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Pages
randomNumbers_MT19937.h
Go to the documentation of this file.
1
14
#ifndef RANDOMNUMBERS_MT19937_INCLUDED
15
#define RANDOMNUMBERS_MT19937_INCLUDED
16
17
//==========================================================
18
// Random number generator.
19
// MT19937 random number generator.
20
// Original version in C was written by
21
// Takuji Nishimura and Makoto Matsumoto.
22
// See URL http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/MT2002/mt19937ar.html
23
//
24
// 25 Dec 2004 H.Matsufuru
25
//==========================================================
26
27
#include <cmath>
28
#include <string>
29
#include <vector>
30
31
#include "
randomNumbers.h
"
32
33
class
RandomNumbers_MT19937
:
public
RandomNumbers
34
{
35
public
:
36
RandomNumbers_MT19937
(
int
s);
37
//RandomNumbers_MT19937(unsigned long s = 5489UL);
38
RandomNumbers_MT19937
(
unsigned
long
s);
39
RandomNumbers_MT19937
(std::vector<unsigned long>& key);
40
RandomNumbers_MT19937
(
const
std::string filename);
41
42
~RandomNumbers_MT19937
() {}
43
44
double
get
() {
return
randDouble2
(); }
45
void
writefile
(
const
std::string);
46
47
private
:
48
void
init
(
unsigned
long
s);
49
void
init
(
unsigned
long
s, std::vector<unsigned long>& key);
50
51
void
nextState
()
const
;
52
unsigned
long
twist
(
unsigned
long
u,
unsigned
long
v)
const
;
53
54
// return [0,0xffffffff]
55
unsigned
long
randInt32
()
const
;
56
57
// return [0,0x7fffffff]
58
long
randInt31
()
const
;
59
60
// return [0,1] random number
61
double
randDouble1
()
const
;
62
63
// return [0,1) random number
64
double
randDouble2
()
const
;
65
66
// return (0,1) random number
67
double
randDouble3
()
const
;
68
69
// return [0,1) random number with 53-bit resolution
70
double
randRes53
()
const
;
71
72
enum
{
N
=624,
M
=397 };
73
74
mutable
int
m_left
;
75
mutable
unsigned
long
m_state
[
N
];
76
mutable
unsigned
long
*
m_next
;
77
};
78
#endif
src
Tools
randomNumbers_MT19937.h
Generated on Tue Jul 23 2013 10:48:50 for Bridge++ by
1.8.3.1