You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by ah...@apache.org on 2022/05/26 16:39:04 UTC
[commons-numbers] 02/02: Replace deprecated RandomSource.create
This is an automated email from the ASF dual-hosted git repository.
aherbert pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-numbers.git
commit f41eefd6ed381e4b62496a9bfde1d874e6b141cf
Author: Alex Herbert <ah...@apache.org>
AuthorDate: Thu May 26 17:38:41 2022 +0100
Replace deprecated RandomSource.create
---
.../commons/numbers/examples/jmh/complex/ComplexPerformance.java | 6 +++---
.../commons/numbers/examples/jmh/core/DoubleSplitPerformance.java | 6 +++---
.../examples/jmh/core/EuclideanNormAlgorithmPerformance.java | 2 +-
.../numbers/examples/jmh/core/LinearCombinationPerformance.java | 2 +-
.../apache/commons/numbers/examples/jmh/core/NormPerformance.java | 2 +-
.../commons/numbers/examples/jmh/core/StickySumPerformance.java | 2 +-
.../apache/commons/numbers/examples/jmh/core/SumPerformance.java | 2 +-
.../numbers/examples/jmh/core/EuclideanNormAccuracyTest.java | 2 +-
.../numbers/examples/jmh/core/LinearCombinationAccuracyTest.java | 4 ++--
.../commons/numbers/examples/jmh/core/LinearCombinationsTest.java | 2 +-
10 files changed, 15 insertions(+), 15 deletions(-)
diff --git a/commons-numbers-examples/examples-jmh/src/main/java/org/apache/commons/numbers/examples/jmh/complex/ComplexPerformance.java b/commons-numbers-examples/examples-jmh/src/main/java/org/apache/commons/numbers/examples/jmh/complex/ComplexPerformance.java
index 10398954..4404ddf7 100644
--- a/commons-numbers-examples/examples-jmh/src/main/java/org/apache/commons/numbers/examples/jmh/complex/ComplexPerformance.java
+++ b/commons-numbers-examples/examples-jmh/src/main/java/org/apache/commons/numbers/examples/jmh/complex/ComplexPerformance.java
@@ -112,7 +112,7 @@ public class ComplexPerformance {
*/
@Setup
public void setup() {
- numbers = createNumbers(RandomSource.create(RandomSource.XO_RO_SHI_RO_128_PP));
+ numbers = createNumbers(RandomSource.XO_RO_SHI_RO_128_PP.create());
}
/**
@@ -170,7 +170,7 @@ public class ComplexPerformance {
@Setup
public void setup() {
// Do not call super.setup() so we recycle the RNG and avoid duplicates
- final UniformRandomProvider rng = RandomSource.create(RandomSource.XO_RO_SHI_RO_128_PP);
+ final UniformRandomProvider rng = RandomSource.XO_RO_SHI_RO_128_PP.create();
numbers = createNumbers(rng);
numbers2 = createNumbers(rng);
}
@@ -200,7 +200,7 @@ public class ComplexPerformance {
@Setup
public void setup() {
// Do not call super.setup() so we recycle the RNG and avoid duplicates
- final UniformRandomProvider rng = RandomSource.create(RandomSource.XO_RO_SHI_RO_128_PP);
+ final UniformRandomProvider rng = RandomSource.XO_RO_SHI_RO_128_PP.create();
numbers = createNumbers(rng);
numbers2 = Arrays.stream(createNumbers(rng)).mapToDouble(Complex::real).toArray();
}
diff --git a/commons-numbers-examples/examples-jmh/src/main/java/org/apache/commons/numbers/examples/jmh/core/DoubleSplitPerformance.java b/commons-numbers-examples/examples-jmh/src/main/java/org/apache/commons/numbers/examples/jmh/core/DoubleSplitPerformance.java
index f9136cf2..0cefa627 100644
--- a/commons-numbers-examples/examples-jmh/src/main/java/org/apache/commons/numbers/examples/jmh/core/DoubleSplitPerformance.java
+++ b/commons-numbers-examples/examples-jmh/src/main/java/org/apache/commons/numbers/examples/jmh/core/DoubleSplitPerformance.java
@@ -120,7 +120,7 @@ public class DoubleSplitPerformance {
*/
@Setup
public void setup() {
- final UniformRandomProvider rng = RandomSource.create(RandomSource.XO_RO_SHI_RO_1024_PP);
+ final UniformRandomProvider rng = RandomSource.XO_RO_SHI_RO_1024_PP.create();
a = new double[size];
for (int i = 0; i < size; i++) {
long bits = rng.nextLong() & SIGN_MATISSA_MASK;
@@ -193,7 +193,7 @@ public class DoubleSplitPerformance {
assert Double.isInfinite(d * d) : "Product of big numbers does not overflow";
final long expBig = Double.doubleToRawLongBits(d);
- final UniformRandomProvider rng = RandomSource.create(RandomSource.XO_RO_SHI_RO_1024_PP);
+ final UniformRandomProvider rng = RandomSource.XO_RO_SHI_RO_1024_PP.create();
a = new double[size * 2];
for (int i = 0; i < a.length; i++) {
long bits = rng.nextLong() & SIGN_MATISSA_MASK;
@@ -246,7 +246,7 @@ public class DoubleSplitPerformance {
*/
@Setup
public void setup() {
- final UniformRandomProvider rng = RandomSource.create(RandomSource.XO_RO_SHI_RO_1024_PP);
+ final UniformRandomProvider rng = RandomSource.XO_RO_SHI_RO_1024_PP.create();
a = new double[size];
for (int i = 0; i < size; i++) {
// Value in (-1, 1)
diff --git a/commons-numbers-examples/examples-jmh/src/main/java/org/apache/commons/numbers/examples/jmh/core/EuclideanNormAlgorithmPerformance.java b/commons-numbers-examples/examples-jmh/src/main/java/org/apache/commons/numbers/examples/jmh/core/EuclideanNormAlgorithmPerformance.java
index 95b7d841..fa6e9af3 100644
--- a/commons-numbers-examples/examples-jmh/src/main/java/org/apache/commons/numbers/examples/jmh/core/EuclideanNormAlgorithmPerformance.java
+++ b/commons-numbers-examples/examples-jmh/src/main/java/org/apache/commons/numbers/examples/jmh/core/EuclideanNormAlgorithmPerformance.java
@@ -88,7 +88,7 @@ public class EuclideanNormAlgorithmPerformance {
*/
@Setup
public void createVectors() {
- final UniformRandomProvider rng = RandomSource.create(RandomSource.XO_RO_SHI_RO_1024_PP);
+ final UniformRandomProvider rng = RandomSource.XO_RO_SHI_RO_1024_PP.create();
int minExp;
int maxExp;
diff --git a/commons-numbers-examples/examples-jmh/src/main/java/org/apache/commons/numbers/examples/jmh/core/LinearCombinationPerformance.java b/commons-numbers-examples/examples-jmh/src/main/java/org/apache/commons/numbers/examples/jmh/core/LinearCombinationPerformance.java
index b0a3a590..c65dc6ce 100644
--- a/commons-numbers-examples/examples-jmh/src/main/java/org/apache/commons/numbers/examples/jmh/core/LinearCombinationPerformance.java
+++ b/commons-numbers-examples/examples-jmh/src/main/java/org/apache/commons/numbers/examples/jmh/core/LinearCombinationPerformance.java
@@ -129,7 +129,7 @@ public class LinearCombinationPerformance {
@Setup
public void setup() {
final UniformRandomProvider rng =
- RandomSource.create(RandomSource.XO_RO_SHI_RO_1024_PP, SEED);
+ RandomSource.XO_RO_SHI_RO_1024_PP.create(SEED);
// Use the ill conditioned data generation method.
// This requires an array of at least 6.
final int n = Math.max(6, getLength());
diff --git a/commons-numbers-examples/examples-jmh/src/main/java/org/apache/commons/numbers/examples/jmh/core/NormPerformance.java b/commons-numbers-examples/examples-jmh/src/main/java/org/apache/commons/numbers/examples/jmh/core/NormPerformance.java
index c6475caa..402f120d 100644
--- a/commons-numbers-examples/examples-jmh/src/main/java/org/apache/commons/numbers/examples/jmh/core/NormPerformance.java
+++ b/commons-numbers-examples/examples-jmh/src/main/java/org/apache/commons/numbers/examples/jmh/core/NormPerformance.java
@@ -81,7 +81,7 @@ public class NormPerformance {
*/
@Setup
public void createVectors() {
- final UniformRandomProvider rng = RandomSource.create(RandomSource.XO_RO_SHI_RO_1024_PP);
+ final UniformRandomProvider rng = RandomSource.XO_RO_SHI_RO_1024_PP.create();
vectors = new double[samples][];
for (int i = 0; i < vectors.length; ++i) {
diff --git a/commons-numbers-examples/examples-jmh/src/main/java/org/apache/commons/numbers/examples/jmh/core/StickySumPerformance.java b/commons-numbers-examples/examples-jmh/src/main/java/org/apache/commons/numbers/examples/jmh/core/StickySumPerformance.java
index 6567a2c0..49e0ba87 100644
--- a/commons-numbers-examples/examples-jmh/src/main/java/org/apache/commons/numbers/examples/jmh/core/StickySumPerformance.java
+++ b/commons-numbers-examples/examples-jmh/src/main/java/org/apache/commons/numbers/examples/jmh/core/StickySumPerformance.java
@@ -103,7 +103,7 @@ public class StickySumPerformance {
*/
@Setup
public void setup() {
- final UniformRandomProvider rng = RandomSource.create(RandomSource.XO_RO_SHI_RO_1024_PP);
+ final UniformRandomProvider rng = RandomSource.XO_RO_SHI_RO_1024_PP.create();
a = new double[size * 2];
// Report on the dataset
int nonZero = 0;
diff --git a/commons-numbers-examples/examples-jmh/src/main/java/org/apache/commons/numbers/examples/jmh/core/SumPerformance.java b/commons-numbers-examples/examples-jmh/src/main/java/org/apache/commons/numbers/examples/jmh/core/SumPerformance.java
index 0dd67320..cd4c45e5 100644
--- a/commons-numbers-examples/examples-jmh/src/main/java/org/apache/commons/numbers/examples/jmh/core/SumPerformance.java
+++ b/commons-numbers-examples/examples-jmh/src/main/java/org/apache/commons/numbers/examples/jmh/core/SumPerformance.java
@@ -100,7 +100,7 @@ public class SumPerformance {
/** Create the input arrays for the instance. */
@Setup
public void createArrays() {
- final UniformRandomProvider rng = RandomSource.create(RandomSource.XO_RO_SHI_RO_1024_PP, SEED);
+ final UniformRandomProvider rng = RandomSource.XO_RO_SHI_RO_1024_PP.create(SEED);
a = new double[samples][];
b = new double[samples][];
diff --git a/commons-numbers-examples/examples-jmh/src/test/java/org/apache/commons/numbers/examples/jmh/core/EuclideanNormAccuracyTest.java b/commons-numbers-examples/examples-jmh/src/test/java/org/apache/commons/numbers/examples/jmh/core/EuclideanNormAccuracyTest.java
index 8981c02c..ce8bae33 100644
--- a/commons-numbers-examples/examples-jmh/src/test/java/org/apache/commons/numbers/examples/jmh/core/EuclideanNormAccuracyTest.java
+++ b/commons-numbers-examples/examples-jmh/src/test/java/org/apache/commons/numbers/examples/jmh/core/EuclideanNormAccuracyTest.java
@@ -45,7 +45,7 @@ class EuclideanNormAccuracyTest {
@Test
@Disabled("This method is used to output a report of the accuracy of implementations.")
void reportUlpErrors() throws IOException {
- final UniformRandomProvider rng = RandomSource.create(RandomSource.XO_RO_SHI_RO_1024_PP);
+ final UniformRandomProvider rng = RandomSource.XO_RO_SHI_RO_1024_PP.create();
final EuclideanNormEvaluator eval = new EuclideanNormEvaluator();
eval.addMethod("direct", new EuclideanNormAlgorithms.Direct())
diff --git a/commons-numbers-examples/examples-jmh/src/test/java/org/apache/commons/numbers/examples/jmh/core/LinearCombinationAccuracyTest.java b/commons-numbers-examples/examples-jmh/src/test/java/org/apache/commons/numbers/examples/jmh/core/LinearCombinationAccuracyTest.java
index 4dec2e81..3df198b5 100644
--- a/commons-numbers-examples/examples-jmh/src/test/java/org/apache/commons/numbers/examples/jmh/core/LinearCombinationAccuracyTest.java
+++ b/commons-numbers-examples/examples-jmh/src/test/java/org/apache/commons/numbers/examples/jmh/core/LinearCombinationAccuracyTest.java
@@ -88,7 +88,7 @@ class LinearCombinationAccuracyTest {
final double[] x = new double[LENGTH];
final double[] y = new double[LENGTH];
// Fixed seed to consistency
- final UniformRandomProvider rng = RandomSource.create(RandomSource.XO_RO_SHI_RO_1024_PP, 9283746);
+ final UniformRandomProvider rng = RandomSource.XO_RO_SHI_RO_1024_PP.create(9283746);
// Use an average as the actual condition number of the generated dot product
// may not be the requested condition number. It will average out at the desired
@@ -137,7 +137,7 @@ class LinearCombinationAccuracyTest {
final double logB = Math.log(1e120);
final ArrayList<double[]> data = new ArrayList<>(samples);
- final UniformRandomProvider rng = RandomSource.create(RandomSource.XO_RO_SHI_RO_1024_PP);
+ final UniformRandomProvider rng = RandomSource.XO_RO_SHI_RO_1024_PP.create();
final double[] x = new double[LENGTH];
final double[] y = new double[LENGTH];
final double[] cc = new double[1];
diff --git a/commons-numbers-examples/examples-jmh/src/test/java/org/apache/commons/numbers/examples/jmh/core/LinearCombinationsTest.java b/commons-numbers-examples/examples-jmh/src/test/java/org/apache/commons/numbers/examples/jmh/core/LinearCombinationsTest.java
index 81be903f..776726e6 100644
--- a/commons-numbers-examples/examples-jmh/src/test/java/org/apache/commons/numbers/examples/jmh/core/LinearCombinationsTest.java
+++ b/commons-numbers-examples/examples-jmh/src/test/java/org/apache/commons/numbers/examples/jmh/core/LinearCombinationsTest.java
@@ -441,7 +441,7 @@ class LinearCombinationsTest {
@Test
void testSumZero() {
// Fixed seed for stability
- final UniformRandomProvider rng = RandomSource.create(RandomSource.XO_RO_SHI_RO_128_PP, 876543L);
+ final UniformRandomProvider rng = RandomSource.XO_RO_SHI_RO_128_PP.create(876543L);
final int size = 10;
// Create random doublets of pairs of numbers that sum to 1 or -1.
for (int length = 4; length <= 12; length += 4) {