RngStream.h
Go to the documentation of this file.
1 /***********************************************************************\
2  *
3  * This file is part of the RngStreams package
4  *
5  * File: RngStream.h for multiple streams of Random Numbers
6  * Language: C++ (ISO 1998)
7  * Copyright: Pierre L'Ecuyer, University of Montreal
8  * Date: 14 August 2001
9  *
10  * RngStreams is free software: you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation, either version 3 of the License, or
13  * (at your option) any later version.
14  *
15  * RngStreams is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with RngStreams. If not, see <http://www.gnu.org/licenses/>.
22  *
23  * We would appreciate that
24  * f you use this software for work leading to publications,
25  * you cite the following relevant articles in which MRG32k3a
26  * and the package with multiple streams were proposed:
27 
28  * P. L'Ecuyer, ``Good Parameter Sets for Combined Multiple Recursive Random Number Generators'',
29  * Operations Research, 47, 1 (1999), 159--164.
30 
31  * P. L'Ecuyer, R. Simard, E. J. Chen, and W. D. Kelton,
32  * ``An Objected-Oriented Random-Number Package with Many Long Streams and Substreams'',
33  * Operations Research, 50, 6 (2002), 1073--1075
34  *
35 \***********************************************************************/
36 
37 
38 #ifndef RNGSTREAM_H
39 #define RNGSTREAM_H
40 
41 #include <string>
42 
43 class RngStream
44 {
45 public:
46 
47 RngStream (const char *name = "");
48 
49 
50 static bool SetPackageSeed (const unsigned long seed[6]);
51 
52 
53 void ResetStartStream ();
54 
55 
56 void ResetStartSubstream ();
57 
58 
59 void ResetNextSubstream ();
60 
61 
62 void SetAntithetic (bool a);
63 
64 
65 void IncreasedPrecis (bool incp);
66 
67 
68 bool SetSeed (const unsigned long seed[6]);
69 
70 
71 void AdvanceState (long e, long c);
72 
73 
74 void GetState (unsigned long seed[6]) const;
75 
76 
77 void WriteState () const;
78 
79 
80 void WriteStateFull () const;
81 
82 
83 double RandU01 ();
84 
85 
86 int RandInt (int i, int j);
87 
88 
89 
90 private:
91 
92 double Cg[6], Bg[6], Ig[6];
93 
94 
95 bool anti, incPrec;
96 
97 
98 std::string name;
99 
100 
101 static double nextSeed[6];
102 
103 
104 double U01 ();
105 
106 
107 double U01d ();
108 
109 
110 };
111 
112 #endif
113 
114 
double Cg[6]
Definition: RngStream.h:92
void AdvanceState(long e, long c)
Definition: RngStream.cpp:408
double RandU01()
Definition: RngStream.cpp:509
void ResetStartSubstream()
Definition: RngStream.cpp:361
static bool SetPackageSeed(const unsigned long seed[6])
Definition: RngStream.cpp:381
bool SetSeed(const unsigned long seed[6])
Definition: RngStream.cpp:392
bool incPrec
Definition: RngStream.h:95
double Bg[6]
Definition: RngStream.h:92
void WriteState() const
Definition: RngStream.cpp:447
std::string name
Definition: RngStream.h:98
void IncreasedPrecis(bool incp)
Definition: RngStream.cpp:493
double Ig[6]
Definition: RngStream.h:92
void ResetStartStream()
Definition: RngStream.cpp:351
Definition: RngStream.h:43
void ResetNextSubstream()
Definition: RngStream.cpp:371
static double nextSeed[6]
Definition: RngStream.h:101
RngStream(const char *name="")
Definition: RngStream.cpp:327
void SetAntithetic(bool a)
Definition: RngStream.cpp:500
bool anti
Definition: RngStream.h:95
void GetState(unsigned long seed[6]) const
Definition: RngStream.cpp:439
double U01d()
Definition: RngStream.cpp:295
static const int i
index of ith thing
Definition: rod_math_v9.h:63
void WriteStateFull() const
Definition: RngStream.cpp:462
double U01()
Definition: RngStream.cpp:266
int RandInt(int i, int j)
Definition: RngStream.cpp:521