Files | |
file | rng-stream.cc |
Class RngStream and MRG32k3a implementation. | |
file | rng-stream.h |
Declaration of class RngStream. | |
Namespaces | |
anonymous_namespace{rng-stream.cc} | |
Unnamed namespace for MRG32k3a implementation details. | |
Classes | |
struct | anonymous_namespace{rng-stream.cc}::Precalculated |
The transition matrices of the two MRG components (in matrix form), raised to all powers of 2 from 1 to 191. More... | |
class | ns3::RngStream |
Combined Multiple-Recursive Generator MRG32k3a. More... | |
Typedefs | |
typedef double | anonymous_namespace{rng-stream.cc}::Matrix[3][3] |
Type for 3x3 matrix of doubles. More... | |
Functions | |
void | anonymous_namespace{rng-stream.cc}::MatMatModM (const Matrix A, const Matrix B, Matrix C, double m) |
Compute the matrix C = A*B MOD m. More... | |
void | anonymous_namespace{rng-stream.cc}::MatTwoPowModM (const Matrix src, Matrix dst, double m, int32_t e) |
Compute the matrix B = (A^(2^e) Mod m); works also if A = B. More... | |
void | anonymous_namespace{rng-stream.cc}::MatVecModM (const Matrix A, const double s[3], double v[3], double m) |
Compute the vector v = A*s MOD m. More... | |
double | anonymous_namespace{rng-stream.cc}::MultModM (double a, double s, double c, double m) |
Return (a*s + c) MOD m; a, s, c and m must be < 2^35. More... | |
Variables | |
const double | anonymous_namespace{rng-stream.cc}::a12 = 1403580.0 |
First component multiplier of n - 2 value. More... | |
const double | anonymous_namespace{rng-stream.cc}::a13n = 810728.0 |
First component multiplier of n - 3 value. More... | |
const Matrix | anonymous_namespace{rng-stream.cc}::A1p0 |
First component transition matrix. More... | |
const double | anonymous_namespace{rng-stream.cc}::a21 = 527612.0 |
Second component multiplier of n - 1 value. More... | |
const double | anonymous_namespace{rng-stream.cc}::a23n = 1370589.0 |
Second component multiplier of n - 3 value. More... | |
const Matrix | anonymous_namespace{rng-stream.cc}::A2p0 |
Second component transition matrix. More... | |
const double | anonymous_namespace{rng-stream.cc}::m1 = 4294967087.0 |
First component modulus, 232 - 209. More... | |
const double | anonymous_namespace{rng-stream.cc}::m2 = 4294944443.0 |
Second component modulus, 232 - 22853. More... | |
const double | anonymous_namespace{rng-stream.cc}::norm = 1.0 / (m1 + 1.0) |
Normalization to obtain randoms on [0,1). More... | |
const double | anonymous_namespace{rng-stream.cc}::two17 = 131072.0 |
Decomposition factor for computing a*s in less than 53 bits, 217 More... | |
const double | anonymous_namespace{rng-stream.cc}::two53 = 9007199254740992.0 |
IEEE-754 floating point precision, 253 More... | |
typedef double anonymous_namespace{rng-stream.cc}::Matrix[3][3] |
Type for 3x3 matrix of doubles.
Definition at line 50 of file rng-stream.cc.
void anonymous_namespace{rng-stream.cc}::MatMatModM | ( | const Matrix | A, |
const Matrix | B, | ||
Matrix | C, | ||
double | m | ||
) |
Compute the matrix C = A*B MOD m.
Assume that -m < s[i] < m. Note: works also if A = C or B = C or A = B = C.
[in] | A | First matrix argument. |
[in] | B | Second matrix argument. |
[out] | C | Result matrix. |
[in] | m | Modulus. |
Definition at line 187 of file rng-stream.cc.
References anonymous_namespace{rng-stream.cc}::MatVecModM().
Referenced by anonymous_namespace{rng-stream.cc}::MatTwoPowModM().
void anonymous_namespace{rng-stream.cc}::MatTwoPowModM | ( | const Matrix | src, |
Matrix | dst, | ||
double | m, | ||
int32_t | e | ||
) |
Compute the matrix B = (A^(2^e) Mod m); works also if A = B.
[in] | src | Matrix input argument A . |
[out] | dst | Matrix output B . |
[in] | m | Modulus. |
[in] | e | The exponent. |
Definition at line 225 of file rng-stream.cc.
References anonymous_namespace{rng-stream.cc}::MatMatModM().
Referenced by anonymous_namespace{rng-stream.cc}::PowerOfTwoConstants().
void anonymous_namespace{rng-stream.cc}::MatVecModM | ( | const Matrix | A, |
const double | s[3], | ||
double | v[3], | ||
double | m | ||
) |
Compute the vector v = A*s MOD m.
Assume that -m < s[i] < m. Works also when v = s.
[in] | A | Matrix argument, 3x3. |
[in] | s | Three component input vector. |
[out] | v | Three component output vector. |
[in] | m | Modulus. |
Definition at line 158 of file rng-stream.cc.
References anonymous_namespace{rng-stream.cc}::MultModM(), and sample-rng-plot::x.
Referenced by ns3::RngStream::AdvanceNthBy(), and anonymous_namespace{rng-stream.cc}::MatMatModM().
double anonymous_namespace{rng-stream.cc}::MultModM | ( | double | a, |
double | s, | ||
double | c, | ||
double | m | ||
) |
Return (a*s + c) MOD m; a, s, c and m must be < 2^35.
This computes the result exactly, without exceeding the 53 bit precision of doubles.
[in] | a | First multiplicative argument. |
[in] | s | Second multiplicative argument. |
[in] | c | Additive argument. |
[in] | m | Modulus. |
(a*s +c) MOD m
Definition at line 118 of file rng-stream.cc.
References anonymous_namespace{rng-stream.cc}::two17.
Referenced by anonymous_namespace{rng-stream.cc}::MatVecModM().
const double anonymous_namespace{rng-stream.cc}::a12 = 1403580.0 |
First component multiplier of n - 2 value.
Definition at line 66 of file rng-stream.cc.
Referenced by ns3::RngStream::RandU01().
const double anonymous_namespace{rng-stream.cc}::a13n = 810728.0 |
First component multiplier of n - 3 value.
Definition at line 70 of file rng-stream.cc.
Referenced by ns3::RngStream::RandU01().
const Matrix anonymous_namespace{rng-stream.cc}::A1p0 |
First component transition matrix.
Definition at line 90 of file rng-stream.cc.
const double anonymous_namespace{rng-stream.cc}::a21 = 527612.0 |
Second component multiplier of n - 1 value.
Definition at line 74 of file rng-stream.cc.
Referenced by ns3::RngStream::RandU01().
const double anonymous_namespace{rng-stream.cc}::a23n = 1370589.0 |
Second component multiplier of n - 3 value.
Definition at line 78 of file rng-stream.cc.
Referenced by ns3::RngStream::RandU01().
const Matrix anonymous_namespace{rng-stream.cc}::A2p0 |
Second component transition matrix.
Definition at line 98 of file rng-stream.cc.
const double anonymous_namespace{rng-stream.cc}::m1 = 4294967087.0 |
First component modulus, 232 - 209.
Definition at line 54 of file rng-stream.cc.
Referenced by ns3::RngStream::AdvanceNthBy(), UanTest::DoPhyTests(), TracedCallbackTypedefTestCase::Checker< T1, T2, T3, T4, T5 >::Invoke(), TracedCallbackTypedefTestCase::Checker< T1, T2, T3, T4, empty >::Invoke(), TracedCallbackTypedefTestCase::Checker< T1, T2, T3, empty, empty >::Invoke(), TracedCallbackTypedefTestCase::Checker< T1, T2, empty, empty, empty >::Invoke(), TracedCallbackTypedefTestCase::Checker< T1, empty, empty, empty, empty >::Invoke(), PbbTestSuite::PbbTestSuite(), ns3::RngStream::RandU01(), and ns3::RngStream::RngStream().
const double anonymous_namespace{rng-stream.cc}::m2 = 4294944443.0 |
Second component modulus, 232 - 22853.
Definition at line 58 of file rng-stream.cc.
Referenced by ns3::RngStream::AdvanceNthBy(), TracedCallbackTypedefTestCase::Checker< T1, T2, T3, T4, T5 >::Invoke(), TracedCallbackTypedefTestCase::Checker< T1, T2, T3, T4, empty >::Invoke(), TracedCallbackTypedefTestCase::Checker< T1, T2, T3, empty, empty >::Invoke(), TracedCallbackTypedefTestCase::Checker< T1, T2, empty, empty, empty >::Invoke(), PbbTestSuite::PbbTestSuite(), ns3::RngStream::RandU01(), and ns3::RngStream::RngStream().
const double anonymous_namespace{rng-stream.cc}::norm = 1.0 / (m1 + 1.0) |
Normalization to obtain randoms on [0,1).
Definition at line 62 of file rng-stream.cc.
Referenced by ns3::RngStream::RandU01().
const double anonymous_namespace{rng-stream.cc}::two17 = 131072.0 |
Decomposition factor for computing a*s in less than 53 bits, 217
Definition at line 82 of file rng-stream.cc.
Referenced by anonymous_namespace{rng-stream.cc}::MultModM().
const double anonymous_namespace{rng-stream.cc}::two53 = 9007199254740992.0 |
IEEE-754 floating point precision, 253
Definition at line 86 of file rng-stream.cc.