43 const double m1 = 4294967087.0;
44 const double m2 = 4294944443.0;
45 const double norm = 1.0 / (m1 + 1.0);
46 const double a12 = 1403580.0;
47 const double a13n = 810728.0;
48 const double a21 = 527612.0;
49 const double a23n = 1370589.0;
51 const double two53 = 9007199254740992.0;
56 { -810728.0, 1403580.0, 0.0 }
62 { -1370589.0, 0.0, 527612.0 }
69 double MultModM (
double a,
double s,
double c,
double m)
76 if (v >= two53 || v <= -two53)
78 a1 =
static_cast<int32_t
> (a /
two17);
81 a1 =
static_cast<int32_t
> (v / m);
83 v = v * two17 + a * s + c;
86 a1 =
static_cast<int32_t
> (v / m);
88 if ((v -= a1 * m) < 0.0)
109 for (i = 0; i < 3; ++i)
111 x[i] =
MultModM (A[i][0], s[0], 0.0, m);
112 x[i] =
MultModM (A[i][1], s[1], x[i], m);
113 x[i] =
MultModM (A[i][2], s[2], x[i], m);
115 for (i = 0; i < 3; ++i)
133 for (i = 0; i < 3; ++i)
135 for (j = 0; j < 3; ++j)
140 for (j = 0; j < 3; ++j)
145 for (i = 0; i < 3; ++i)
147 for (j = 0; j < 3; ++j)
163 for (i = 0; i < 3; ++i)
165 for (j = 0; j < 3; ++j)
167 dst[i][j] = src[i][j];
171 for (i = 0; i < e; i++)
225 for (
int i = 0; i < 190; i++)
231 return precalculated;
236 for (
int i = 0; i < 3; i ++)
238 for (
int j = 0; j < 3; j++)
240 a1p[i][j] = constants.
a1[n-1][i][j];
241 a2p[i][j] = constants.
a2[n-1][i][j];
260 k =
static_cast<int32_t
> (p1 /
m1);
266 m_currentState[0] = m_currentState[1]; m_currentState[1] = m_currentState[2]; m_currentState[2] = p1;
269 p2 =
a21 * m_currentState[5] -
a23n * m_currentState[3];
270 k =
static_cast<int32_t
> (p2 /
m2);
276 m_currentState[3] = m_currentState[4]; m_currentState[4] = m_currentState[5]; m_currentState[5] = p2;
279 u = ((p1 > p2) ? (p1 - p2) *
norm : (p1 - p2 +
m1) *
norm);
286 if (seedNumber >=
m1 || seedNumber >=
m2 || seedNumber == 0)
290 for (
int i = 0; i < 6; ++i)
300 for (
int i = 0; i < 6; ++i)
310 for (
int i = 0; i < 64; i++)
313 int bit = (nth >> nbit) & 0x1;
NS_FATAL_x macro definitions.
void MatTwoPowModM(const Matrix src, Matrix dst, double m, int32_t e)
void MatVecModM(const Matrix A, const double s[3], double v[3], double m)
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
#define NS_FATAL_ERROR(msg)
Fatal error handling.
double MultModM(double a, double s, double c, double m)
Combined Multiple-Recursive Generator MRG32k3a.
void AdvanceNthBy(uint64_t nth, int by, double state[6])
RngStream(uint32_t seed, uint64_t stream, uint64_t substream)
Every class exported by the ns3 library is enclosed in the ns3 namespace.
struct Precalculated PowerOfTwoConstants(void)
double RandU01(void)
Generate the next random number for this stream.
void PowerOfTwoMatrix(int n, Matrix a1p, Matrix a2p)
void MatMatModM(const Matrix A, const Matrix B, Matrix C, double m)