You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by er...@apache.org on 2016/05/17 18:34:41 UTC

[06/12] [math] MATH-1366

MATH-1366

Implementation of the RNG was moved to package "o.a.c.m.rng.internal.source32".


Project: http://git-wip-us.apache.org/repos/asf/commons-math/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-math/commit/70594746
Tree: http://git-wip-us.apache.org/repos/asf/commons-math/tree/70594746
Diff: http://git-wip-us.apache.org/repos/asf/commons-math/diff/70594746

Branch: refs/heads/task-MATH-1366
Commit: 7059474674d61d29c90369de0b402efdf0103ee2
Parents: 19ca67a
Author: Gilles <er...@apache.org>
Authored: Tue May 17 19:36:35 2016 +0200
Committer: Gilles <er...@apache.org>
Committed: Tue May 17 19:36:35 2016 +0200

----------------------------------------------------------------------
 .../apache/commons/math4/random/Well512a.java   | 108 -------------------
 .../commons/math4/random/Well512aTest.java      |  77 -------------
 2 files changed, 185 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-math/blob/70594746/src/main/java/org/apache/commons/math4/random/Well512a.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math4/random/Well512a.java b/src/main/java/org/apache/commons/math4/random/Well512a.java
deleted file mode 100644
index 391bb2f..0000000
--- a/src/main/java/org/apache/commons/math4/random/Well512a.java
+++ /dev/null
@@ -1,108 +0,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.
- */
-package org.apache.commons.math4.random;
-
-
-/** This class implements the WELL512a pseudo-random number generator
- * from Fran&ccedil;ois Panneton, Pierre L'Ecuyer and Makoto Matsumoto.
- * <p>
- * This generator is described in a paper by Fran&ccedil;ois Panneton,
- * Pierre L'Ecuyer and Makoto Matsumoto <a
- * href="http://www.iro.umontreal.ca/~lecuyer/myftp/papers/wellrng.pdf">Improved
- * Long-Period Generators Based on Linear Recurrences Modulo 2</a> ACM
- * Transactions on Mathematical Software, 32, 1 (2006). The errata for the paper
- * are in <a href="http://www.iro.umontreal.ca/~lecuyer/myftp/papers/wellrng-errata.txt">wellrng-errata.txt</a>.</p>
- *
- * @see <a href="http://www.iro.umontreal.ca/~panneton/WELLRNG.html">WELL Random number generator</a>
- * @since 2.2
- */
-public class Well512a extends AbstractWell {
-
-    /** Serializable version identifier. */
-    private static final long serialVersionUID = 20150223L;
-
-    /** Number of bits in the pool. */
-    private static final int K = 512;
-
-    /** First parameter of the algorithm. */
-    private static final int M1 = 13;
-
-    /** Second parameter of the algorithm. */
-    private static final int M2 = 9;
-
-    /** Third parameter of the algorithm. */
-    private static final int M3 = 5;
-
-    /** The indirection index table. */
-    private static final IndexTable TABLE = new IndexTable(K, M1, M2, M3);
-
-    /** Creates a new random number generator.
-     * <p>The instance is initialized using the current time as the
-     * seed.</p>
-     */
-    public Well512a() {
-        super(K);
-    }
-
-    /** Creates a new random number generator using a single int seed.
-     * @param seed the initial seed (32 bits integer)
-     */
-    public Well512a(int seed) {
-        super(K, seed);
-    }
-
-    /** Creates a new random number generator using an int array seed.
-     * @param seed the initial seed (32 bits integers array), if null
-     * the seed of the generator will be related to the current time
-     */
-    public Well512a(int[] seed) {
-        super(K, seed);
-    }
-
-    /** Creates a new random number generator using a single long seed.
-     * @param seed the initial seed (64 bits integer)
-     */
-    public Well512a(long seed) {
-        super(K, seed);
-    }
-
-    /** {@inheritDoc} */
-    @Override
-    protected int next(final int bits) {
-
-        final int indexRm1 = TABLE.getIndexPred(index);
-
-        final int vi = v[index];
-        final int vi1 = v[TABLE.getIndexM1(index)];
-        final int vi2 = v[TABLE.getIndexM2(index)];
-        final int z0 = v[indexRm1];
-
-        // the values below include the errata of the original article
-        final int z1 = (vi ^ (vi << 16))   ^ (vi1 ^ (vi1 << 15));
-        final int z2 = vi2 ^ (vi2 >>> 11);
-        final int z3 = z1 ^ z2;
-        final int z4 = (z0 ^ (z0 << 2)) ^ (z1 ^ (z1 << 18)) ^ (z2 << 28) ^ (z3 ^ ((z3 << 5) & 0xda442d24));
-
-        v[index] = z3;
-        v[indexRm1]  = z4;
-        index    = indexRm1;
-
-        return z4 >>> (32 - bits);
-
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/commons-math/blob/70594746/src/test/java/org/apache/commons/math4/random/Well512aTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/math4/random/Well512aTest.java b/src/test/java/org/apache/commons/math4/random/Well512aTest.java
deleted file mode 100644
index 192d7d5..0000000
--- a/src/test/java/org/apache/commons/math4/random/Well512aTest.java
+++ /dev/null
@@ -1,77 +0,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.
- */
-package org.apache.commons.math4.random;
-
-import org.apache.commons.math4.random.RandomGenerator;
-import org.apache.commons.math4.random.Well512a;
-import org.junit.Assert;
-import org.junit.Test;
-
-public class Well512aTest extends RandomGeneratorAbstractTest {
-
-    @Override
-    public RandomGenerator makeGenerator() {
-        return new Well512a(101);
-    }
-    @Test
-    public void testReferenceCode() {
-        Well512a mt = new Well512a(new int[] {
-            740849862,  1202665156,  -199039369,  -259008301,  -291878969, -1164428990, -1565918811,   491009864,
-          -1883086670,  1383450241,  1244617256,   689006653, -1576746370, -1307940314,  1421489086,  1742094000
-       });
-        int[] refInt = {
-            1634813289,   1876773016,   -973836208,  -2130023652,  -1045460084,  -1834384857,   1691032973,    609714289,
-            2033920362,    555915483,      6680992,   1958127415,   1866469645,  -1471336965,   2049178762,   -192324811,
-           -2056050066,    810879705,   1405046309,   -781317118,   1012782311,  -1045081032,    728377508,   1473511660,
-             290489070,    326666761,   2018299979,  -1876688058,   1239968501,   1464625040,   2025151042,   -101397407,
-            1387902041,    210959839,   1366359326,   -476473433,    153180037,  -1607631523,   -506743495,     17888738,
-             313865008,   -340504498,    586684079,   1243699375,    753162229,   -646761694,   -739189655,   -210120185,
-           -1856358726,   -628255542,  -1812798197,   1416288088,   1077967722,   -846846208,   1379850409,   -580183344,
-              -1858959,    210859778,    295841424,   1492774865,  -1415543680,   -344870570,  -1942779197,   1549510646,
-            -389544849,    314254218,     11784988,  -1311757368,   1719514841,   -764610517,   1296788970,   -994707050,
-             783854563,    422654144,    387639079,   1219688425,   2144352572,   -834212874,  -1036550358,    935909479,
-            -568610842,   1327498837,   -588933178,   1910065754,    -40851599,   -182063170,   1302731458,    541311559,
-           -1647345522,    805224371,  -1721196679,   1518507830,   -952689880,   -433276260,    509675254,   -777259954,
-            1277810106,    284054896,    936042202,   2036836351,   1956412426,  -1186403024,    287795400,   2135311211,
-             720485927,   1500695024,   -281656583,  -1277937322,  -1628968482,   1242814831,  -2030700974,   1473867890,
-             440813549,  -1357033971,     28384076,   1602731216,   -641465746,   -609054347,    635938444,   1472898176,
-            1476894555,   -747974186,  -1590337055,   -884242108,   -389736197,  -2066984505,   1087103272,  -1236446290,
-              31657463,   1835715432,   -468439078,  -2132633204,   -434609235,    258308151,   1851926761,  -1630139159,
-           -1344617241,   1969204215,    619463174,   -174392624,    207475487,  -1619828078,   1327980298,    -83968178,
-             445951782,  -1786230541,      6279288,   -580982231,   1550645552,   2006533941,    275746007,    455676647,
-            2019637349,   1115547704,  -1313120106,   -516213449,     73752461,  -1382448112,    398589620,   1319888048,
-           -1595572334,   1566934536,  -1735685764,  -1509545339,   1458173912,   -549395819,   -618827040,   1516624531,
-            1900757187,  -1454200688,    965524719,    488355065,  -1869294316,   -810641680,  -2059428251,   1454656431,
-            1329120541,   -232185900,   -994996943,   1855980910,   -452077812,   1565630611,    759842266,   1241435187,
-           -1390456063,   1946400597,  -2032319771,    683667881,    905911106,   1983310786,    120010546,    526018017,
-           -1946881912,    205004987,  -1307250612,   2130980818,   2052864161,    189839787,   1789478047,    406168885,
-           -1145186347,      8507675,   1277188815,   1492619042,   2009819675,  -1627411598,   -851016743,  -1828234956,
-            1962622506,   2140398255,    236935165,   -337237772,   1263419111,    516775236,   -335741025,   1391328225,
-             455979249,  -1457534664,   -657606241,    485648133,   1762116343,   1194889600,    817834937,    321150162,
-             131159182,    290277758,  -1876924740,  -1770401129,   1291602973,  -1003642974,  -1580211929,   1520422021,
-            -399171579,    -24315308,    453805396,   -659197747,   -205656847,    466526550,   1444397201,   1178091401,
-           -1157268826,   -602394028,  -1370668795,   1614896435,   1699071659,   1864753793,   1888518358,  -1721244514,
-            1812776767,    668822227,   -297283057,   2130183333,  -1169618692,    912860240,  -2028253096,   1244694278
-        };
-
-        for (int i = 0; i < refInt.length; ++i) {
-            Assert.assertEquals(refInt[i], mt.nextInt());
-        }
-
-    }
-
-}