equal
deleted
inserted
replaced
59 * (and {@link L64X256MixRandom} does use a mixing function). |
59 * (and {@link L64X256MixRandom} does use a mixing function). |
60 * <p> |
60 * <p> |
61 * The LCG subgenerator for {@link L64X256MixRandom} has an update step of the |
61 * The LCG subgenerator for {@link L64X256MixRandom} 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 L64X256MixRandom}}) and the addend |
64 * is fixed (the same for all instances of {@link L64X256MixRandom}) 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> |
325 */ |
325 */ |
326 public long nextLong() { |
326 public long nextLong() { |
327 final long z = s + x0; |
327 final long z = s + x0; |
328 s = M * s + a; // LCG |
328 s = M * s + a; // LCG |
329 long q0 = x0, q1 = x1, q2 = x2, q3 = x3; |
329 long q0 = x0, q1 = x1, q2 = x2, q3 = x3; |
330 { long t = q1 << 17; q2 ^= q0; q3 ^= q1; q1 ^= q2; q0 ^= q3; q2 ^= t; q3 = Long.rotateLeft(q3, 45); } // xoshiro256 1.0 |
330 { // xoshiro256 1.0 |
|
331 long t = q1 << 17; |
|
332 q2 ^= q0; |
|
333 q3 ^= q1; |
|
334 q1 ^= q2; |
|
335 q0 ^= q3; |
|
336 q2 ^= t; |
|
337 q3 = Long.rotateLeft(q3, 45); |
|
338 } |
331 x0 = q0; x1 = q1; x2 = q2; x3 = q3; |
339 x0 = q0; x1 = q1; x2 = q2; x3 = q3; |
332 return RandomSupport.mixLea64(z); // mixing function |
340 return RandomSupport.mixLea64(z); // mixing function |
333 } |
341 } |
334 |
342 |
335 public BigInteger period() { |
343 public BigInteger period() { |