Multimodule support
Project: http://git-wip-us.apache.org/repos/asf/commons-rng/repo Commit: http://git-wip-us.apache.org/repos/asf/commons-rng/commit/42530e25 Tree: http://git-wip-us.apache.org/repos/asf/commons-rng/tree/42530e25 Diff: http://git-wip-us.apache.org/repos/asf/commons-rng/diff/42530e25 Branch: refs/heads/multimodule Commit: 42530e25b5fb1c077ec0ebf31ece540483e156e4 Parents: 3139232 Author: Artem Barger <ar...@bargr.net> Authored: Fri Oct 21 02:02:07 2016 +0300 Committer: Artem Barger <ar...@bargr.net> Committed: Wed Oct 26 01:36:36 2016 +0300 ---------------------------------------------------------------------- commons-rng-core/clirr-ignored.xml | 21 + commons-rng-core/findbugs-exclude-filter.xml | 27 + commons-rng-core/pmd-ruleset.xml | 57 + commons-rng-core/pom.xml | 32 + commons-rng-core/src/assembly/bin.xml | 48 + commons-rng-core/src/assembly/src.xml | 41 + commons-rng-core/src/changes/changes.xml | 64 + commons-rng-core/src/changes/release-notes.vm | 140 + .../apache/commons/rng/RandomProviderState.java | 25 + .../org/apache/commons/rng/RandomSource.java | 539 +++ .../rng/RestorableUniformRandomProvider.java | 49 + .../commons/rng/UniformRandomProvider.java | 116 + .../commons/rng/internal/BaseProvider.java | 153 + .../commons/rng/internal/ProviderBuilder.java | 381 ++ .../commons/rng/internal/package-info.java | 52 + .../rng/internal/source32/AbstractWell.java | 201 + .../rng/internal/source32/ISAACRandom.java | 267 ++ .../rng/internal/source32/IntProvider.java | 130 + .../rng/internal/source32/JDKRandom.java | 98 + .../rng/internal/source32/KISSRandom.java | 121 + .../rng/internal/source32/MersenneTwister.java | 244 ++ .../internal/source32/MultiplyWithCarry256.java | 124 + .../rng/internal/source32/RandomIntSource.java | 30 + .../rng/internal/source32/Well1024a.java | 78 + .../rng/internal/source32/Well19937a.java | 80 + .../rng/internal/source32/Well19937c.java | 56 + .../rng/internal/source32/Well44497a.java | 83 + .../rng/internal/source32/Well44497b.java | 56 + .../commons/rng/internal/source32/Well512a.java | 78 + .../rng/internal/source32/package-info.java | 52 + .../rng/internal/source64/LongProvider.java | 134 + .../internal/source64/MersenneTwister64.java | 202 + .../rng/internal/source64/RandomLongSource.java | 30 + .../rng/internal/source64/SplitMix64.java | 75 + .../commons/rng/internal/source64/TwoCmres.java | 307 ++ .../rng/internal/source64/XorShift1024Star.java | 94 + .../rng/internal/source64/package-info.java | 52 + .../rng/internal/util/ByteArray2IntArray.java | 39 + .../rng/internal/util/ByteArray2LongArray.java | 39 + .../commons/rng/internal/util/Int2Long.java | 31 + .../commons/rng/internal/util/IntArray2Int.java | 35 + .../rng/internal/util/IntArray2LongArray.java | 38 + .../commons/rng/internal/util/Long2Int.java | 30 + .../rng/internal/util/Long2IntArray.java | 44 + .../rng/internal/util/Long2LongArray.java | 50 + .../rng/internal/util/LongArray2IntArray.java | 37 + .../rng/internal/util/LongArray2Long.java | 35 + .../rng/internal/util/NoOpConverter.java | 34 + .../rng/internal/util/NumberFactory.java | 332 ++ .../rng/internal/util/SeedConverter.java | 35 + .../internal/util/SeedConverterComposer.java | 50 + .../commons/rng/internal/util/SeedFactory.java | 357 ++ .../commons/rng/internal/util/package-info.java | 22 + .../org/apache/commons/rng/package-info.java | 95 + commons-rng-core/src/site/apt/userguide/rng.apt | 510 +++ .../site/resources/images/commons_rng.small.png | Bin 0 -> 89955 bytes .../src/site/resources/profile.jacoco | 17 + .../src/site/resources/style/project.css | 18 + .../txt/userguide/stress/dh/run_1/dh_1 | 154 + .../txt/userguide/stress/dh/run_1/dh_10 | 178 + .../txt/userguide/stress/dh/run_1/dh_11 | 140 + .../txt/userguide/stress/dh/run_1/dh_12 | 172 + .../txt/userguide/stress/dh/run_1/dh_13 | 138 + .../txt/userguide/stress/dh/run_1/dh_14 | 140 + .../txt/userguide/stress/dh/run_1/dh_15 | 161 + .../txt/userguide/stress/dh/run_1/dh_2 | 172 + .../txt/userguide/stress/dh/run_1/dh_3 | 203 + .../txt/userguide/stress/dh/run_1/dh_4 | 229 ++ .../txt/userguide/stress/dh/run_1/dh_5 | 168 + .../txt/userguide/stress/dh/run_1/dh_6 | 141 + .../txt/userguide/stress/dh/run_1/dh_7 | 170 + .../txt/userguide/stress/dh/run_1/dh_8 | 168 + .../txt/userguide/stress/dh/run_1/dh_9 | 140 + .../txt/userguide/stress/dh/run_2/dh_1 | 151 + .../txt/userguide/stress/dh/run_2/dh_10 | 138 + .../txt/userguide/stress/dh/run_2/dh_11 | 139 + .../txt/userguide/stress/dh/run_2/dh_12 | 171 + .../txt/userguide/stress/dh/run_2/dh_13 | 139 + .../txt/userguide/stress/dh/run_2/dh_14 | 168 + .../txt/userguide/stress/dh/run_2/dh_15 | 143 + .../txt/userguide/stress/dh/run_2/dh_2 | 141 + .../txt/userguide/stress/dh/run_2/dh_3 | 180 + .../txt/userguide/stress/dh/run_2/dh_4 | 151 + .../txt/userguide/stress/dh/run_2/dh_5 | 142 + .../txt/userguide/stress/dh/run_2/dh_6 | 258 ++ .../txt/userguide/stress/dh/run_2/dh_7 | 175 + .../txt/userguide/stress/dh/run_2/dh_8 | 139 + .../txt/userguide/stress/dh/run_2/dh_9 | 169 + .../txt/userguide/stress/dh/run_3/dh_1 | 150 + .../txt/userguide/stress/dh/run_3/dh_10 | 169 + .../txt/userguide/stress/dh/run_3/dh_11 | 140 + .../txt/userguide/stress/dh/run_3/dh_12 | 138 + .../txt/userguide/stress/dh/run_3/dh_13 | 291 ++ .../txt/userguide/stress/dh/run_3/dh_14 | 140 + .../txt/userguide/stress/dh/run_3/dh_15 | 139 + .../txt/userguide/stress/dh/run_3/dh_2 | 141 + .../txt/userguide/stress/dh/run_3/dh_3 | 140 + .../txt/userguide/stress/dh/run_3/dh_4 | 200 + .../txt/userguide/stress/dh/run_3/dh_5 | 139 + .../txt/userguide/stress/dh/run_3/dh_6 | 139 + .../txt/userguide/stress/dh/run_3/dh_7 | 139 + .../txt/userguide/stress/dh/run_3/dh_8 | 170 + .../txt/userguide/stress/dh/run_3/dh_9 | 143 + .../txt/userguide/stress/tu/run_1/tu_1 | 3879 +++++++++++++++++ .../txt/userguide/stress/tu/run_1/tu_10 | 3803 +++++++++++++++++ .../txt/userguide/stress/tu/run_1/tu_11 | 3803 +++++++++++++++++ .../txt/userguide/stress/tu/run_1/tu_12 | 3795 +++++++++++++++++ .../txt/userguide/stress/tu/run_1/tu_13 | 3795 +++++++++++++++++ .../txt/userguide/stress/tu/run_1/tu_14 | 3795 +++++++++++++++++ .../txt/userguide/stress/tu/run_1/tu_15 | 3795 +++++++++++++++++ .../txt/userguide/stress/tu/run_1/tu_2 | 3803 +++++++++++++++++ .../txt/userguide/stress/tu/run_1/tu_3 | 3807 +++++++++++++++++ .../txt/userguide/stress/tu/run_1/tu_4 | 3805 +++++++++++++++++ .../txt/userguide/stress/tu/run_1/tu_5 | 3803 +++++++++++++++++ .../txt/userguide/stress/tu/run_1/tu_6 | 3803 +++++++++++++++++ .../txt/userguide/stress/tu/run_1/tu_7 | 3804 +++++++++++++++++ .../txt/userguide/stress/tu/run_1/tu_8 | 3803 +++++++++++++++++ .../txt/userguide/stress/tu/run_1/tu_9 | 3795 +++++++++++++++++ .../txt/userguide/stress/tu/run_2/tu_1 | 3880 ++++++++++++++++++ .../txt/userguide/stress/tu/run_2/tu_10 | 3803 +++++++++++++++++ .../txt/userguide/stress/tu/run_2/tu_11 | 3795 +++++++++++++++++ .../txt/userguide/stress/tu/run_2/tu_12 | 3795 +++++++++++++++++ .../txt/userguide/stress/tu/run_2/tu_13 | 3795 +++++++++++++++++ .../txt/userguide/stress/tu/run_2/tu_14 | 3795 +++++++++++++++++ .../txt/userguide/stress/tu/run_2/tu_15 | 3802 +++++++++++++++++ .../txt/userguide/stress/tu/run_2/tu_2 | 3803 +++++++++++++++++ .../txt/userguide/stress/tu/run_2/tu_3 | 3807 +++++++++++++++++ .../txt/userguide/stress/tu/run_2/tu_4 | 3807 +++++++++++++++++ .../txt/userguide/stress/tu/run_2/tu_5 | 3803 +++++++++++++++++ .../txt/userguide/stress/tu/run_2/tu_6 | 3804 +++++++++++++++++ .../txt/userguide/stress/tu/run_2/tu_7 | 3804 +++++++++++++++++ .../txt/userguide/stress/tu/run_2/tu_8 | 3803 +++++++++++++++++ .../txt/userguide/stress/tu/run_2/tu_9 | 3795 +++++++++++++++++ .../txt/userguide/stress/tu/run_3/tu_1 | 3879 +++++++++++++++++ .../txt/userguide/stress/tu/run_3/tu_10 | 3803 +++++++++++++++++ .../txt/userguide/stress/tu/run_3/tu_11 | 3802 +++++++++++++++++ .../txt/userguide/stress/tu/run_3/tu_12 | 3795 +++++++++++++++++ .../txt/userguide/stress/tu/run_3/tu_13 | 3802 +++++++++++++++++ .../txt/userguide/stress/tu/run_3/tu_14 | 3802 +++++++++++++++++ .../txt/userguide/stress/tu/run_3/tu_15 | 3795 +++++++++++++++++ .../txt/userguide/stress/tu/run_3/tu_2 | 3803 +++++++++++++++++ .../txt/userguide/stress/tu/run_3/tu_3 | 3808 +++++++++++++++++ .../txt/userguide/stress/tu/run_3/tu_4 | 3805 +++++++++++++++++ .../txt/userguide/stress/tu/run_3/tu_5 | 3803 +++++++++++++++++ .../txt/userguide/stress/tu/run_3/tu_6 | 3804 +++++++++++++++++ .../txt/userguide/stress/tu/run_3/tu_7 | 3803 +++++++++++++++++ .../txt/userguide/stress/tu/run_3/tu_8 | 3803 +++++++++++++++++ .../txt/userguide/stress/tu/run_3/tu_9 | 3802 +++++++++++++++++ commons-rng-core/src/site/site.xml | 50 + commons-rng-core/src/site/xdoc/developers.xml | 277 ++ commons-rng-core/src/site/xdoc/download_rng.xml | 69 + commons-rng-core/src/site/xdoc/index.xml | 82 + .../src/site/xdoc/issue-tracking.xml | 102 + commons-rng-core/src/site/xdoc/mail-lists.xml | 205 + .../src/site/xdoc/userguide/index.xml | 57 + .../src/site/xdoc/userguide/xdoc.xsl | 68 + .../commons/rng/AbstractTestPerformance.java | 59 + .../commons/rng/GenerationTestPerformance.java | 115 + .../commons/rng/Providers32ParametricTest.java | 62 + .../commons/rng/Providers64ParametricTest.java | 62 + .../rng/ProvidersCommonParametricTest.java | 761 ++++ .../org/apache/commons/rng/ProvidersList.java | 159 + .../org/apache/commons/rng/RandomAssert.java | 92 + .../apache/commons/rng/RandomSourceTest.java | 69 + .../commons/rng/internal/BaseProviderTest.java | 57 + .../rng/internal/source32/ISAACRandomTest.java | 375 ++ .../rng/internal/source32/JDKRandomTest.java | 38 + .../rng/internal/source32/KISSRandomTest.java | 165 + .../internal/source32/MersenneTwisterTest.java | 162 + .../source32/MultiplyWithCarry256Test.java | 195 + .../rng/internal/source32/Well1024aTest.java | 69 + .../rng/internal/source32/Well19937aTest.java | 171 + .../rng/internal/source32/Well19937cTest.java | 171 + .../rng/internal/source32/Well44497aTest.java | 299 ++ .../rng/internal/source32/Well44497bTest.java | 299 ++ .../rng/internal/source32/Well512aTest.java | 67 + .../source64/MersenneTwister64Test.java | 287 ++ .../rng/internal/source64/SplitMix64Test.java | 40 + .../rng/internal/source64/TwoCmresTest.java | 85 + .../internal/source64/XorShift1024StarTest.java | 51 + .../internal/util/ByteArray2IntArrayTest.java | 43 + .../internal/util/ByteArray2LongArrayTest.java | 43 + .../internal/util/IntArray2LongArrayTest.java | 39 + .../rng/internal/util/NumberFactoryTest.java | 162 + .../rng/internal/util/SeedFactoryTest.java | 147 + commons-rng-core/src/userguide/README.txt | 22 + .../src/userguide/c/rng/stdin2testu01.c | 127 + .../apache/commons/rng/userguide/ComputePi.java | 87 + .../commons/rng/userguide/GeneratorsList.java | 59 + .../rng/userguide/MonteCarloIntegration.java | 90 + .../rng/userguide/RandomStressTester.java | 280 ++ commons-rng-core/src/userguide/pom.xml | 101 + pom.xml | 96 +- src/assembly/bin.xml | 48 - src/assembly/src.xml | 41 - src/changes/changes.xml | 64 - src/changes/release-notes.vm | 140 - .../apache/commons/rng/RandomProviderState.java | 25 - .../org/apache/commons/rng/RandomSource.java | 539 --- .../rng/RestorableUniformRandomProvider.java | 49 - .../commons/rng/UniformRandomProvider.java | 116 - .../commons/rng/internal/BaseProvider.java | 153 - .../commons/rng/internal/ProviderBuilder.java | 381 -- .../commons/rng/internal/package-info.java | 52 - .../rng/internal/source32/AbstractWell.java | 201 - .../rng/internal/source32/ISAACRandom.java | 267 -- .../rng/internal/source32/IntProvider.java | 130 - .../rng/internal/source32/JDKRandom.java | 98 - .../rng/internal/source32/KISSRandom.java | 121 - .../rng/internal/source32/MersenneTwister.java | 244 -- .../internal/source32/MultiplyWithCarry256.java | 124 - .../rng/internal/source32/RandomIntSource.java | 30 - .../rng/internal/source32/Well1024a.java | 78 - .../rng/internal/source32/Well19937a.java | 80 - .../rng/internal/source32/Well19937c.java | 56 - .../rng/internal/source32/Well44497a.java | 83 - .../rng/internal/source32/Well44497b.java | 56 - .../commons/rng/internal/source32/Well512a.java | 78 - .../rng/internal/source32/package-info.java | 52 - .../rng/internal/source64/LongProvider.java | 134 - .../internal/source64/MersenneTwister64.java | 202 - .../rng/internal/source64/RandomLongSource.java | 30 - .../rng/internal/source64/SplitMix64.java | 75 - .../commons/rng/internal/source64/TwoCmres.java | 307 -- .../rng/internal/source64/XorShift1024Star.java | 94 - .../rng/internal/source64/package-info.java | 52 - .../rng/internal/util/ByteArray2IntArray.java | 39 - .../rng/internal/util/ByteArray2LongArray.java | 39 - .../commons/rng/internal/util/Int2Long.java | 31 - .../commons/rng/internal/util/IntArray2Int.java | 35 - .../rng/internal/util/IntArray2LongArray.java | 38 - .../commons/rng/internal/util/Long2Int.java | 30 - .../rng/internal/util/Long2IntArray.java | 44 - .../rng/internal/util/Long2LongArray.java | 50 - .../rng/internal/util/LongArray2IntArray.java | 37 - .../rng/internal/util/LongArray2Long.java | 35 - .../rng/internal/util/NoOpConverter.java | 34 - .../rng/internal/util/NumberFactory.java | 332 -- .../rng/internal/util/SeedConverter.java | 35 - .../internal/util/SeedConverterComposer.java | 50 - .../commons/rng/internal/util/SeedFactory.java | 357 -- .../commons/rng/internal/util/package-info.java | 22 - .../org/apache/commons/rng/package-info.java | 95 - src/site/apt/userguide/rng.apt | 510 --- src/site/resources/images/commons_rng.small.png | Bin 89955 -> 0 bytes src/site/resources/profile.jacoco | 17 - src/site/resources/style/project.css | 18 - .../txt/userguide/stress/dh/run_1/dh_1 | 154 - .../txt/userguide/stress/dh/run_1/dh_10 | 178 - .../txt/userguide/stress/dh/run_1/dh_11 | 140 - .../txt/userguide/stress/dh/run_1/dh_12 | 172 - .../txt/userguide/stress/dh/run_1/dh_13 | 138 - .../txt/userguide/stress/dh/run_1/dh_14 | 140 - .../txt/userguide/stress/dh/run_1/dh_15 | 161 - .../txt/userguide/stress/dh/run_1/dh_2 | 172 - .../txt/userguide/stress/dh/run_1/dh_3 | 203 - .../txt/userguide/stress/dh/run_1/dh_4 | 229 -- .../txt/userguide/stress/dh/run_1/dh_5 | 168 - .../txt/userguide/stress/dh/run_1/dh_6 | 141 - .../txt/userguide/stress/dh/run_1/dh_7 | 170 - .../txt/userguide/stress/dh/run_1/dh_8 | 168 - .../txt/userguide/stress/dh/run_1/dh_9 | 140 - .../txt/userguide/stress/dh/run_2/dh_1 | 151 - .../txt/userguide/stress/dh/run_2/dh_10 | 138 - .../txt/userguide/stress/dh/run_2/dh_11 | 139 - .../txt/userguide/stress/dh/run_2/dh_12 | 171 - .../txt/userguide/stress/dh/run_2/dh_13 | 139 - .../txt/userguide/stress/dh/run_2/dh_14 | 168 - .../txt/userguide/stress/dh/run_2/dh_15 | 143 - .../txt/userguide/stress/dh/run_2/dh_2 | 141 - .../txt/userguide/stress/dh/run_2/dh_3 | 180 - .../txt/userguide/stress/dh/run_2/dh_4 | 151 - .../txt/userguide/stress/dh/run_2/dh_5 | 142 - .../txt/userguide/stress/dh/run_2/dh_6 | 258 -- .../txt/userguide/stress/dh/run_2/dh_7 | 175 - .../txt/userguide/stress/dh/run_2/dh_8 | 139 - .../txt/userguide/stress/dh/run_2/dh_9 | 169 - .../txt/userguide/stress/dh/run_3/dh_1 | 150 - .../txt/userguide/stress/dh/run_3/dh_10 | 169 - .../txt/userguide/stress/dh/run_3/dh_11 | 140 - .../txt/userguide/stress/dh/run_3/dh_12 | 138 - .../txt/userguide/stress/dh/run_3/dh_13 | 291 -- .../txt/userguide/stress/dh/run_3/dh_14 | 140 - .../txt/userguide/stress/dh/run_3/dh_15 | 139 - .../txt/userguide/stress/dh/run_3/dh_2 | 141 - .../txt/userguide/stress/dh/run_3/dh_3 | 140 - .../txt/userguide/stress/dh/run_3/dh_4 | 200 - .../txt/userguide/stress/dh/run_3/dh_5 | 139 - .../txt/userguide/stress/dh/run_3/dh_6 | 139 - .../txt/userguide/stress/dh/run_3/dh_7 | 139 - .../txt/userguide/stress/dh/run_3/dh_8 | 170 - .../txt/userguide/stress/dh/run_3/dh_9 | 143 - .../txt/userguide/stress/tu/run_1/tu_1 | 3879 ----------------- .../txt/userguide/stress/tu/run_1/tu_10 | 3803 ----------------- .../txt/userguide/stress/tu/run_1/tu_11 | 3803 ----------------- .../txt/userguide/stress/tu/run_1/tu_12 | 3795 ----------------- .../txt/userguide/stress/tu/run_1/tu_13 | 3795 ----------------- .../txt/userguide/stress/tu/run_1/tu_14 | 3795 ----------------- .../txt/userguide/stress/tu/run_1/tu_15 | 3795 ----------------- .../txt/userguide/stress/tu/run_1/tu_2 | 3803 ----------------- .../txt/userguide/stress/tu/run_1/tu_3 | 3807 ----------------- .../txt/userguide/stress/tu/run_1/tu_4 | 3805 ----------------- .../txt/userguide/stress/tu/run_1/tu_5 | 3803 ----------------- .../txt/userguide/stress/tu/run_1/tu_6 | 3803 ----------------- .../txt/userguide/stress/tu/run_1/tu_7 | 3804 ----------------- .../txt/userguide/stress/tu/run_1/tu_8 | 3803 ----------------- .../txt/userguide/stress/tu/run_1/tu_9 | 3795 ----------------- .../txt/userguide/stress/tu/run_2/tu_1 | 3880 ------------------ .../txt/userguide/stress/tu/run_2/tu_10 | 3803 ----------------- .../txt/userguide/stress/tu/run_2/tu_11 | 3795 ----------------- .../txt/userguide/stress/tu/run_2/tu_12 | 3795 ----------------- .../txt/userguide/stress/tu/run_2/tu_13 | 3795 ----------------- .../txt/userguide/stress/tu/run_2/tu_14 | 3795 ----------------- .../txt/userguide/stress/tu/run_2/tu_15 | 3802 ----------------- .../txt/userguide/stress/tu/run_2/tu_2 | 3803 ----------------- .../txt/userguide/stress/tu/run_2/tu_3 | 3807 ----------------- .../txt/userguide/stress/tu/run_2/tu_4 | 3807 ----------------- .../txt/userguide/stress/tu/run_2/tu_5 | 3803 ----------------- .../txt/userguide/stress/tu/run_2/tu_6 | 3804 ----------------- .../txt/userguide/stress/tu/run_2/tu_7 | 3804 ----------------- .../txt/userguide/stress/tu/run_2/tu_8 | 3803 ----------------- .../txt/userguide/stress/tu/run_2/tu_9 | 3795 ----------------- .../txt/userguide/stress/tu/run_3/tu_1 | 3879 ----------------- .../txt/userguide/stress/tu/run_3/tu_10 | 3803 ----------------- .../txt/userguide/stress/tu/run_3/tu_11 | 3802 ----------------- .../txt/userguide/stress/tu/run_3/tu_12 | 3795 ----------------- .../txt/userguide/stress/tu/run_3/tu_13 | 3802 ----------------- .../txt/userguide/stress/tu/run_3/tu_14 | 3802 ----------------- .../txt/userguide/stress/tu/run_3/tu_15 | 3795 ----------------- .../txt/userguide/stress/tu/run_3/tu_2 | 3803 ----------------- .../txt/userguide/stress/tu/run_3/tu_3 | 3808 ----------------- .../txt/userguide/stress/tu/run_3/tu_4 | 3805 ----------------- .../txt/userguide/stress/tu/run_3/tu_5 | 3803 ----------------- .../txt/userguide/stress/tu/run_3/tu_6 | 3804 ----------------- .../txt/userguide/stress/tu/run_3/tu_7 | 3803 ----------------- .../txt/userguide/stress/tu/run_3/tu_8 | 3803 ----------------- .../txt/userguide/stress/tu/run_3/tu_9 | 3802 ----------------- src/site/site.xml | 50 - src/site/xdoc/developers.xml | 277 -- src/site/xdoc/download_rng.xml | 69 - src/site/xdoc/index.xml | 82 - src/site/xdoc/issue-tracking.xml | 102 - src/site/xdoc/mail-lists.xml | 205 - src/site/xdoc/userguide/index.xml | 57 - src/site/xdoc/userguide/xdoc.xsl | 68 - .../commons/rng/AbstractTestPerformance.java | 59 - .../commons/rng/GenerationTestPerformance.java | 115 - .../commons/rng/Providers32ParametricTest.java | 62 - .../commons/rng/Providers64ParametricTest.java | 62 - .../rng/ProvidersCommonParametricTest.java | 761 ---- .../org/apache/commons/rng/ProvidersList.java | 159 - .../org/apache/commons/rng/RandomAssert.java | 92 - .../apache/commons/rng/RandomSourceTest.java | 69 - .../commons/rng/internal/BaseProviderTest.java | 57 - .../rng/internal/source32/ISAACRandomTest.java | 375 -- .../rng/internal/source32/JDKRandomTest.java | 38 - .../rng/internal/source32/KISSRandomTest.java | 165 - .../internal/source32/MersenneTwisterTest.java | 162 - .../source32/MultiplyWithCarry256Test.java | 195 - .../rng/internal/source32/Well1024aTest.java | 69 - .../rng/internal/source32/Well19937aTest.java | 171 - .../rng/internal/source32/Well19937cTest.java | 171 - .../rng/internal/source32/Well44497aTest.java | 299 -- .../rng/internal/source32/Well44497bTest.java | 299 -- .../rng/internal/source32/Well512aTest.java | 67 - .../source64/MersenneTwister64Test.java | 287 -- .../rng/internal/source64/SplitMix64Test.java | 40 - .../rng/internal/source64/TwoCmresTest.java | 85 - .../internal/source64/XorShift1024StarTest.java | 51 - .../internal/util/ByteArray2IntArrayTest.java | 43 - .../internal/util/ByteArray2LongArrayTest.java | 43 - .../internal/util/IntArray2LongArrayTest.java | 39 - .../rng/internal/util/NumberFactoryTest.java | 162 - .../rng/internal/util/SeedFactoryTest.java | 147 - src/userguide/README.txt | 22 - src/userguide/c/rng/stdin2testu01.c | 127 - .../apache/commons/rng/userguide/ComputePi.java | 87 - .../commons/rng/userguide/GeneratorsList.java | 59 - .../rng/userguide/MonteCarloIntegration.java | 90 - .../rng/userguide/RandomStressTester.java | 280 -- src/userguide/pom.xml | 101 - 381 files changed, 190770 insertions(+), 190687 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/commons-rng/blob/42530e25/commons-rng-core/clirr-ignored.xml ---------------------------------------------------------------------- diff --git a/commons-rng-core/clirr-ignored.xml b/commons-rng-core/clirr-ignored.xml new file mode 100644 index 0000000..ed97259 --- /dev/null +++ b/commons-rng-core/clirr-ignored.xml @@ -0,0 +1,21 @@ +<?xml version="1.0"?> +<!-- + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> + +<differences> + +</differences> http://git-wip-us.apache.org/repos/asf/commons-rng/blob/42530e25/commons-rng-core/findbugs-exclude-filter.xml ---------------------------------------------------------------------- diff --git a/commons-rng-core/findbugs-exclude-filter.xml b/commons-rng-core/findbugs-exclude-filter.xml new file mode 100644 index 0000000..99b2e8a --- /dev/null +++ b/commons-rng-core/findbugs-exclude-filter.xml @@ -0,0 +1,27 @@ +<?xml version="1.0"?> +<!-- + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> + +<!-- + This file contains some false positive bugs detected by findbugs. Their + false positive nature has been analyzed individually and they have been + put here to instruct findbugs it must ignore them. +--> +<FindBugsFilter> + + +</FindBugsFilter> http://git-wip-us.apache.org/repos/asf/commons-rng/blob/42530e25/commons-rng-core/pmd-ruleset.xml ---------------------------------------------------------------------- diff --git a/commons-rng-core/pmd-ruleset.xml b/commons-rng-core/pmd-ruleset.xml new file mode 100644 index 0000000..c637ef7 --- /dev/null +++ b/commons-rng-core/pmd-ruleset.xml @@ -0,0 +1,57 @@ +<?xml version="1.0"?> +<!-- + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> +<ruleset name="commons-rng-customized" + xmlns="http://pmd.sourceforge.net/ruleset/2.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://pmd.sourceforge.net/ruleset/2.0.0 http://pmd.sourceforge.net/ruleset_2_0_0.xsd"> + <description> + This ruleset checks the code for discouraged programming constructs. + </description> + + <rule ref="rulesets/java/basic.xml"/> + + <rule ref="rulesets/java/braces.xml"/> + + <rule ref="rulesets/java/comments.xml"> + <exclude name="CommentSize"/> + </rule> + <rule ref="rulesets/java/comments.xml/CommentSize"> + <properties> + <property name="maxLines" value="200"/> + <property name="maxLineLength" value="256"/> + </properties> + </rule> + + <rule ref="rulesets/java/empty.xml"/> + + <rule ref="rulesets/java/finalizers.xml"/> + + <rule ref="rulesets/java/imports.xml"/> + + <rule ref="rulesets/java/typeresolution.xml"/> + + <rule ref="rulesets/java/clone.xml"/> + + <rule ref="rulesets/java/unnecessary.xml"> + <!-- We do use extra parentheses there as most people do not recall operator precedence, + this means even if the parentheses are useless for the compiler, we don't consider + them useless for the developer. This is the reason why we disable this rule. --> + <exclude name="UselessParentheses"/> + </rule> + +</ruleset> http://git-wip-us.apache.org/repos/asf/commons-rng/blob/42530e25/commons-rng-core/pom.xml ---------------------------------------------------------------------- diff --git a/commons-rng-core/pom.xml b/commons-rng-core/pom.xml new file mode 100644 index 0000000..f3f3dfd --- /dev/null +++ b/commons-rng-core/pom.xml @@ -0,0 +1,32 @@ +<?xml version="1.0"?> +<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" + xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> + <modelVersion>4.0.0</modelVersion> + + <parent> + <groupId>org.apache.commons</groupId> + <artifactId>commons-rng</artifactId> + <version>1.0-SNAPSHOT</version> + </parent> + + <groupId>org.apache.commons</groupId> + <artifactId>commons-rng-core</artifactId> + <version>1.0-SNAPSHOT</version> + <name>Apache Commons RNG Core</name> + <url>http://maven.apache.org</url> + + <properties> + <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> + </properties> + + <inceptionYear>2016</inceptionYear> + <description>The Apache Commons RNG Core module includes implementations of random numbers generators.</description> + + <scm> + <connection>scm:git:http://git-wip-us.apache.org/repos/asf/commons-rng.git</connection> + <developerConnection>scm:git:https://git-wip-us.apache.org/repos/asf/commons-rng.git</developerConnection> + <url>https://git-wip-us.apache.org/repos/asf?p=commons-rng.git</url> + </scm> + +</project> http://git-wip-us.apache.org/repos/asf/commons-rng/blob/42530e25/commons-rng-core/src/assembly/bin.xml ---------------------------------------------------------------------- diff --git a/commons-rng-core/src/assembly/bin.xml b/commons-rng-core/src/assembly/bin.xml new file mode 100644 index 0000000..a5ff153 --- /dev/null +++ b/commons-rng-core/src/assembly/bin.xml @@ -0,0 +1,48 @@ +<?xml version="1.0"?> +<!-- + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> + +<assembly> + <id>bin</id> + <formats> + <format>tar.gz</format> + <format>zip</format> + </formats> + <includeSiteDirectory>false</includeSiteDirectory> + <fileSets> + <fileSet> + <includes> + <include>LICENSE*</include> + <include>NOTICE*</include> + <include>RELEASE-NOTES.txt</include> + </includes> + </fileSet> + <fileSet> + <directory>target</directory> + <outputDirectory></outputDirectory> + <includes> + <include>*.jar</include> + </includes> + </fileSet> + <fileSet> + <directory>target/site</directory> + <outputDirectory>docs</outputDirectory> + <excludes> + </excludes> + </fileSet> + </fileSets> +</assembly> http://git-wip-us.apache.org/repos/asf/commons-rng/blob/42530e25/commons-rng-core/src/assembly/src.xml ---------------------------------------------------------------------- diff --git a/commons-rng-core/src/assembly/src.xml b/commons-rng-core/src/assembly/src.xml new file mode 100644 index 0000000..a78f24f --- /dev/null +++ b/commons-rng-core/src/assembly/src.xml @@ -0,0 +1,41 @@ +<?xml version="1.0"?> +<!-- + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> +<assembly> + <id>src</id> + <formats> + <format>tar.gz</format> + <format>zip</format> + </formats> + <baseDirectory> + ${project.artifactId}-${commons.release.version}-src + </baseDirectory> + <fileSets> + <fileSet> + <includes> + <include>*.txt</include> + <include>*.xml</include> + </includes> + </fileSet> + <fileSet> + <directory>src</directory> + <excludes> + </excludes> + </fileSet> + </fileSets> +</assembly> + http://git-wip-us.apache.org/repos/asf/commons-rng/blob/42530e25/commons-rng-core/src/changes/changes.xml ---------------------------------------------------------------------- diff --git a/commons-rng-core/src/changes/changes.xml b/commons-rng-core/src/changes/changes.xml new file mode 100644 index 0000000..5a3c372 --- /dev/null +++ b/commons-rng-core/src/changes/changes.xml @@ -0,0 +1,64 @@ +<?xml version="1.0"?> +<!-- + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> + +<!-- +This file is used by the maven-changes-plugin to generate the release notes. +Useful ways of finding items to add to this file are: + +1. Add items when you fix a bug or add a feature (this makes the +release process easy :-). + +2. Do a JIRA search for tickets closed since the previous release. + +3. Use the report generated by the maven-changelog-plugin to see all +SVN commits. + +To generate the file RELEASE-NOTES.txt from this file: + +mvn changes:announcement-generate -Prelease-notes [-Dchanges.version] + +The <action> type attribute can be add,update,fix,remove. +--> + +<!-- NOTE: +The description attribute entries below are specially formatted +so as to improve the layout of the generated text release notes. + +The parsing process removes all line feeds, replacing them with a single space. +The Velocity template in src/changes/release-notes.vm has been enhanced to replace pairs of adjacent spaces +with a new-line in the release notes. (These spaces are ignored when displaying HTML). +If the output is not quite correct, check for invisible trailing spaces! +--> + +<document> + <properties> + <title>Apache Commons RNG Release Notes</title> + </properties> + <body> + <release version="1.0" date="TBD" description=" +This is the first release of Apache Commons RNG. + +The minimum version of the Java platform required to compile and use + Apache Commons RNG 1.0 is Java 6. +"> + <!-- <action dev="erans" type="fix" issue="RNG-xxx"> --> + <!-- </action> --> + </release> + + </body> +</document> http://git-wip-us.apache.org/repos/asf/commons-rng/blob/42530e25/commons-rng-core/src/changes/release-notes.vm ---------------------------------------------------------------------- diff --git a/commons-rng-core/src/changes/release-notes.vm b/commons-rng-core/src/changes/release-notes.vm new file mode 100644 index 0000000..cc1b18c --- /dev/null +++ b/commons-rng-core/src/changes/release-notes.vm @@ -0,0 +1,140 @@ +## Licensed to the Apache Software Foundation (ASF) under one +## or more contributor license agreements. See the NOTICE file +## distributed with this work for additional information +## regarding copyright ownership. The ASF licenses this file +## to you under the Apache License, Version 2.0 (the +## "License"); you may not use this file except in compliance +## with the License. You may obtain a copy of the License at +## +## http://www.apache.org/licenses/LICENSE-2.0 +## +## Unless required by applicable law or agreed to in writing, +## software distributed under the License is distributed on an +## "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +## KIND, either express or implied. See the License for the +## specific language governing permissions and limitations +## under the License. + + ${project.name} ${version} RELEASE NOTES + +The ${developmentTeam} is pleased to announce the release of ${finalName} + +$introduction.replaceAll("(?<!\015)\012", " +") + +## N.B. the available variables are described here: +## http://maven.apache.org/plugins/maven-changes-plugin/examples/using-a-custom-announcement-template.html +## +## Hack to improve layout: replace all pairs of spaces with a single new-line +$release.description.replaceAll(" ", " +") + +#if ($release.getActions().size() == 0) +No changes defined in this version. +#else +Changes in this version include: + +## indent to be used if there is no issue attribute. +## should be the same as the indent in the changes.xml file +## less 2 spaces for the 'o' and trailing space +#set($indent=' ') +#if ($release.getActions('add').size() !=0) +New features: +#foreach($actionItem in $release.getActions('add')) +## Use replaceAll to fix up LF-only line ends on Windows. +#set($action=$actionItem.getAction().replaceAll("\n"," +")) +#if ($actionItem.getIssue()) +#set($issue=$actionItem.getIssue()) +#else +#set($issue="") +#end +#if ($actionItem.getDueTo()) +#set($dueto=$actionItem.getDueTo()) +#else +#set($dueto="") +#end +o#if($!issue != "") $issue: #else$indent#end ${action} #if($!dueto != "")Thanks to $dueto. #end + +#set($issue="") +#set($dueto="") +#end +#end + +#if ($release.getActions('fix').size() !=0) +Fixed Bugs: +#foreach($actionItem in $release.getActions('fix')) +## Use replaceAll to fix up LF-only line ends on Windows. +#set($action=$actionItem.getAction().replaceAll("\n"," +")) +#if ($actionItem.getIssue()) +#set($issue=$actionItem.getIssue()) +#else +#set($issue="") +#end +#if ($actionItem.getDueTo()) +#set($dueto=$actionItem.getDueTo()) +#else +#set($dueto="") +#end +o#if($!issue != "") $issue: #else$indent#end ${action} #if($!dueto != "")Thanks to $dueto. #end + +#set($issue="") +#set($dueto="") +#end +#end + +#if ($release.getActions('update').size() !=0) +Changes: +#foreach($actionItem in $release.getActions('update')) +## Use replaceAll to fix up LF-only line ends on Windows. +#set($action=$actionItem.getAction().replaceAll("\n"," +")) +#if ($actionItem.getIssue()) +#set($issue=$actionItem.getIssue()) +#else +#set($issue="") +#end +#if ($actionItem.getDueTo()) +#set($dueto=$actionItem.getDueTo()) +#else +#set($dueto="") +#end +o#if($!issue != "") $issue: #else$indent#end ${action} #if($!dueto != "")Thanks to $dueto. #end + +#set($issue="") +#set($dueto="") +#end +#end + +#if ($release.getActions('remove').size() !=0) +Removed: +#foreach($actionItem in $release.getActions('remove')) +## Use replaceAll to fix up LF-only line ends on Windows. +#set($action=$actionItem.getAction().replaceAll("\n"," +")) +#if ($actionItem.getIssue()) +#set($issue=$actionItem.getIssue()) +#else +#set($issue="") +#end +#if ($actionItem.getDueTo()) +#set($dueto=$actionItem.getDueTo()) +#else +#set($dueto="") +#end +o#if($!issue != "") $issue: #else$indent#end ${action} #if($!dueto != "")Thanks to $dueto. #end + +#set($issue="") +#set($dueto="") +#end +#end +## End of main loop +#end + +For complete information on ${project.name}, including instructions on how to submit bug reports, +patches, or suggestions for improvement, see the ${project.name} website: + +${project.url} + + http://git-wip-us.apache.org/repos/asf/commons-rng/blob/42530e25/commons-rng-core/src/main/java/org/apache/commons/rng/RandomProviderState.java ---------------------------------------------------------------------- diff --git a/commons-rng-core/src/main/java/org/apache/commons/rng/RandomProviderState.java b/commons-rng-core/src/main/java/org/apache/commons/rng/RandomProviderState.java new file mode 100644 index 0000000..f4af719 --- /dev/null +++ b/commons-rng-core/src/main/java/org/apache/commons/rng/RandomProviderState.java @@ -0,0 +1,25 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.commons.rng; + +/** + * Marker interface for objects that represents the state of a random + * generator. + * + * @since 1.0 + */ +public interface RandomProviderState {} http://git-wip-us.apache.org/repos/asf/commons-rng/blob/42530e25/commons-rng-core/src/main/java/org/apache/commons/rng/RandomSource.java ---------------------------------------------------------------------- diff --git a/commons-rng-core/src/main/java/org/apache/commons/rng/RandomSource.java b/commons-rng-core/src/main/java/org/apache/commons/rng/RandomSource.java new file mode 100644 index 0000000..bab6224 --- /dev/null +++ b/commons-rng-core/src/main/java/org/apache/commons/rng/RandomSource.java @@ -0,0 +1,539 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.commons.rng; + +import java.util.Arrays; + +import org.apache.commons.rng.internal.ProviderBuilder; +import org.apache.commons.rng.internal.util.SeedFactory; + +/** + * This class provides the API for creating generators of random numbers. + * + * <p>Usage examples:</p> + * <pre><code> + * UniformRandomProvider rng = RandomSource.create(RandomSource.MT); + * </code></pre> + * or + * <pre><code> + * final int[] seed = new int[] { 196, 9, 0, 226 }; + * UniformRandomProvider rng = RandomSource.create(RandomSource.MT, seed); + * </code></pre> + * or + * <pre><code> + * final int[] seed = RandomSource.createIntArray(256); + * UniformRandomProvider rng = RandomSource.create(RandomSource.MT, seed); + * </code></pre> + * where the first argument to method {@code create} is the identifier + * of the generator's concrete implementation, and the second the is the + * (optional) seed. + * + * <p> + * In the first form, a random seed will be {@link SeedFactory generated + * automatically}; in the second form, a fixed seed is used; a random seed + * is explicitly generated in the third form. + * </p> + * + * <p> + * Seeding is the procedure by which a value (or set of values) is + * used to <i>initialize</i> a generator instance. + * The requirement that a given seed will always result in the same + * internal state allows to create different instances of a generator + * that will produce the same sequence of pseudo-random numbers. + * </p> + * + * <p> + * The type of data used as a seed depends on the concrete implementation + * as some types may not provide enough information to fully initialize + * the generator's internal state. + * <br> + * The reference algorithm's seeding procedure (if provided) operates + * on a value of a (single) <i>native</i> type: + * Each concrete implementation's constructor creates an instance using + * the native type whose information contents is used to set the + * internal state. + * <br> + * When the seed value passed by the caller is of the native type, it is + * expected that the sequences produced will be identical to those + * produced by other implementations of the same reference algorithm. + * <br> + * However, when the seed value passed by the caller is not of the native + * type, a transformation is performed by this library and the resulting + * native type value will <i>not</i> contain more information than the + * original seed value. + * If the algorithm's native type is "simpler" than the type passed by + * the caller, then some (unused) information will even be lost. + * <br> + * The transformation from non-native to native seed type is arbitrary, + * as long as it does not reduce the amount of information required by + * the algorithm to initialize its state. + * The consequence of the transformation is that sequences produced + * by this library may <i>not</i> be the same as the sequences produced + * by other implementations of the same algorithm! + * </p> + * + * <p> + * For each algorithm, the Javadoc mentions the "ideal" size of the seed, + * meaning the number of {@code int} or {@code long} values that is neither + * too large (i.e. some of the seed is useless) or too small (i.e. an + * internal procedure will fill the state with redundant information + * computed from the given seed). + * </p> + * + * <p> + * Note that some algorithms are inherently sensitive to having too low + * diversity in their initial state. + * For example, it is often a bad idea to use a seed that is mostly + * composed of zeroes, or of repeated values. + * </p> + * + * <p> + * This class provides methods to generate random seeds (single values + * or arrays of values, of {@code int} or {@code long} types) that can + * be passed to the {@link RandomSource#create(RandomSource,Object,Object[]) + * generators factory method}. + * </p> + * <p> + * Although the seed-generating methods defined in this class will likely + * return different values each time they are called, there is no guarantee: + * </p> + * <ul> + * <li> + * In any sub-sequence, it is <a href="https://en.wikipedia.org/wiki/Birthday_problem"> + * expected</a> that the same numbers can occur, with a probability getting + * higher as the range of allowed values is smaller and the sequence becomes + * longer. + * </li> + * <li> + * It possible that the resulting "seed" will not be <i>good</i> (i.e. + * it will not generate a sufficiently uniformly random sequence for the + * intended purpose), even if the generator is good! + * The only way to ensure that the selected seed will make the generator + * produce a good sequence is to submit that sequence to a series of + * stringent tests, as provided by tools such as + * <a href="http://www.phy.duke.edu/~rgb/General/dieharder.php">dieharder</a> + * or <a href="http://simul.iro.umontreal.ca/testu01/tu01.html">TestU01</a>. + * </li> + * </ul> + * + * <p> + * The current implementations have no provision for producing non-overlapping + * sequences. + * For parallel applications, a possible workaround is that each thread uses + * a generator of a different type (see {@link #TWO_CMRES_SELECT}). + * </p> + * + * <p> + * <b>Note:</b> + * Seeding is not equivalent to restoring the internal state of an + * <i>already initialized</i> generator. + * Indeed, generators can have a state that is more complex than the + * seed, and seeding is thus a transformation (from seed to state). + * Implementations do not provide the inverse transformation (from + * state to seed), hence it is not generally possible to know the seed + * that would initialize a new generator instance to the current state + * of another instance. + * Reseeding is also inefficient if the purpose is to continue the + * same sequence where another instance left off, as it would require + * to "replay" all the calls performed by that other instance (and it + * would require to know the number of calls to the primary source of + * randomness, which is also not usually accessible). + * </p> + * + * @since 1.0 + */ +public enum RandomSource { + /** + * Source of randomness is {@link org.apache.commons.rng.internal.source32.JDKRandom}. + * <ul> + * <li>Native seed type: {@code Long}.</li> + * <li>Native seed size: 1.</li> + * </ul> + */ + JDK(ProviderBuilder.RandomSourceInternal.JDK), + /** + * Source of randomness is {@link org.apache.commons.rng.internal.source32.Well512a}. + * <ul> + * <li>Native seed type: {@code int[]}.</li> + * <li>Native seed size: 16.</li> + * </ul> + */ + WELL_512_A(ProviderBuilder.RandomSourceInternal.WELL_512_A), + /** + * Source of randomness is {@link org.apache.commons.rng.internal.source32.Well1024a}. + * <ul> + * <li>Native seed type: {@code int[]}.</li> + * <li>Native seed size: 32.</li> + * </ul> + */ + WELL_1024_A(ProviderBuilder.RandomSourceInternal.WELL_1024_A), + /** + * Source of randomness is {@link org.apache.commons.rng.internal.source32.Well19937a}. + * <ul> + * <li>Native seed type: {@code int[]}.</li> + * <li>Native seed size: 624.</li> + * </ul> + */ + WELL_19937_A(ProviderBuilder.RandomSourceInternal.WELL_19937_A), + /** + * Source of randomness is {@link org.apache.commons.rng.internal.source32.Well19937c}. + * <ul> + * <li>Native seed type: {@code int[]}.</li> + * <li>Native seed size: 624.</li> + * </ul> + */ + WELL_19937_C(ProviderBuilder.RandomSourceInternal.WELL_19937_C), + /** + * Source of randomness is {@link org.apache.commons.rng.internal.source32.Well44497a}. + * <ul> + * <li>Native seed type: {@code int[]}.</li> + * <li>Native seed size: 1391.</li> + * </ul> + */ + WELL_44497_A(ProviderBuilder.RandomSourceInternal.WELL_44497_A), + /** + * Source of randomness is {@link org.apache.commons.rng.internal.source32.Well44497b}. + * <ul> + * <li>Native seed type: {@code int[]}.</li> + * <li>Native seed size: 1391.</li> + * </ul> + */ + WELL_44497_B(ProviderBuilder.RandomSourceInternal.WELL_44497_B), + /** + * Source of randomness is {@link org.apache.commons.rng.internal.source32.MersenneTwister}. + * <ul> + * <li>Native seed type: {@code int[]}.</li> + * <li>Native seed size: 624.</li> + * </ul> + */ + MT(ProviderBuilder.RandomSourceInternal.MT), + /** + * Source of randomness is {@link org.apache.commons.rng.internal.source32.ISAACRandom}. + * <ul> + * <li>Native seed type: {@code int[]}.</li> + * <li>Native seed size: 256.</li> + * </ul> + */ + ISAAC(ProviderBuilder.RandomSourceInternal.ISAAC), + /** + * Source of randomness is {@link org.apache.commons.rng.internal.source64.SplitMix64}. + * <ul> + * <li>Native seed type: {@code Long}.</li> + * <li>Native seed size: 1.</li> + * </ul> + */ + SPLIT_MIX_64(ProviderBuilder.RandomSourceInternal.SPLIT_MIX_64), + /** + * Source of randomness is {@link org.apache.commons.rng.internal.source64.XorShift1024Star}. + * <ul> + * <li>Native seed type: {@code long[]}.</li> + * <li>Native seed size: 16.</li> + * </ul> + */ + XOR_SHIFT_1024_S(ProviderBuilder.RandomSourceInternal.XOR_SHIFT_1024_S), + /** + * Source of randomness is {@link org.apache.commons.rng.internal.source64.TwoCmres}. + * This generator is equivalent to {@link #TWO_CMRES_SELECT} with the choice of the + * pair {@code (0, 1)} for the two subcycle generators. + * <ul> + * <li>Native seed type: {@code Integer}.</li> + * <li>Native seed size: 1.</li> + * </ul> + */ + TWO_CMRES(ProviderBuilder.RandomSourceInternal.TWO_CMRES), + /** + * Source of randomness is {@link org.apache.commons.rng.internal.source64.TwoCmres}, + * with explicit selection of the two subcycle generators. + * The selection of the subcycle generator is by passing its index in the internal + * table, a value between 0 (included) and 13 (included). + * The two indices must be different. + * Different choices of an ordered pair of indices create independent generators. + * <ul> + * <li>Native seed type: {@code Integer}.</li> + * <li>Native seed size: 1.</li> + * </ul> + */ + TWO_CMRES_SELECT(ProviderBuilder.RandomSourceInternal.TWO_CMRES_SELECT), + /** + * Source of randomness is {@link org.apache.commons.rng.internal.source64.MersenneTwister64}. + * <ul> + * <li>Native seed type: {@code long[]}.</li> + * <li>Native seed size: 312.</li> + * </ul> + */ + MT_64(ProviderBuilder.RandomSourceInternal.MT_64), + /** + * Source of randomness is {@link org.apache.commons.rng.internal.source32.MultiplyWithCarry256}. + * <ul> + * <li>Native seed type: {@code int[]}.</li> + * <li>Native seed size: 257.</li> + * </ul> + */ + MWC_256(ProviderBuilder.RandomSourceInternal.MWC_256), + /** + * Source of randomness is {@link org.apache.commons.rng.internal.source32.KISSRandom}. + * <ul> + * <li>Native seed type: {@code int[]}.</li> + * <li>Native seed size: 4.</li> + * </ul> + */ + KISS(ProviderBuilder.RandomSourceInternal.KISS); + + /** Internal identifier. */ + private final ProviderBuilder.RandomSourceInternal internalIdentifier; + + /** + * Wraps the internal state of the {@link RestorableUniformRandomProvider} + * instances created by this factory. + * Its purpose is to store all the data needed to recover the same + * state in order to restart a sequence where it left off. + * External code should not try to modify the data contained in instances + * of this class. + */ + public static class State implements RandomProviderState { + /** Internal state. */ + private final byte[] state; + + /** + * Initializes an instance. + * The contents of the {@code state} argument is unspecified, and is + * guaranteed to be valid only if it was generated by implementations + * provided by this library. + * + * @param state Mapping of all the data which an implementation of + * {@link UniformRandomProvider} needs in order to reset its internal + * state. + */ + public State(byte[] state) { + this.state = Arrays.copyOf(state, state.length); + } + + /** + * @return the internal state. + */ + public byte[] getState() { + return Arrays.copyOf(state, state.length); + } + } + + /** + * @param id Internal identifier. + */ + RandomSource(ProviderBuilder.RandomSourceInternal id) { + internalIdentifier = id; + } + + /** + * @return the internal identifier. + */ + ProviderBuilder.RandomSourceInternal getInternalIdentifier() { + return internalIdentifier; + } + + /** + * Checks whether the type of given {@code seed} is the native type + * of the implementation. + * + * @param seed Seed value. + * @return {@code true} if the type of {@code seed} is the native + * type for this RNG source. + */ + public boolean isNativeSeed(Object seed) { + return internalIdentifier.isNativeSeed(seed); + } + + /** + * Creates a random number generator with a random seed. + * + * <p>Usage example:</p> + * <pre><code> + * UniformRandomProvider rng = RandomSource.create(RandomSource.MT); + * </code></pre> + * <p>or, if a {@link RestorableUniformRandomProvider "save/restore"} functionality is needed,</p> + * <pre><code> + * RestorableUniformRandomProvider rng = RandomSource.create(RandomSource.MT); + * </code></pre> + * + * @param source RNG type. + * @return the RNG. + * + * @see #create(RandomSource,Object,Object[]) + */ + public static RestorableUniformRandomProvider create(RandomSource source) { + return create(source, null); + } + + /** + * Creates a random number generator with the given {@code seed}. + * + * <p>Usage example:</p> + * <pre><code> + * UniformRandomProvider rng = RandomSource.create(RandomSource.TWO_CMRES_SELECT, 26219, 6, 9); + * </code></pre> + * + * <p>Valid types for the {@code seed} are:</p> + * <ul> + * <li>{@code Integer} (or {@code int})</li> + * <li>{@code Long} (or {@code long})</li> + * <li>{@code int[]}</li> + * <li>{@code long[]}</li> + * <li>{@code byte[]}</li> + * </ul> + * + * <p>Notes:</p> + * <ul> + * <li> + * When the seed type passed as argument is more complex (i.e. more + * bits can be independently chosen) than the generator's + * {@link #isNativeSeed(Object) native type}, the conversion of a + * set of different seeds will necessarily result in the same value + * of the native seed type. + * </li> + * <li> + * When the native seed type is an array, the same remark applies + * when the array contains more bits than the state of the generator. + * </li> + * <li> + * When the native seed type is an array and the {@code seed} is + * {@code null}, the size of the generated array will be 128. + * </li> + * </ul> + * + * @param source RNG type. + * @param seed Seed value. It can be {@code null} (in which case a + * random value will be used). + * @param data Additional arguments to the implementation's constructor. + * Please refer to the documentation of each specific implementation. + * @return the RNG. + * @throws UnsupportedOperationException if the type of the {@code seed} + * is invalid. + * @throws IllegalStateException if data is missing to initialize the + * generator implemented by the given {@code source}. + * + * @see #create(RandomSource) + */ + public static RestorableUniformRandomProvider create(RandomSource source, + Object seed, + Object ... data) { + return ProviderBuilder.create(source.getInternalIdentifier(), seed, data); + } + + /** + * Creates a number for use as a seed. + * + * @return a random number. + */ + public static int createInt() { + return SeedFactory.createInt(); + } + + /** + * Creates a number for use as a seed. + * + * @return a random number. + */ + public static long createLong() { + return SeedFactory.createLong(); + } + + /** + * Creates an array of numbers for use as a seed. + * + * @param n Size of the array to create. + * @return an array of {@code n} random numbers. + */ + public static int[] createIntArray(int n) { + return SeedFactory.createIntArray(n); + } + + /** + * Creates an array of numbers for use as a seed. + * + * @param n Size of the array to create. + * @return an array of {@code n} random numbers. + */ + public static long[] createLongArray(int n) { + return SeedFactory.createLongArray(n); + } + + /** + * Wraps the given {@code delegate} generator in a new instance that + * does not allow access to the "save/restore" functionality. + * + * @param delegate Generator to which calls will be delegated. + * @return a new instance whose state cannot be saved or restored. + */ + public static UniformRandomProvider unrestorable(final UniformRandomProvider delegate) { + return new UniformRandomProvider() { + /** {@inheritDoc} */ + @Override + public void nextBytes(byte[] bytes) { + delegate.nextBytes(bytes); + } + + /** {@inheritDoc} */ + @Override + public void nextBytes(byte[] bytes, + int start, + int len) { + delegate.nextBytes(bytes, start, len); + } + + /** {@inheritDoc} */ + @Override + public int nextInt() { + return delegate.nextInt(); + } + + /** {@inheritDoc} */ + @Override + public int nextInt(int n) { + return delegate.nextInt(n); + } + + /** {@inheritDoc} */ + @Override + public long nextLong() { + return delegate.nextLong(); + } + + /** {@inheritDoc} */ + @Override + public long nextLong(long n) { + return delegate.nextLong(n); + } + + /** {@inheritDoc} */ + @Override + public boolean nextBoolean() { + return delegate.nextBoolean(); + } + + /** {@inheritDoc} */ + @Override + public float nextFloat() { + return delegate.nextFloat(); + } + + /** {@inheritDoc} */ + @Override + public double nextDouble() { + return delegate.nextDouble(); + } + }; + } +} http://git-wip-us.apache.org/repos/asf/commons-rng/blob/42530e25/commons-rng-core/src/main/java/org/apache/commons/rng/RestorableUniformRandomProvider.java ---------------------------------------------------------------------- diff --git a/commons-rng-core/src/main/java/org/apache/commons/rng/RestorableUniformRandomProvider.java b/commons-rng-core/src/main/java/org/apache/commons/rng/RestorableUniformRandomProvider.java new file mode 100644 index 0000000..476ce7f --- /dev/null +++ b/commons-rng-core/src/main/java/org/apache/commons/rng/RestorableUniformRandomProvider.java @@ -0,0 +1,49 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.commons.rng; + +/** + * Applies to generators whose internal state can be saved and restored. + * + * @since 1.0 + */ +public interface RestorableUniformRandomProvider extends UniformRandomProvider { + /** + * Saves the state of a generator. + * + * @return the current state of this instance. It is a value that can + * subsequently be passed to the {@link #restoreState(RandomProviderState) + * restore} method. + * @throws UnsupportedOperationException if the underlying source of + * randomness does not support this functionality. + */ + RandomProviderState saveState(); + + /** + * Restores the state of a generator. + * + * @param state State which this instance will be set to. + * This parameter would usually have been obtained by a call to + * {@link #saveState() saveState} performed either on the same + * object as this one, or an object of the exact same class. + * @throws UnsupportedOperationException if the underlying source of + * randomness does not support this functionality. + * @throws IllegalArgumentException if it was detected that the + * {@code state} argument is incompatible with this intance. + */ + void restoreState(RandomProviderState state); +} http://git-wip-us.apache.org/repos/asf/commons-rng/blob/42530e25/commons-rng-core/src/main/java/org/apache/commons/rng/UniformRandomProvider.java ---------------------------------------------------------------------- diff --git a/commons-rng-core/src/main/java/org/apache/commons/rng/UniformRandomProvider.java b/commons-rng-core/src/main/java/org/apache/commons/rng/UniformRandomProvider.java new file mode 100644 index 0000000..2b974ad --- /dev/null +++ b/commons-rng-core/src/main/java/org/apache/commons/rng/UniformRandomProvider.java @@ -0,0 +1,116 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.commons.rng; + +/** + * Applies to generators of random number sequences that follow a uniform + * distribution. + * + * @since 1.0 + */ +public interface UniformRandomProvider { + /** + * Generates {@code byte} values and places them into a user-supplied array. + * <p> + * The number of random bytes produced is equal to the length of the + * the byte array. + * </p> + * + * @param bytes Byte array in which to put the random bytes. + * Cannot be {@code null}. + */ + void nextBytes(byte[] bytes); + + /** + * Generates {@code byte} values and places them into a user-supplied array. + * + * <p> + * The array is filled with bytes extracted from random integers. + * This implies that the number of random bytes generated may be larger than + * the length of the byte array. + * </p> + * + * @param bytes Array in which to put the generated bytes. + * Cannot be {@code null}. + * @param start Index at which to start inserting the generated bytes. + * @param len Number of bytes to insert. + * @throws IndexOutOfBoundsException if {@code start < 0} or + * {@code start >= bytes.length}. + * @throws IndexOutOfBoundsException if {@code len < 0} or + * {@code len > bytes.length - start}. + */ + void nextBytes(byte[] bytes, + int start, + int len); + + /** + * Generates an {@code int} value. + * + * @return the next random value. + */ + int nextInt(); + + /** + * Generates an {@code int} value between 0 (inclusive) and the + * specified value (exclusive). + * + * @param n Bound on the random number to be returned. Must be positive. + * @return a random {@code int} value between 0 (inclusive) and n + * (exclusive). + * @throws IllegalArgumentException if {@code n} is negative. + */ + int nextInt(int n); + + /** + * Generates a {@code long} value. + * + * @return the next random value. + */ + long nextLong(); + + /** + * Generates a {@code long} value between 0 (inclusive) and the specified + * value (exclusive). + * + * @param n Bound on the random number to be returned. Must be positive. + * @return a random {@code long} value between 0 (inclusive) and n + * (exclusive). + * @throws IllegalArgumentException if {@code n} is negative. + */ + long nextLong(long n); + + /** + * Generates a {@code boolean} value. + * + * @return the next random value. + */ + boolean nextBoolean(); + + /** + * Generates a {@code float} value between 0 and 1. + * + * @return the next random value between 0 and 1. + */ + float nextFloat(); + + /** + * Generates a {@code double} value between 0 and 1. + * + * @return the next random value between 0 and 1. + */ + double nextDouble(); +} http://git-wip-us.apache.org/repos/asf/commons-rng/blob/42530e25/commons-rng-core/src/main/java/org/apache/commons/rng/internal/BaseProvider.java ---------------------------------------------------------------------- diff --git a/commons-rng-core/src/main/java/org/apache/commons/rng/internal/BaseProvider.java b/commons-rng-core/src/main/java/org/apache/commons/rng/internal/BaseProvider.java new file mode 100644 index 0000000..9a6eadd --- /dev/null +++ b/commons-rng-core/src/main/java/org/apache/commons/rng/internal/BaseProvider.java @@ -0,0 +1,153 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.commons.rng.internal; + +import org.apache.commons.rng.RestorableUniformRandomProvider; +import org.apache.commons.rng.RandomProviderState; +import org.apache.commons.rng.RandomSource; + +/** + * Base class with default implementation for common methods. + */ +public abstract class BaseProvider + implements RestorableUniformRandomProvider { + /** {@inheritDoc} */ + @Override + public int nextInt(int n) { + checkStrictlyPositive(n); + + if ((n & -n) == n) { + return (int) ((n * (long) (nextInt() >>> 1)) >> 31); + } + int bits; + int val; + do { + bits = nextInt() >>> 1; + val = bits % n; + } while (bits - val + (n - 1) < 0); + + return val; + } + + /** {@inheritDoc} */ + @Override + public long nextLong(long n) { + checkStrictlyPositive(n); + + long bits; + long val; + do { + bits = nextLong() >>> 1; + val = bits % n; + } while (bits - val + (n - 1) < 0); + + return val; + } + + /** {@inheritDoc} */ + @Override + public RandomProviderState saveState() { + return new RandomSource.State(getStateInternal()); + } + + /** {@inheritDoc} */ + @Override + public void restoreState(RandomProviderState state) { + if (state instanceof RandomSource.State) { + setStateInternal(((RandomSource.State) state).getState()); + } else { + throw new IllegalArgumentException("Foreign instance"); + } + } + + /** {@inheritDoc} */ + @Override + public String toString() { + return getClass().getName(); + } + + /** + * Creates a snapshot of the RNG state. + * + * @return the internal state. + * @throws UnsupportedOperationException if not implemented. + */ + protected byte[] getStateInternal() { + throw new UnsupportedOperationException(); + } + + /** + * Resets the RNG to the given {@code state}. + * + * @param state State (previously obtained by a call to + * {@link #getStateInternal()}). + * @throws UnsupportedOperationException if not implemented. + * + * @see #checkStateSize(byte[],int) + */ + protected void setStateInternal(byte[] state) { + throw new UnsupportedOperationException(); + } + + /** + * Checks that the {@code state} has the {@code expected} size. + * + * @param state State. + * @param expected Expected length of {@code state} array. + * @throws IllegalArgumentException if {@code state.length != expected}. + */ + protected void checkStateSize(byte[] state, + int expected) { + if (state.length != expected) { + throw new IllegalArgumentException("State size must be " + expected + + " but was " + state.length); + } + } + + /** + * Checks whether {@code index} is in the range {@code [min, max]}. + * + * @param min Lower bound. + * @param max Upper bound. + * @param index Value that must lie within the {@code [min, max]} interval. + * @throws IndexOutOfBoundsException if {@code index} is not within the + * {@code [min, max]} interval. + */ + protected void checkIndex(int min, + int max, + int index) { + if (index < min || + index > max) { + throw new IndexOutOfBoundsException(index + " is out of interval [" + + min + ", " + + max + "]"); + } + } + + /** + * Checks that the argument is strictly positive. + * + * @param n Number to check. + * @throws IllegalArgumentException if {@code n <= 0}. + */ + private void checkStrictlyPositive(long n) { + if (n <= 0) { + throw new IllegalArgumentException("Must be strictly positive: " + n); + } + } +}