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 15:49:54 UTC
[21/25] [math] MATH-1335
MATH-1335
Use new RNG API.
Project: http://git-wip-us.apache.org/repos/asf/commons-math/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-math/commit/11a7e62a
Tree: http://git-wip-us.apache.org/repos/asf/commons-math/tree/11a7e62a
Diff: http://git-wip-us.apache.org/repos/asf/commons-math/diff/11a7e62a
Branch: refs/heads/develop
Commit: 11a7e62a898e54d66936d1b8b67cb5e62578ba98
Parents: 7331773
Author: Gilles <er...@apache.org>
Authored: Wed May 11 16:53:19 2016 +0200
Committer: Gilles <er...@apache.org>
Committed: Tue May 17 15:30:23 2016 +0200
----------------------------------------------------------------------
.../org/apache/commons/math4/util/FastMathTest.java | 15 ++++++++-------
.../apache/commons/math4/util/MathArraysTest.java | 5 +++--
2 files changed, 11 insertions(+), 9 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/commons-math/blob/11a7e62a/src/test/java/org/apache/commons/math4/util/FastMathTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/math4/util/FastMathTest.java b/src/test/java/org/apache/commons/math4/util/FastMathTest.java
index 26c1cd9..cc95c9c 100644
--- a/src/test/java/org/apache/commons/math4/util/FastMathTest.java
+++ b/src/test/java/org/apache/commons/math4/util/FastMathTest.java
@@ -28,9 +28,8 @@ import org.apache.commons.math4.dfp.Dfp;
import org.apache.commons.math4.dfp.DfpField;
import org.apache.commons.math4.dfp.DfpMath;
import org.apache.commons.math4.exception.MathArithmeticException;
-import org.apache.commons.math4.random.MersenneTwister;
-import org.apache.commons.math4.random.RandomGenerator;
-import org.apache.commons.math4.random.Well1024a;
+import org.apache.commons.math4.rng.UniformRandomProvider;
+import org.apache.commons.math4.rng.RandomSource;
import org.apache.commons.math4.util.FastMath;
import org.apache.commons.math4.util.Precision;
import org.junit.Assert;
@@ -45,12 +44,12 @@ public class FastMathTest {
private DfpField field;
- private RandomGenerator generator;
+ private UniformRandomProvider generator;
@Before
public void setUp() {
field = new DfpField(40);
- generator = new MersenneTwister(6176597458463500194l);
+ generator = RandomSource.create(RandomSource.MT, 6176597458463500194l);
}
@Test
@@ -1914,7 +1913,8 @@ public class FastMathTest {
@Test
public void testFloorDivModInt() {
- RandomGenerator generator = new Well1024a(0x7ccab45edeaab90al);
+ UniformRandomProvider generator = RandomSource.create(RandomSource.WELL_1024_A,
+ 0x7ccab45edeaab90al);
for (int i = 0; i < 10000; ++i) {
int a = generator.nextInt();
int b = generator.nextInt();
@@ -1986,7 +1986,8 @@ public class FastMathTest {
@Test
public void testFloorDivModLong() {
- RandomGenerator generator = new Well1024a(0xb87b9bc14c96ccd5l);
+ UniformRandomProvider generator = RandomSource.create(RandomSource.WELL_1024_A,
+ 0xb87b9bc14c96ccd5l);
for (int i = 0; i < 10000; ++i) {
long a = generator.nextLong();
long b = generator.nextLong();
http://git-wip-us.apache.org/repos/asf/commons-math/blob/11a7e62a/src/test/java/org/apache/commons/math4/util/MathArraysTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/math4/util/MathArraysTest.java b/src/test/java/org/apache/commons/math4/util/MathArraysTest.java
index d0b635c..05de1b0 100644
--- a/src/test/java/org/apache/commons/math4/util/MathArraysTest.java
+++ b/src/test/java/org/apache/commons/math4/util/MathArraysTest.java
@@ -25,8 +25,8 @@ import org.apache.commons.math4.exception.NotANumberException;
import org.apache.commons.math4.exception.NotPositiveException;
import org.apache.commons.math4.exception.NotStrictlyPositiveException;
import org.apache.commons.math4.exception.NullArgumentException;
+import org.apache.commons.math4.rng.UniformRandomProvider;
import org.apache.commons.math4.rng.RandomSource;
-import org.apache.commons.math4.random.Well1024a;
import org.apache.commons.math4.util.FastMath;
import org.apache.commons.math4.util.MathArrays;
import org.apache.commons.math4.util.Precision;
@@ -762,7 +762,8 @@ public class MathArraysTest {
public void testLinearCombination2() {
// we compare accurate versus naive dot product implementations
// on regular vectors (i.e. not extreme cases like in the previous test)
- Well1024a random = new Well1024a(553267312521321234l);
+ UniformRandomProvider random = RandomSource.create(RandomSource.XOR_SHIFT_1024_S,
+ 553267312521321234l);
for (int i = 0; i < 10000; ++i) {
final double ux = 1e17 * random.nextDouble();