You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by ma...@apache.org on 2021/09/30 03:10:52 UTC
[commons-geometry] branch master updated: using latest commons-rng
syntax
This is an automated email from the ASF dual-hosted git repository.
mattjuntunen pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-geometry.git
The following commit(s) were added to refs/heads/master by this push:
new 4792f9c using latest commons-rng syntax
4792f9c is described below
commit 4792f9cba313e3c4498e4f8a54b44c7f622d1590
Author: Matt Juntunen <ma...@apache.org>
AuthorDate: Wed Sep 29 23:10:38 2021 -0400
using latest commons-rng syntax
---
.../geometry/enclosing/euclidean/threed/SphereGeneratorTest.java | 9 ++++-----
.../geometry/enclosing/euclidean/threed/WelzlEncloser3DTest.java | 9 ++++-----
.../geometry/enclosing/euclidean/twod/DiskGeneratorTest.java | 9 ++++-----
.../geometry/enclosing/euclidean/twod/WelzlEncloser2DTest.java | 2 +-
.../apache/commons/geometry/euclidean/threed/Vector3DTest.java | 4 ++--
.../euclidean/threed/rotation/QuaternionRotationTest.java | 2 +-
.../commons/geometry/euclidean/threed/shape/SphereTest.java | 2 +-
.../examples/jmh/euclidean/AffineTransformMatrixPerformance.java | 8 ++++----
.../geometry/examples/jmh/euclidean/CirclePerformance.java | 4 ++--
.../geometry/examples/jmh/euclidean/SpherePerformance.java | 4 ++--
.../geometry/examples/jmh/euclidean/VectorPerformance.java | 2 +-
.../hull/euclidean/twod/ConvexHullGenerator2DAbstractTest.java | 2 +-
12 files changed, 27 insertions(+), 30 deletions(-)
diff --git a/commons-geometry-enclosing/src/test/java/org/apache/commons/geometry/enclosing/euclidean/threed/SphereGeneratorTest.java b/commons-geometry-enclosing/src/test/java/org/apache/commons/geometry/enclosing/euclidean/threed/SphereGeneratorTest.java
index df8fb86..cc012e5 100644
--- a/commons-geometry-enclosing/src/test/java/org/apache/commons/geometry/enclosing/euclidean/threed/SphereGeneratorTest.java
+++ b/commons-geometry-enclosing/src/test/java/org/apache/commons/geometry/enclosing/euclidean/threed/SphereGeneratorTest.java
@@ -178,16 +178,15 @@ class SphereGeneratorTest {
@Test
void testRandom() {
// arrange
- final UniformRandomProvider random = RandomSource.create(RandomSource.WELL_1024_A,
- 0xd015982e9f31ee04L);
- final UnitSphereSampler sr = new UnitSphereSampler(3, random);
+ final UniformRandomProvider random = RandomSource.WELL_1024_A.create(0xd015982e9f31ee04L);
+ final UnitSphereSampler sr = UnitSphereSampler.of(random, 3);
for (int i = 0; i < 100; ++i) {
final double d = 25 * random.nextDouble();
final double refRadius = 10 * random.nextDouble();
- final Vector3D refCenter = Vector3D.of(sr.nextVector()).multiply(d);
+ final Vector3D refCenter = Vector3D.of(sr.sample()).multiply(d);
final List<Vector3D> support = new ArrayList<>();
for (int j = 0; j < 5; ++j) {
- support.add(Vector3D.Sum.of(refCenter).addScaled(refRadius, Vector3D.of(sr.nextVector())).get());
+ support.add(Vector3D.Sum.of(refCenter).addScaled(refRadius, Vector3D.of(sr.sample())).get());
}
// act
diff --git a/commons-geometry-enclosing/src/test/java/org/apache/commons/geometry/enclosing/euclidean/threed/WelzlEncloser3DTest.java b/commons-geometry-enclosing/src/test/java/org/apache/commons/geometry/enclosing/euclidean/threed/WelzlEncloser3DTest.java
index 9561982..544148a 100644
--- a/commons-geometry-enclosing/src/test/java/org/apache/commons/geometry/enclosing/euclidean/threed/WelzlEncloser3DTest.java
+++ b/commons-geometry-enclosing/src/test/java/org/apache/commons/geometry/enclosing/euclidean/threed/WelzlEncloser3DTest.java
@@ -111,22 +111,21 @@ class WelzlEncloser3DTest {
@Test
void testLargeSamples() {
// arrange
- final UniformRandomProvider random = RandomSource.create(RandomSource.WELL_1024_A,
- 0x35ddecfc78131e1dL);
- final UnitSphereSampler sr = new UnitSphereSampler(3, random);
+ final UniformRandomProvider random = RandomSource.WELL_1024_A.create(0x35ddecfc78131e1dL);
+ final UnitSphereSampler sr = UnitSphereSampler.of(random, 3);
for (int k = 0; k < 50; ++k) {
// define the reference sphere we want to compute
final double d = 25 * random.nextDouble();
final double refRadius = 10 * random.nextDouble();
- final Vector3D refCenter = Vector3D.of(sr.nextVector()).multiply(d);
+ final Vector3D refCenter = Vector3D.of(sr.sample()).multiply(d);
// set up a large sample inside the reference sphere
final int nbPoints = random.nextInt(1000);
final List<Vector3D> points = new ArrayList<>();
for (int i = 0; i < nbPoints; ++i) {
final double r = refRadius * random.nextDouble();
- points.add(Vector3D.Sum.of(refCenter).addScaled(r, Vector3D.of(sr.nextVector())).get());
+ points.add(Vector3D.Sum.of(refCenter).addScaled(r, Vector3D.of(sr.sample())).get());
}
// act/assert
diff --git a/commons-geometry-enclosing/src/test/java/org/apache/commons/geometry/enclosing/euclidean/twod/DiskGeneratorTest.java b/commons-geometry-enclosing/src/test/java/org/apache/commons/geometry/enclosing/euclidean/twod/DiskGeneratorTest.java
index c3428d9..18dce78 100644
--- a/commons-geometry-enclosing/src/test/java/org/apache/commons/geometry/enclosing/euclidean/twod/DiskGeneratorTest.java
+++ b/commons-geometry-enclosing/src/test/java/org/apache/commons/geometry/enclosing/euclidean/twod/DiskGeneratorTest.java
@@ -132,16 +132,15 @@ class DiskGeneratorTest {
@Test
void testRandom() {
// arrange
- final UniformRandomProvider random = RandomSource.create(RandomSource.WELL_1024_A,
- 0x12faa818373ffe90L);
- final UnitSphereSampler sr = new UnitSphereSampler(2, random);
+ final UniformRandomProvider random = RandomSource.WELL_1024_A.create(0x12faa818373ffe90L);
+ final UnitSphereSampler sr = UnitSphereSampler.of(random, 2);
for (int i = 0; i < 500; ++i) {
final double d = 25 * random.nextDouble();
final double refRadius = 10 * random.nextDouble();
- final Vector2D refCenter = Vector2D.of(sr.nextVector()).multiply(d);
+ final Vector2D refCenter = Vector2D.of(sr.sample()).multiply(d);
final List<Vector2D> support = new ArrayList<>();
for (int j = 0; j < 3; ++j) {
- support.add(Vector2D.Sum.of(refCenter).addScaled(refRadius, Vector2D.of(sr.nextVector())).get());
+ support.add(Vector2D.Sum.of(refCenter).addScaled(refRadius, Vector2D.of(sr.sample())).get());
}
// act
diff --git a/commons-geometry-enclosing/src/test/java/org/apache/commons/geometry/enclosing/euclidean/twod/WelzlEncloser2DTest.java b/commons-geometry-enclosing/src/test/java/org/apache/commons/geometry/enclosing/euclidean/twod/WelzlEncloser2DTest.java
index 8bbb9cb..67493d1 100755
--- a/commons-geometry-enclosing/src/test/java/org/apache/commons/geometry/enclosing/euclidean/twod/WelzlEncloser2DTest.java
+++ b/commons-geometry-enclosing/src/test/java/org/apache/commons/geometry/enclosing/euclidean/twod/WelzlEncloser2DTest.java
@@ -100,7 +100,7 @@ class WelzlEncloser2DTest {
@Test
void testLargeSamples() {
// arrange
- final UniformRandomProvider random = RandomSource.create(RandomSource.WELL_1024_A, 0xa2a63cad12c01fb2L);
+ final UniformRandomProvider random = RandomSource.WELL_1024_A.create(0xa2a63cad12c01fb2L);
for (int k = 0; k < 100; ++k) {
final int nbPoints = random.nextInt(10000);
final List<Vector2D> points = new ArrayList<>();
diff --git a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/Vector3DTest.java b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/Vector3DTest.java
index 02e5642..476fa6e 100644
--- a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/Vector3DTest.java
+++ b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/Vector3DTest.java
@@ -644,7 +644,7 @@ class Vector3DTest {
void testCrossProduct_accuracy() {
// we compare accurate versus naive cross product implementations
// on regular vectors (i.e. not extreme cases like in the previous test)
- final UniformRandomProvider random = RandomSource.create(RandomSource.WELL_1024_A, 885362227452043215L);
+ final UniformRandomProvider random = RandomSource.WELL_1024_A.create(885362227452043215L);
for (int i = 0; i < 10000; ++i) {
// arrange
final double ux = 10000 * random.nextDouble();
@@ -780,7 +780,7 @@ class Vector3DTest {
void testDotProduct_accuracy() {
// we compare accurate versus naive dot product implementations
// on regular vectors (i.e. not extreme cases like in the previous test)
- final UniformRandomProvider random = RandomSource.create(RandomSource.WELL_1024_A, 553267312521321237L);
+ final UniformRandomProvider random = RandomSource.WELL_1024_A.create(553267312521321237L);
for (int i = 0; i < 10000; ++i) {
// arrange
final double ux = 10000 * random.nextDouble();
diff --git a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/rotation/QuaternionRotationTest.java b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/rotation/QuaternionRotationTest.java
index 8b5a395..95f6493 100644
--- a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/rotation/QuaternionRotationTest.java
+++ b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/rotation/QuaternionRotationTest.java
@@ -443,7 +443,7 @@ class QuaternionRotationTest {
QuaternionRotation q = QuaternionRotation.identity();
- final UniformRandomProvider rand = RandomSource.create(RandomSource.JDK, 2L);
+ final UniformRandomProvider rand = RandomSource.JDK.create(2L);
// act
for (int i = 0; i < slices; ++i) {
diff --git a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/shape/SphereTest.java b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/shape/SphereTest.java
index 83a095f..57d699a 100644
--- a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/shape/SphereTest.java
+++ b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/shape/SphereTest.java
@@ -362,7 +362,7 @@ class SphereTest {
@Test
void testToTree_randomSpheres() {
// arrange
- final UniformRandomProvider rand = RandomSource.create(RandomSource.XO_RO_SHI_RO_128_PP, 1L);
+ final UniformRandomProvider rand = RandomSource.XO_RO_SHI_RO_128_PP.create(1L);
final Precision.DoubleEquivalence precision = Precision.doubleEquivalenceOfEpsilon(1e-10);
final double min = 1e-1;
final double max = 1e2;
diff --git a/commons-geometry-examples/examples-jmh/src/main/java/org/apache/commons/geometry/examples/jmh/euclidean/AffineTransformMatrixPerformance.java b/commons-geometry-examples/examples-jmh/src/main/java/org/apache/commons/geometry/examples/jmh/euclidean/AffineTransformMatrixPerformance.java
index d437f4b..0ccb8ea 100644
--- a/commons-geometry-examples/examples-jmh/src/main/java/org/apache/commons/geometry/examples/jmh/euclidean/AffineTransformMatrixPerformance.java
+++ b/commons-geometry-examples/examples-jmh/src/main/java/org/apache/commons/geometry/examples/jmh/euclidean/AffineTransformMatrixPerformance.java
@@ -81,7 +81,7 @@ public class AffineTransformMatrixPerformance {
*/
@Setup(Level.Iteration)
public void setup() {
- final UniformRandomProvider rand = RandomSource.create(RandomSource.XO_RO_SHI_RO_128_PP);
+ final UniformRandomProvider rand = RandomSource.XO_RO_SHI_RO_128_PP.create();
array = new double[size];
@@ -109,7 +109,7 @@ public class AffineTransformMatrixPerformance {
/** Set up the input. */
@Setup
public void setup() {
- final UniformRandomProvider rand = RandomSource.create(RandomSource.XO_RO_SHI_RO_128_PP);
+ final UniformRandomProvider rand = RandomSource.XO_RO_SHI_RO_128_PP.create();
transform = AffineTransformMatrix1D.of(BenchmarkUtils.randomDoubleArray(2, rand));
}
@@ -133,7 +133,7 @@ public class AffineTransformMatrixPerformance {
/** Set up the input. */
@Setup
public void setup() {
- final UniformRandomProvider rand = RandomSource.create(RandomSource.XO_RO_SHI_RO_128_PP);
+ final UniformRandomProvider rand = RandomSource.XO_RO_SHI_RO_128_PP.create();
transform = AffineTransformMatrix2D.of(BenchmarkUtils.randomDoubleArray(6, rand));
}
@@ -157,7 +157,7 @@ public class AffineTransformMatrixPerformance {
/** Set up the input. */
@Setup
public void setup() {
- final UniformRandomProvider rand = RandomSource.create(RandomSource.XO_RO_SHI_RO_128_PP);
+ final UniformRandomProvider rand = RandomSource.XO_RO_SHI_RO_128_PP.create();
transform = AffineTransformMatrix3D.of(BenchmarkUtils.randomDoubleArray(12, rand));
}
diff --git a/commons-geometry-examples/examples-jmh/src/main/java/org/apache/commons/geometry/examples/jmh/euclidean/CirclePerformance.java b/commons-geometry-examples/examples-jmh/src/main/java/org/apache/commons/geometry/examples/jmh/euclidean/CirclePerformance.java
index 43c853d..a37e40a 100644
--- a/commons-geometry-examples/examples-jmh/src/main/java/org/apache/commons/geometry/examples/jmh/euclidean/CirclePerformance.java
+++ b/commons-geometry-examples/examples-jmh/src/main/java/org/apache/commons/geometry/examples/jmh/euclidean/CirclePerformance.java
@@ -66,7 +66,7 @@ public class CirclePerformance {
/** Set up the instance for the benchmark. */
@Setup(Level.Iteration)
public void setup() {
- circle = randomCircle(RandomSource.create(RandomSource.XO_RO_SHI_RO_128_PP));
+ circle = randomCircle(RandomSource.XO_RO_SHI_RO_128_PP.create());
}
/** Get the input circle.
@@ -105,7 +105,7 @@ public class CirclePerformance {
/** Set up the instance for the benchmark. */
@Setup(Level.Iteration)
public void setup() {
- final Circle circle = randomCircle(RandomSource.create(RandomSource.XO_RO_SHI_RO_128_PP));
+ final Circle circle = randomCircle(RandomSource.XO_RO_SHI_RO_128_PP.create());
tree = circle.toTree(getSegments());
}
diff --git a/commons-geometry-examples/examples-jmh/src/main/java/org/apache/commons/geometry/examples/jmh/euclidean/SpherePerformance.java b/commons-geometry-examples/examples-jmh/src/main/java/org/apache/commons/geometry/examples/jmh/euclidean/SpherePerformance.java
index c159ce1..5cb12fb 100644
--- a/commons-geometry-examples/examples-jmh/src/main/java/org/apache/commons/geometry/examples/jmh/euclidean/SpherePerformance.java
+++ b/commons-geometry-examples/examples-jmh/src/main/java/org/apache/commons/geometry/examples/jmh/euclidean/SpherePerformance.java
@@ -66,7 +66,7 @@ public class SpherePerformance {
/** Set up the instance for the benchmark. */
@Setup(Level.Iteration)
public void setup() {
- sphere = randomSphere(RandomSource.create(RandomSource.XO_RO_SHI_RO_128_PP));
+ sphere = randomSphere(RandomSource.XO_RO_SHI_RO_128_PP.create());
}
/** Get the input sphere.
@@ -105,7 +105,7 @@ public class SpherePerformance {
/** Set up the instance for the benchmark. */
@Setup(Level.Iteration)
public void setup() {
- final Sphere sphere = randomSphere(RandomSource.create(RandomSource.XO_RO_SHI_RO_128_PP));
+ final Sphere sphere = randomSphere(RandomSource.XO_RO_SHI_RO_128_PP.create());
tree = sphere.toTree(getSubdivisions());
}
diff --git a/commons-geometry-examples/examples-jmh/src/main/java/org/apache/commons/geometry/examples/jmh/euclidean/VectorPerformance.java b/commons-geometry-examples/examples-jmh/src/main/java/org/apache/commons/geometry/examples/jmh/euclidean/VectorPerformance.java
index 27d2638..86efbf2 100644
--- a/commons-geometry-examples/examples-jmh/src/main/java/org/apache/commons/geometry/examples/jmh/euclidean/VectorPerformance.java
+++ b/commons-geometry-examples/examples-jmh/src/main/java/org/apache/commons/geometry/examples/jmh/euclidean/VectorPerformance.java
@@ -114,7 +114,7 @@ public class VectorPerformance {
final double[] values = new double[dimension];
final DoubleSupplier doubleSupplier = createDoubleSupplier(getType(),
- RandomSource.create(RandomSource.XO_RO_SHI_RO_128_PP));
+ RandomSource.XO_RO_SHI_RO_128_PP.create());
for (int i = 0; i < size; ++i) {
for (int j = 0; j < dimension; ++j) {
diff --git a/commons-geometry-hull/src/test/java/org/apache/commons/geometry/hull/euclidean/twod/ConvexHullGenerator2DAbstractTest.java b/commons-geometry-hull/src/test/java/org/apache/commons/geometry/hull/euclidean/twod/ConvexHullGenerator2DAbstractTest.java
index e30d5cc..252c977 100644
--- a/commons-geometry-hull/src/test/java/org/apache/commons/geometry/hull/euclidean/twod/ConvexHullGenerator2DAbstractTest.java
+++ b/commons-geometry-hull/src/test/java/org/apache/commons/geometry/hull/euclidean/twod/ConvexHullGenerator2DAbstractTest.java
@@ -58,7 +58,7 @@ public abstract class ConvexHullGenerator2DAbstractTest {
public void setUp() {
// by default, do not include collinear points
generator = createConvexHullGenerator(false);
- random = RandomSource.create(RandomSource.MT, 10);
+ random = RandomSource.MT.create(10);
}
// ------------------------------------------------------------------------------