Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 40060200BB7 for ; Wed, 26 Oct 2016 00:37:22 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 3E7E3160B04; Tue, 25 Oct 2016 22:37:22 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id E837C160AD8 for ; Wed, 26 Oct 2016 00:37:19 +0200 (CEST) Received: (qmail 25572 invoked by uid 500); 25 Oct 2016 22:37:07 -0000 Mailing-List: contact commits-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@commons.apache.org Delivered-To: mailing list commits@commons.apache.org Received: (qmail 19500 invoked by uid 99); 25 Oct 2016 22:37:01 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 25 Oct 2016 22:37:01 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id E2EFFF16B0; Tue, 25 Oct 2016 22:37:00 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: bartem@apache.org To: commits@commons.apache.org Date: Tue, 25 Oct 2016 22:37:49 -0000 Message-Id: In-Reply-To: <813fa0aa778d4130a9d089ee04c8700a@git.apache.org> References: <813fa0aa778d4130a9d089ee04c8700a@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [51/51] [partial] commons-rng git commit: Multimodule support archived-at: Tue, 25 Oct 2016 22:37:22 -0000 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 Authored: Fri Oct 21 02:02:07 2016 +0300 Committer: Artem Barger 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 @@ + + + + + + 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 @@ + + + + + + + + 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 @@ + + + + + This ruleset checks the code for discouraged programming constructs. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 @@ + + + 4.0.0 + + + org.apache.commons + commons-rng + 1.0-SNAPSHOT + + + org.apache.commons + commons-rng-core + 1.0-SNAPSHOT + Apache Commons RNG Core + http://maven.apache.org + + + UTF-8 + + + 2016 + The Apache Commons RNG Core module includes implementations of random numbers generators. + + + scm:git:http://git-wip-us.apache.org/repos/asf/commons-rng.git + scm:git:https://git-wip-us.apache.org/repos/asf/commons-rng.git + https://git-wip-us.apache.org/repos/asf?p=commons-rng.git + + + 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 @@ + + + + + bin + + tar.gz + zip + + false + + + + LICENSE* + NOTICE* + RELEASE-NOTES.txt + + + + target + + + *.jar + + + + target/site + docs + + + + + 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 @@ + + + + src + + tar.gz + zip + + + ${project.artifactId}-${commons.release.version}-src + + + + + *.txt + *.xml + + + + src + + + + + + 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 @@ + + + + + + + + + + Apache Commons RNG Release Notes + + + + + + + + + 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("(?Usage examples:

+ *

+ *  UniformRandomProvider rng = RandomSource.create(RandomSource.MT);
+ * 
+ * or + *

+ *  final int[] seed = new int[] { 196, 9, 0, 226 };
+ *  UniformRandomProvider rng = RandomSource.create(RandomSource.MT, seed);
+ * 
+ * or + *

+ *  final int[] seed = RandomSource.createIntArray(256);
+ *  UniformRandomProvider rng = RandomSource.create(RandomSource.MT, seed);
+ * 
+ * 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. + * + *

+ * 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. + *

+ * + *

+ * Seeding is the procedure by which a value (or set of values) is + * used to initialize 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. + *

+ * + *

+ * 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. + *
+ * The reference algorithm's seeding procedure (if provided) operates + * on a value of a (single) native type: + * Each concrete implementation's constructor creates an instance using + * the native type whose information contents is used to set the + * internal state. + *
+ * 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. + *
+ * 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 not 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. + *
+ * 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 not be the same as the sequences produced + * by other implementations of the same algorithm! + *

+ * + *

+ * 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). + *

+ * + *

+ * 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. + *

+ * + *

+ * 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}. + *

+ *

+ * Although the seed-generating methods defined in this class will likely + * return different values each time they are called, there is no guarantee: + *

+ *
    + *
  • + * In any sub-sequence, it is + * expected that the same numbers can occur, with a probability getting + * higher as the range of allowed values is smaller and the sequence becomes + * longer. + *
  • + *
  • + * It possible that the resulting "seed" will not be good (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 + * dieharder + * or TestU01. + *
  • + *
+ * + *

+ * 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}). + *

+ * + *

+ * Note: + * Seeding is not equivalent to restoring the internal state of an + * already initialized 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). + *

