MATH-1335

Use new RNG API.
This commit is contained in:
Gilles 2016-05-12 14:04:19 +02:00
parent ae7ade3990
commit b720481312
5 changed files with 18 additions and 16 deletions

View File

@ -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<Vector2D> points = new ArrayList<Vector2D>();

View File

@ -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();

View File

@ -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;

View File

@ -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();

View File

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