This is an automated email from the ASF dual-hosted git repository. aherbert pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-rng.git
commit 43047b4e017c82f37321c08c7ace34be584e623f Author: aherbert <aherb...@apache.org> AuthorDate: Mon Oct 7 15:21:31 2019 +0100 RNG-122: Use XoRoShiRo1024PlusPlus as the default source of randomness. --- .../org/apache/commons/rng/simple/internal/SeedFactory.java | 12 ++++++------ src/changes/changes.xml | 3 +++ 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/commons-rng-simple/src/main/java/org/apache/commons/rng/simple/internal/SeedFactory.java b/commons-rng-simple/src/main/java/org/apache/commons/rng/simple/internal/SeedFactory.java index 4b336ea..c444074 100644 --- a/commons-rng-simple/src/main/java/org/apache/commons/rng/simple/internal/SeedFactory.java +++ b/commons-rng-simple/src/main/java/org/apache/commons/rng/simple/internal/SeedFactory.java @@ -23,7 +23,7 @@ import org.apache.commons.rng.core.util.NumberFactory; import org.apache.commons.rng.UniformRandomProvider; import org.apache.commons.rng.core.source64.RandomLongSource; import org.apache.commons.rng.core.source64.SplitMix64; -import org.apache.commons.rng.core.source64.XorShift1024StarPhi; +import org.apache.commons.rng.core.source64.XoRoShiRo1024PlusPlus; /** * Utilities related to seeding. @@ -45,8 +45,8 @@ import org.apache.commons.rng.core.source64.XorShift1024StarPhi; * @since 1.0 */ public final class SeedFactory { - /** Size of the state array of "XorShift1024StarPhi". */ - private static final int XOR_SHIFT_1024_STATE_SIZE = 16; + /** Size of the state array of "XoRoShiRo1024PlusPlus". */ + private static final int XO_RO_SHI_RO_1024_STATE_SIZE = 16; /** Size of block to fill in an {@code int[]} seed per synchronized operation. */ private static final int INT_ARRAY_BLOCK_SIZE = 8; /** Size of block to fill in a {@code long[]} seed per synchronized operation. */ @@ -68,10 +68,10 @@ public final class SeedFactory { // Use a secure RNG so that different instances (e.g. in multiple JVM // instances started in rapid succession) will have different seeds. final SecureRandom seedGen = new SecureRandom(); - final byte[] bytes = new byte[8 * XOR_SHIFT_1024_STATE_SIZE]; + final byte[] bytes = new byte[8 * XO_RO_SHI_RO_1024_STATE_SIZE]; seedGen.nextBytes(bytes); final long[] seed = NumberFactory.makeLongArray(bytes); - // The XorShift1024StarPhi generator cannot recover from an all zero seed and + // The XoRoShiRo1024PlusPlus generator cannot recover from an all zero seed and // will produce low quality initial output if initialised with some zeros. // Ensure it is non zero at all array positions using a SplitMix64 // generator (this is insensitive to a zero seed so can use the first seed value). @@ -80,7 +80,7 @@ public final class SeedFactory { seed[i] = ensureNonZero(rng, seed[i]); } - SEED_GENERATOR = new XorShift1024StarPhi(seed); + SEED_GENERATOR = new XoRoShiRo1024PlusPlus(seed); } /** diff --git a/src/changes/changes.xml b/src/changes/changes.xml index ae40c29..d45e789 100644 --- a/src/changes/changes.xml +++ b/src/changes/changes.xml @@ -75,6 +75,9 @@ re-run tests that fail, and pass the build if they succeed within the allotted number of reruns (the test will be marked as 'flaky' in the report). "> + <action dev="aherbert" type="update" issue="RNG-122"> + "SeedFactory": Use XoRoShiRo1024PlusPlus as the default source of randomness. + </action> <action dev="aherbert" type="update" issue="RNG-121"> "ChengBetaSampler": Algorithms for different distribution parameters have been delegated to specialised classes.