equal
deleted
inserted
replaced
59 * (but {@link L64X128Random} does not use a mixing function). |
59 * (but {@link L64X128Random} does not use a mixing function). |
60 * <p> |
60 * <p> |
61 * The LCG subgenerator for {@link L64X128Random} has an update step of the |
61 * The LCG subgenerator for {@link L64X128Random} 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 L64X128Random}}) and the addend |
64 * is fixed (the same for all instances of {@link L64X128Random}) 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> |
309 */ |
309 */ |
310 public long nextLong() { |
310 public long nextLong() { |
311 final long z = s + x0; |
311 final long z = s + x0; |
312 s = M * s + a; // LCG |
312 s = M * s + a; // LCG |
313 long q0 = x0, q1 = x1; |
313 long q0 = x0, q1 = x1; |
314 { q1 ^= q0; q0 = Long.rotateLeft(q0, 24); q0 = q0 ^ q1 ^ (q1 << 16); q1 = Long.rotateLeft(q1, 37); } // xoroshiro128v1_0 |
314 { // xoroshiro128v1_0 |
|
315 q1 ^= q0; |
|
316 q0 = Long.rotateLeft(q0, 24); |
|
317 q0 = q0 ^ q1 ^ (q1 << 16); |
|
318 q1 = Long.rotateLeft(q1, 37); |
|
319 } |
315 x0 = q0; x1 = q1; |
320 x0 = q0; x1 = q1; |
316 return z; |
321 return z; |
317 } |
322 } |
318 |
323 |
319 public BigInteger period() { |
324 public BigInteger period() { |