48 private static final long serialVersionUID = 70510L;
53 private static final double m1 = 4294967087.0;
54 private static final double m2 = 4294944443.0;
55 private static final double a12 = 1403580.0;
56 private static final double a13n = 810728.0;
57 private static final double a21 = 527612.0;
58 private static final double a23n = 1370589.0;
59 private static final double two17 = 131072.0;
60 private static final double two53 = 9007199254740992.0;
61 private static final double invtwo24 = 5.9604644775390625e-8;
62 private static final double norm = 2.328306549295727688e-10;
72 private static final double A1p0[][] = { { 0.0, 1.0, 0.0 }, { 0.0, 0.0, 1.0 }, { -810728.0, 1403580.0, 0.0 } };
73 private static final double A2p0[][] = { { 0.0, 1.0, 0.0 }, { 0.0, 0.0, 1.0 }, { -1370589.0, 0.0, 527612.0 } };
74 private static final double A1p76[][] = { { 82758667.0, 1871391091.0, 4127413238.0 },
75 { 3672831523.0, 69195019.0, 1871391091.0 }, { 3672091415.0, 3528743235.0, 69195019.0 } };
76 private static final double A2p76[][] = { { 1511326704.0, 3759209742.0, 1610795712.0 },
77 { 4292754251.0, 1511326704.0, 3889917532.0 }, { 3859662829.0, 4292754251.0, 3708466080.0 } };
78 private static final double A1p127[][] = { { 2427906178.0, 3580155704.0, 949770784.0 },
79 { 226153695.0, 1230515664.0, 3580155704.0 }, { 1988835001.0, 986791581.0, 1230515664.0 } };
80 private static final double A2p127[][] = { { 1464411153.0, 277697599.0, 1610723613.0 },
81 { 32183930.0, 1464411153.0, 1022607788.0 }, { 2824425944.0, 32183930.0, 2093834863.0 } };
86 private static double nextSeed[] = { 12345, 12345, 12345, 12345, 12345, 12345 };
87 private double Cg0, Cg1, Cg2, Cg3, Cg4, Cg5;
88 private double Bg[] =
new double[6];
89 private double Ig[] =
new double[6];
96 private static void multMatVect(
double[] v,
double[][] A,
double m1,
double[][] B,
double m2) {
97 double[] vv =
new double[3];
98 for (
int i = 0; i < 3; i++)
101 for (
int i = 0; i < 3; i++)
104 for (
int i = 0; i < 3; i++)
107 for (
int i = 0; i < 3; i++)
124 for (
int i = 0; i < 6; i++)
127 multMatVect(nextSeed, A1p127, m1, A2p127, m2);
154 for (
int i = 0; i < 6; ++i)
155 nextSeed[i] = seed[i];
173 for (
int i = 0; i < 6; ++i)
179 for (
int i = 0; i < 6; ++i)
194 multMatVect(Bg, A1p76, m1, A2p76, m2);
206 return new long[] { (long) Cg0, (
long) Cg1, (long) Cg2, (
long) Cg3, (long) Cg4, (
long) Cg5 };
218 str.
append(
"The current state of the MRG32k3a");
219 if (name !=
null && name.length() > 0)
222 str.
append((
long) Cg0 +
", ");
223 str.
append((
long) Cg1 +
", ");
224 str.
append((
long) Cg2 +
", ");
225 str.
append((
long) Cg3 +
", ");
226 str.
append((
long) Cg4 +
", ");
240 str.
append(
"The MRG32k3a stream");
241 if (name !=
null && name.length() > 0)
247 for (
int i = 0; i < 5; i++)
248 str.
append((
long) Ig[i] +
", ");
252 for (
int i = 0; i < 5; i++)
253 str.
append((
long) Bg[i] +
", ");
257 str.
append((
long) Cg0 +
", ");
258 str.
append((
long) Cg1 +
", ");
259 str.
append((
long) Cg2 +
", ");
260 str.
append((
long) Cg3 +
", ");
261 str.
append((
long) Cg4 +
", ");
276 retour.Bg =
new double[6];
277 retour.Ig =
new double[6];
278 for (
int i = 0; i < 6; i++) {
279 retour.Bg[i] = Bg[i];
280 retour.Ig[i] = Ig[i];
289 p1 = a12 * Cg1 - a13n * Cg0;
298 p2 = a21 * Cg5 - a23n * Cg3;
307 return ((p1 > p2) ? (p1 - p2) * norm : (p1 - p2 + m1) * norm);
310 private static void validateSeed(
long seed[]) {
312 throw new IllegalArgumentException(
"Seed must contain 6 values");
313 if (seed[0] == 0 && seed[1] == 0 && seed[2] == 0)
314 throw new IllegalArgumentException(
"The first 3 values must not be 0");
315 if (seed[3] == 0 && seed[4] == 0 && seed[5] == 0)
316 throw new IllegalArgumentException(
"The last 3 values must not be 0");
317 final long m1 = 4294967087L;
318 if (seed[0] >= m1 || seed[1] >= m1 || seed[2] >= m1)
319 throw new IllegalArgumentException(
"The first 3 values must be less than " + m1);
320 final long m2 = 4294944443L;
321 if (seed[3] >= m2 || seed[4] >= m2 || seed[5] >= m2)
322 throw new IllegalArgumentException(
"The last 3 values must be less than " + m2);