+ * + * @since 1.0 + */ +public enum RandomSource { + /** + * Source of randomness is {@link org.apache.commons.rng.internal.source32.JDKRandom}. + *
    + *
  • Native seed type: {@code Long}.
  • + *
  • Native seed size: 1.
  • + *
+ */ + JDK(ProviderBuilder.RandomSourceInternal.JDK), + /** + * Source of randomness is {@link org.apache.commons.rng.internal.source32.Well512a}. + *
    + *
  • Native seed type: {@code int[]}.
  • + *
  • Native seed size: 16.
  • + *
+ */ + WELL_512_A(ProviderBuilder.RandomSourceInternal.WELL_512_A), + /** + * Source of randomness is {@link org.apache.commons.rng.internal.source32.Well1024a}. + *
    + *
  • Native seed type: {@code int[]}.
  • + *
  • Native seed size: 32.
  • + *
+ */ + WELL_1024_A(ProviderBuilder.RandomSourceInternal.WELL_1024_A), + /** + * Source of randomness is {@link org.apache.commons.rng.internal.source32.Well19937a}. + *
    + *
  • Native seed type: {@code int[]}.
  • + *
  • Native seed size: 624.
  • + *
+ */ + WELL_19937_A(ProviderBuilder.RandomSourceInternal.WELL_19937_A), + /** + * Source of randomness is {@link org.apache.commons.rng.internal.source32.Well19937c}. + *
    + *
  • Native seed type: {@code int[]}.
  • + *
  • Native seed size: 624.
  • + *
+ */ + WELL_19937_C(ProviderBuilder.RandomSourceInternal.WELL_19937_C), + /** + * Source of randomness is {@link org.apache.commons.rng.internal.source32.Well44497a}. + *
    + *
  • Native seed type: {@code int[]}.
  • + *
  • Native seed size: 1391.
  • + *
+ */ + WELL_44497_A(ProviderBuilder.RandomSourceInternal.WELL_44497_A), + /** + * Source of randomness is {@link org.apache.commons.rng.internal.source32.Well44497b}. + *
    + *
  • Native seed type: {@code int[]}.
  • + *
  • Native seed size: 1391.
  • + *
+ */ + WELL_44497_B(ProviderBuilder.RandomSourceInternal.WELL_44497_B), + /** + * Source of randomness is {@link org.apache.commons.rng.internal.source32.MersenneTwister}. + *
    + *
  • Native seed type: {@code int[]}.
  • + *
  • Native seed size: 624.
  • + *
+ */ + MT(ProviderBuilder.RandomSourceInternal.MT), + /** + * Source of randomness is {@link org.apache.commons.rng.internal.source32.ISAACRandom}. + *
    + *
  • Native seed type: {@code int[]}.
  • + *
  • Native seed size: 256.
  • + *
+ */ + ISAAC(ProviderBuilder.RandomSourceInternal.ISAAC), + /** + * Source of randomness is {@link org.apache.commons.rng.internal.source64.SplitMix64}. + *
    + *
  • Native seed type: {@code Long}.
  • + *
  • Native seed size: 1.
  • + *
+ */ + SPLIT_MIX_64(ProviderBuilder.RandomSourceInternal.SPLIT_MIX_64), + /** + * Source of randomness is {@link org.apache.commons.rng.internal.source64.XorShift1024Star}. + *
    + *
  • Native seed type: {@code long[]}.
  • + *
  • Native seed size: 16.
  • + *
+ */ + 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. + *
    + *
  • Native seed type: {@code Integer}.
  • + *
  • Native seed size: 1.
  • + *
+ */ + 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. + *
    + *
  • Native seed type: {@code Integer}.
  • + *
  • Native seed size: 1.
  • + *
+ */ + TWO_CMRES_SELECT(ProviderBuilder.RandomSourceInternal.TWO_CMRES_SELECT), + /** + * Source of randomness is {@link org.apache.commons.rng.internal.source64.MersenneTwister64}. + *
    + *
  • Native seed type: {@code long[]}.
  • + *
  • Native seed size: 312.
  • + *
+ */ + MT_64(ProviderBuilder.RandomSourceInternal.MT_64), + /** + * Source of randomness is {@link org.apache.commons.rng.internal.source32.MultiplyWithCarry256}. + *
    + *
  • Native seed type: {@code int[]}.
  • + *
  • Native seed size: 257.
  • + *
+ */ + MWC_256(ProviderBuilder.RandomSourceInternal.MWC_256), + /** + * Source of randomness is {@link org.apache.commons.rng.internal.source32.KISSRandom}. + *
    + *
  • Native seed type: {@code int[]}.
  • + *
  • Native seed size: 4.
  • + *
+ */ + 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. + * + *

Usage example:

+ *

+     *  UniformRandomProvider rng = RandomSource.create(RandomSource.MT);
+     * 
+ *

or, if a {@link RestorableUniformRandomProvider "save/restore"} functionality is needed,

+ *

+     *  RestorableUniformRandomProvider rng = RandomSource.create(RandomSource.MT);
+     * 
+ * + * @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}. + * + *

Usage example:

+ *

+     *  UniformRandomProvider rng = RandomSource.create(RandomSource.TWO_CMRES_SELECT, 26219, 6, 9);
+     * 
+ * + *

Valid types for the {@code seed} are:

+ *
    + *
  • {@code Integer} (or {@code int})
  • + *
  • {@code Long} (or {@code long})
  • + *
  • {@code int[]}
  • + *
  • {@code long[]}
  • + *
  • {@code byte[]}
  • + *
+ * + *

Notes:

+ *
    + *
  • + * 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. + *
  • + *
  • + * When the native seed type is an array, the same remark applies + * when the array contains more bits than the state of the generator. + *
  • + *
  • + * When the native seed type is an array and the {@code seed} is + * {@code null}, the size of the generated array will be 128. + *
  • + *
+ * + * @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. + *

+ * The number of random bytes produced is equal to the length of the + * the byte array. + *

+ * + * @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. + * + *

+ * 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. + *

+ * + * @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); + } + } +}