author | Mathieu Lacage <mathieu.lacage@sophia.inria.fr> |
Mon, 02 Jun 2008 10:30:24 -0700 | |
changeset 3190 | 51fe9001a679 |
parent 2797 | 41489a849fc3 |
child 4221 | 73b49aa25221 |
permissions | -rw-r--r-- |
346
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
1 |
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
2 |
// |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
3 |
// Copyright (C) 2001 Pierre L'Ecuyer (lecuyer@iro.umontreal.ca) |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
4 |
// |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
5 |
// This program is free software; you can redistribute it and/or modify |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
6 |
// it under the terms of the GNU General Public License version 2 as |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
7 |
// published by the Free Software Foundation; |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
8 |
// |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
9 |
// This program is distributed in the hope that it will be useful, |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
10 |
// but WITHOUT ANY WARRANTY; without even the implied warranty of |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
11 |
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
12 |
// GNU General Public License for more details. |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
13 |
// |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
14 |
// You should have received a copy of the GNU General Public License |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
15 |
// along with this program; if not, write to the Free Software |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
16 |
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
17 |
// |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
18 |
// Modified for ns-3 by: Rajib Bhattacharjea<raj.b@gatech.edu> |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
19 |
|
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
20 |
#ifndef RNGSTREAM_H |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
21 |
#define RNGSTREAM_H |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
22 |
#include <string> |
676
0cf407300fa6
Fixed the problems that were found by Mathieu Lacage in the first
Emmanuelle Laprise
parents:
675
diff
changeset
|
23 |
#include <stdint.h> |
346
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
24 |
|
2797
41489a849fc3
documentation for class RngStream
Tom Henderson <tomh@tomh.org>
parents:
676
diff
changeset
|
25 |
namespace ns3 { |
346
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
26 |
|
2797
41489a849fc3
documentation for class RngStream
Tom Henderson <tomh@tomh.org>
parents:
676
diff
changeset
|
27 |
/** |
41489a849fc3
documentation for class RngStream
Tom Henderson <tomh@tomh.org>
parents:
676
diff
changeset
|
28 |
* \ingroup core |
41489a849fc3
documentation for class RngStream
Tom Henderson <tomh@tomh.org>
parents:
676
diff
changeset
|
29 |
* \ingroup randomvariable |
41489a849fc3
documentation for class RngStream
Tom Henderson <tomh@tomh.org>
parents:
676
diff
changeset
|
30 |
* |
41489a849fc3
documentation for class RngStream
Tom Henderson <tomh@tomh.org>
parents:
676
diff
changeset
|
31 |
* \brief Combined Multiple-Recursive Generator MRG32k3a |
41489a849fc3
documentation for class RngStream
Tom Henderson <tomh@tomh.org>
parents:
676
diff
changeset
|
32 |
* |
41489a849fc3
documentation for class RngStream
Tom Henderson <tomh@tomh.org>
parents:
676
diff
changeset
|
33 |
* This class is the combined multiple-recursive random number |
41489a849fc3
documentation for class RngStream
Tom Henderson <tomh@tomh.org>
parents:
676
diff
changeset
|
34 |
* generator called MRG32k3a. The ns3::RandomVariableBase class |
41489a849fc3
documentation for class RngStream
Tom Henderson <tomh@tomh.org>
parents:
676
diff
changeset
|
35 |
* holds a static instance of this class. The details of this |
41489a849fc3
documentation for class RngStream
Tom Henderson <tomh@tomh.org>
parents:
676
diff
changeset
|
36 |
* class are explained in: |
41489a849fc3
documentation for class RngStream
Tom Henderson <tomh@tomh.org>
parents:
676
diff
changeset
|
37 |
* http://www.iro.umontreal.ca/~lecuyer/myftp/papers/streams00.pdf |
41489a849fc3
documentation for class RngStream
Tom Henderson <tomh@tomh.org>
parents:
676
diff
changeset
|
38 |
*/ |
346
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
39 |
class RngStream { |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
40 |
public: //public api |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
41 |
RngStream (); |
360
7bffd987426c
Fixed major memory bug and docs in RandomVariable
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
346
diff
changeset
|
42 |
RngStream (const RngStream&); |
346
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
43 |
void InitializeStream(); // Separate initialization |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
44 |
void ResetStartStream (); |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
45 |
void ResetStartSubstream (); |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
46 |
void ResetNextSubstream (); |
364
9df87117d468
RandomVariable API in line with Michelle's comments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
360
diff
changeset
|
47 |
void ResetNthSubstream(uint32_t N); |
346
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
48 |
void SetAntithetic (bool a); |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
49 |
void IncreasedPrecis (bool incp); |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
50 |
bool SetSeeds (const uint32_t seed[6]); |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
51 |
void AdvanceState (int32_t e, int32_t c); |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
52 |
void GetState (uint32_t seed[6]) const; |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
53 |
double RandU01 (); |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
54 |
int32_t RandInt (int32_t i, int32_t j); |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
55 |
public: //public static api |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
56 |
static bool SetPackageSeed (const uint32_t seed[6]); |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
57 |
static bool CheckSeed(const uint32_t seed[6]); |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
58 |
private: //members |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
59 |
double Cg[6], Bg[6], Ig[6]; |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
60 |
bool anti, incPrec; |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
61 |
double U01 (); |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
62 |
double U01d (); |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
63 |
private: //static data |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
64 |
static double nextSeed[6]; |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
65 |
}; |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
66 |
|
2797
41489a849fc3
documentation for class RngStream
Tom Henderson <tomh@tomh.org>
parents:
676
diff
changeset
|
67 |
} //namespace ns3 |
346
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
68 |
|
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
69 |
#endif |
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
70 |
|
4a76f247e7dc
Add random number files, base class Application
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
71 |