57 const double m1   =       4294967087.0;
 
   60 const double m2   =       4294944443.0;
 
   63 const double norm =       1.0 / (m1 + 1.0);
 
   66 const double a12  =       1403580.0;
 
   69 const double a13n =       810728.0;
 
   72 const double a21  =       527612.0;
 
   75 const double a23n =       1370589.0;
 
   81 const double two53 =      9007199254740992.0;
 
   87   { -810728.0,  1403580.0,       0.0 }
 
   94   { -1370589.0,        0.0,  527612.0 }
 
  111 double MultModM (
double a, 
double s, 
double c, 
double m)
 
  118   if (v >= two53 || v <= -two53)
 
  120       a1 = 
static_cast<int32_t
> (a / 
two17);
 
  123       a1 = 
static_cast<int32_t
> (v / m);
 
  125       v = v * two17 + a * s + c;
 
  128   a1 = 
static_cast<int32_t
> (v / m);
 
  130   if ((v -= a1 * m) < 0.0)
 
  151 void MatVecModM (
const Matrix A, 
const double s[3], 
double v[3],
 
  157   for (i = 0; i < 3; ++i)
 
  159       x[i] = 
MultModM (A[i][0], s[0], 0.0, m);
 
  160       x[i] = 
MultModM (A[i][1], s[1], x[i], m);
 
  161       x[i] = 
MultModM (A[i][2], s[2], x[i], m);
 
  163   for (i = 0; i < 3; ++i)
 
  187   for (i = 0; i < 3; ++i)
 
  189       for (j = 0; j < 3; ++j)
 
  194       for (j = 0; j < 3; ++j)
 
  199   for (i = 0; i < 3; ++i)
 
  201       for (j = 0; j < 3; ++j)
 
  223   for (i = 0; i < 3; ++i)
 
  225       for (j = 0; j < 3; ++j)
 
  227           dst[i][j] = src[i][j];
 
  231   for (i = 0; i < e; i++)
 
  247 void MatPowModM (
const double A[3][3], 
double B[3][3], 
double m, int32_t n)
 
  253   for (i = 0; i < 3; ++i)
 
  255       for (j = 0; j < 3; ++j)
 
  261   for (j = 0; j < 3; ++j)
 
  297   for (
int i = 0; i < 190; i++)
 
  303   return precalculated;
 
  315   for (
int i = 0; i < 3; i ++)
 
  317       for (
int j = 0; j < 3; j++)
 
  319           a1p[i][j] = constants.
a1[n-1][i][j];
 
  320           a2p[i][j] = constants.
a2[n-1][i][j];
 
  338   p1 = 
a12 * m_currentState[1] - 
a13n * m_currentState[0];
 
  339   k = 
static_cast<int32_t
> (p1 / 
m1);
 
  345   m_currentState[0] = m_currentState[1]; m_currentState[1] = m_currentState[2]; m_currentState[2] = p1;
 
  348   p2 = 
a21 * m_currentState[5] - 
a23n * m_currentState[3];
 
  349   k = 
static_cast<int32_t
> (p2 / 
m2);
 
  355   m_currentState[3] = m_currentState[4]; m_currentState[4] = m_currentState[5]; m_currentState[5] = p2;
 
  358   u = ((p1 > p2) ? (p1 - p2) * 
norm : (p1 - p2 + 
m1) * 
norm);
 
  365   if (seedNumber >= 
m1 || seedNumber >= 
m2 || seedNumber == 0)
 
  369   for (
int i = 0; i < 6; ++i)
 
  371       m_currentState[i] = seedNumber;
 
  373   AdvanceNthBy (stream, 127, m_currentState);
 
  374   AdvanceNthBy (substream, 76, m_currentState);
 
  379   for (
int i = 0; i < 6; ++i)
 
  389   for (
int i = 0; i < 64; i++)
 
  392       int bit = (nth >> nbit) & 0x1;
 
NS_FATAL_x macro definitions. 
 
double Matrix[3][3]
Type for 3x3 matrix of doubles. 
 
The transition matrices of the two MRG components (in matrix form), raised to all powers of 2 from 1 ...
 
const double a23n
Second component multiplier of n - 3 value. 
 
const double a13n
First component multiplier of n - 3 value. 
 
const Matrix A2p0
Second component transition matrix. 
 
const double two53
IEEE-754 floating point precision, 253 
 
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name. 
 
const double two17
Decomposition factor for computing a*s in less than 53 bits, 217 
 
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate. 
 
const double m1
First component modulus, 232 - 209. 
 
Namespace for MRG32k3a implementation details. 
 
void MatMatModM(const Matrix A, const Matrix B, Matrix C, double m)
Compute the matrix C = A*B MOD m. 
 
const Matrix A1p0
First component transition matrix. 
 
Combined Multiple-Recursive Generator MRG32k3a. 
 
double MultModM(double a, double s, double c, double m)
Return (a*s + c) MOD m; a, s, c and m must be < 2^35. 
 
void AdvanceNthBy(uint64_t nth, int by, double state[6])
Advance state of the RNG by leaps and bounds. 
 
double m_currentState[6]
The RNG state vector. 
 
const double a21
Second component multiplier of n - 1 value. 
 
RngStream(uint32_t seed, uint64_t stream, uint64_t substream)
Construct from explicit seed, stream and substream values. 
 
Every class exported by the ns3 library is enclosed in the ns3 namespace. 
 
ns3::RngStream declaration. 
 
struct Precalculated PowerOfTwoConstants(void)
Compute the transition matrices of the two MRG components raised to all powers of 2 from 1 to 191...
 
double RandU01(void)
Generate the next random number for this stream. 
 
Matrix a2[190]
Second component transition matrix powers. 
 
void MatVecModM(const Matrix A, const double s[3], double v[3], double m)
Compute the vector v = A*s MOD m. 
 
void MatPowModM(const double A[3][3], double B[3][3], double m, int32_t n)
Compute the matrix B = (A^n Mod m); works even if A = B. 
 
const double norm
Normalization to obtain randoms on [0,1). 
 
const double m2
Second component modulus, 232 - 22853. 
 
void 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. 
 
void PowerOfTwoMatrix(int n, Matrix a1p, Matrix a2p)
Get the transition matrices raised to a power of 2. 
 
const double a12
First component multiplier of n - 2 value. 
 
Matrix a1[190]
First component transition matrix powers.