From b720481312289d9fb311caeb4593c10561af317d Mon Sep 17 00:00:00 2001 From: Gilles Date: Thu, 12 May 2016 14:04:19 +0200 Subject: [PATCH] MATH-1335 Use new RNG API. --- .../math4/geometry/enclosing/WelzlEncloser2DTest.java | 6 +++--- .../geometry/euclidean/threed/FieldVector3DTest.java | 7 ++++--- .../geometry/euclidean/threed/PolyhedronsSetTest.java | 6 +++--- .../math4/geometry/euclidean/threed/Vector3DTest.java | 7 ++++--- .../twod/hull/ConvexHullGenerator2DAbstractTest.java | 8 ++++---- 5 files changed, 18 insertions(+), 16 deletions(-) diff --git a/src/test/java/org/apache/commons/math4/geometry/enclosing/WelzlEncloser2DTest.java b/src/test/java/org/apache/commons/math4/geometry/enclosing/WelzlEncloser2DTest.java index 3729574e6..2d39da5d4 100644 --- a/src/test/java/org/apache/commons/math4/geometry/enclosing/WelzlEncloser2DTest.java +++ b/src/test/java/org/apache/commons/math4/geometry/enclosing/WelzlEncloser2DTest.java @@ -25,8 +25,8 @@ import org.apache.commons.math4.geometry.enclosing.WelzlEncloser; import org.apache.commons.math4.geometry.euclidean.twod.DiskGenerator; import org.apache.commons.math4.geometry.euclidean.twod.Euclidean2D; import org.apache.commons.math4.geometry.euclidean.twod.Vector2D; -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.junit.Assert; import org.junit.Test; @@ -84,7 +84,7 @@ public class WelzlEncloser2DTest { @Test public void testLargeSamples() { - RandomGenerator random = new Well1024a(0xa2a63cad12c01fb2l); + UniformRandomProvider random = RandomSource.create(RandomSource.WELL_1024_A, 0xa2a63cad12c01fb2l); for (int k = 0; k < 100; ++k) { int nbPoints = random.nextInt(10000); List points = new ArrayList(); diff --git a/src/test/java/org/apache/commons/math4/geometry/euclidean/threed/FieldVector3DTest.java b/src/test/java/org/apache/commons/math4/geometry/euclidean/threed/FieldVector3DTest.java index 24e551504..2cf235fa3 100644 --- a/src/test/java/org/apache/commons/math4/geometry/euclidean/threed/FieldVector3DTest.java +++ b/src/test/java/org/apache/commons/math4/geometry/euclidean/threed/FieldVector3DTest.java @@ -27,7 +27,8 @@ import org.apache.commons.math4.exception.DimensionMismatchException; import org.apache.commons.math4.exception.MathArithmeticException; import org.apache.commons.math4.geometry.euclidean.threed.FieldVector3D; import org.apache.commons.math4.geometry.euclidean.threed.Vector3D; -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; @@ -592,7 +593,7 @@ public class FieldVector3DTest { public void testDotProduct() { // 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.WELL_1024_A, 553267312521321237l); for (int i = 0; i < 10000; ++i) { double ux = 10000 * random.nextDouble(); double uy = 10000 * random.nextDouble(); @@ -649,7 +650,7 @@ public class FieldVector3DTest { public void testCrossProduct() { // we compare accurate versus naive cross product implementations // on regular vectors (i.e. not extreme cases like in the previous test) - Well1024a random = new Well1024a(885362227452043214l); + UniformRandomProvider random = RandomSource.create(RandomSource.WELL_1024_A, 885362227452043214l); for (int i = 0; i < 10000; ++i) { double ux = random.nextDouble(); double uy = random.nextDouble(); diff --git a/src/test/java/org/apache/commons/math4/geometry/euclidean/threed/PolyhedronsSetTest.java b/src/test/java/org/apache/commons/math4/geometry/euclidean/threed/PolyhedronsSetTest.java index b1b902ad5..c0aaa1301 100644 --- a/src/test/java/org/apache/commons/math4/geometry/euclidean/threed/PolyhedronsSetTest.java +++ b/src/test/java/org/apache/commons/math4/geometry/euclidean/threed/PolyhedronsSetTest.java @@ -50,8 +50,8 @@ import org.apache.commons.math4.geometry.partitioning.RegionDumper; import org.apache.commons.math4.geometry.partitioning.RegionFactory; import org.apache.commons.math4.geometry.partitioning.RegionParser; import org.apache.commons.math4.geometry.partitioning.SubHyperplane; -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.junit.Assert; import org.junit.Test; @@ -440,7 +440,7 @@ public class PolyhedronsSetTest { public void testIssue1211() throws IOException, ParseException { PolyhedronsSet polyset = RegionParser.parsePolyhedronsSet(loadTestData("issue-1211.bsp")); - RandomGenerator random = new Well1024a(0xb97c9d1ade21e40al); + UniformRandomProvider random = RandomSource.create(RandomSource.WELL_1024_A, 0xb97c9d1ade21e40al); int nrays = 1000; for (int i = 0; i < nrays; i++) { Vector3D origin = Vector3D.ZERO; diff --git a/src/test/java/org/apache/commons/math4/geometry/euclidean/threed/Vector3DTest.java b/src/test/java/org/apache/commons/math4/geometry/euclidean/threed/Vector3DTest.java index 41b0e3a34..f9bf79b9f 100644 --- a/src/test/java/org/apache/commons/math4/geometry/euclidean/threed/Vector3DTest.java +++ b/src/test/java/org/apache/commons/math4/geometry/euclidean/threed/Vector3DTest.java @@ -28,7 +28,8 @@ import org.apache.commons.math4.exception.MathArithmeticException; import org.apache.commons.math4.geometry.Space; import org.apache.commons.math4.geometry.euclidean.threed.Rotation; import org.apache.commons.math4.geometry.euclidean.threed.Vector3D; -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; @@ -350,7 +351,7 @@ public class Vector3DTest { public void testDotProduct() { // 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.WELL_1024_A, 553267312521321237l); for (int i = 0; i < 10000; ++i) { double ux = 10000 * random.nextDouble(); double uy = 10000 * random.nextDouble(); @@ -392,7 +393,7 @@ public class Vector3DTest { public void testCrossProduct() { // we compare accurate versus naive cross product implementations // on regular vectors (i.e. not extreme cases like in the previous test) - Well1024a random = new Well1024a(885362227452043214l); + UniformRandomProvider random = RandomSource.create(RandomSource.WELL_1024_A, 885362227452043215l); for (int i = 0; i < 10000; ++i) { double ux = 10000 * random.nextDouble(); double uy = 10000 * random.nextDouble(); diff --git a/src/test/java/org/apache/commons/math4/geometry/euclidean/twod/hull/ConvexHullGenerator2DAbstractTest.java b/src/test/java/org/apache/commons/math4/geometry/euclidean/twod/hull/ConvexHullGenerator2DAbstractTest.java index 717b2644c..ea32b9cca 100644 --- a/src/test/java/org/apache/commons/math4/geometry/euclidean/twod/hull/ConvexHullGenerator2DAbstractTest.java +++ b/src/test/java/org/apache/commons/math4/geometry/euclidean/twod/hull/ConvexHullGenerator2DAbstractTest.java @@ -29,8 +29,8 @@ import org.apache.commons.math4.geometry.euclidean.twod.hull.ConvexHull2D; import org.apache.commons.math4.geometry.euclidean.twod.hull.ConvexHullGenerator2D; import org.apache.commons.math4.geometry.partitioning.Region; import org.apache.commons.math4.geometry.partitioning.Region.Location; -import org.apache.commons.math4.random.MersenneTwister; -import org.apache.commons.math4.random.RandomGenerator; +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.MathArrays; import org.apache.commons.math4.util.Precision; @@ -45,7 +45,7 @@ import org.junit.Test; public abstract class ConvexHullGenerator2DAbstractTest { protected ConvexHullGenerator2D generator; - protected RandomGenerator random; + protected UniformRandomProvider random; protected abstract ConvexHullGenerator2D createConvexHullGenerator(boolean includeCollinearPoints); @@ -58,7 +58,7 @@ public abstract class ConvexHullGenerator2DAbstractTest { public void setUp() { // by default, do not include collinear points generator = createConvexHullGenerator(false); - random = new MersenneTwister(10); + random = RandomSource.create(RandomSource.MT, 10); } // ------------------------------------------------------------------------------