equal
deleted
inserted
replaced
59 * (but {@link L64X256Random} does not use a mixing function). |
59 * (but {@link L64X256Random} does not use a mixing function). |
60 * <p> |
60 * <p> |
61 * The LCG subgenerator for {@link L64X256Random} has an update step of the |
61 * The LCG subgenerator for {@link L64X256Random} has an update step of the |
62 * form {@code s = m * s + a}, where {@code s}, {@code m}, and {@code a} are all |
62 * form {@code s = m * s + a}, where {@code s}, {@code m}, and {@code a} are all |
63 * of type {@code long}; {@code s} is the mutable state, the multiplier {@code m} |
63 * of type {@code long}; {@code s} is the mutable state, the multiplier {@code m} |
64 * is fixed (the same for all instances of {@link L64X256Random}}) and the addend |
64 * is fixed (the same for all instances of {@link L64X256Random}) and the addend |
65 * {@code a} is a parameter (a final field of the instance). The parameter |
65 * {@code a} is a parameter (a final field of the instance). The parameter |
66 * {@code a} is required to be odd (this allows the LCG to have the maximal |
66 * {@code a} is required to be odd (this allows the LCG to have the maximal |
67 * period, namely 2<sup>64</sup>); therefore there are 2<sup>63</sup> distinct choices |
67 * period, namely 2<sup>64</sup>); therefore there are 2<sup>63</sup> distinct choices |
68 * of parameter. |
68 * of parameter. |
69 * <p> |
69 * <p> |
323 */ |
323 */ |
324 public long nextLong() { |
324 public long nextLong() { |
325 final long z = s + x0; |
325 final long z = s + x0; |
326 s = M * s + a; // LCG |
326 s = M * s + a; // LCG |
327 long q0 = x0, q1 = x1, q2 = x2, q3 = x3; |
327 long q0 = x0, q1 = x1, q2 = x2, q3 = x3; |
328 { long t = q1 << 17; q2 ^= q0; q3 ^= q1; q1 ^= q2; q0 ^= q3; q2 ^= t; q3 = Long.rotateLeft(q3, 45); } // xoshiro256 1.0 |
328 { // xoshiro256 1.0 |
|
329 long t = q1 << 17; |
|
330 q2 ^= q0; |
|
331 q3 ^= q1; |
|
332 q1 ^= q2; |
|
333 q0 ^= q3; |
|
334 q2 ^= t; |
|
335 q3 = Long.rotateLeft(q3, 45); |
|
336 } |
329 x0 = q0; x1 = q1; x2 = q2; x3 = q3; |
337 x0 = q0; x1 = q1; x2 = q2; x3 = q3; |
330 return z; |
338 return z; |
331 } |
339 } |
332 |
340 |
333 public BigInteger period() { |
341 public BigInteger period() { |