@@ -108,7 +108,7 @@ public class GeometricMean extends AbstractStorelessUnivariateStatistic implemen
@Override
public double getResult() {
if (sumOfLogs.getN() > 0) {
- return FastMath.exp(sumOfLogs.getResult() / sumOfLogs.getN());
+ return AccurateMath.exp(sumOfLogs.getResult() / sumOfLogs.getN());
} else {
return Double.NaN;
}
@@ -141,7 +141,7 @@ public class GeometricMean extends AbstractStorelessUnivariateStatistic implemen
@Override
public double evaluate(final double[] values, final int begin, final int length)
throws MathIllegalArgumentException {
- return FastMath.exp(sumOfLogs.evaluate(values, begin, length) / length);
+ return AccurateMath.exp(sumOfLogs.evaluate(values, begin, length) / length);
}
/**
diff --git a/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/stat/descriptive/moment/Kurtosis.java b/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/stat/descriptive/moment/Kurtosis.java
index 2791b9ff9..2d189461a 100644
--- a/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/stat/descriptive/moment/Kurtosis.java
+++ b/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/stat/descriptive/moment/Kurtosis.java
@@ -21,8 +21,8 @@ import java.io.Serializable;
import org.apache.commons.math4.legacy.exception.MathIllegalArgumentException;
import org.apache.commons.math4.legacy.exception.NullArgumentException;
import org.apache.commons.math4.legacy.stat.descriptive.AbstractStorelessUnivariateStatistic;
-import org.apache.commons.math4.legacy.util.FastMath;
-import org.apache.commons.math4.legacy.util.MathArrays;
+import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
+import org.apache.commons.math4.legacy.core.MathArrays;
/**
@@ -171,15 +171,15 @@ public class Kurtosis extends AbstractStorelessUnivariateStatistic implements S
Variance variance = new Variance();
variance.incrementAll(values, begin, length);
double mean = variance.moment.m1;
- double stdDev = FastMath.sqrt(variance.getResult());
+ double stdDev = AccurateMath.sqrt(variance.getResult());
// Sum the ^4 of the distance from the mean divided by the
// standard deviation
double accum3 = 0.0;
for (int i = begin; i < begin + length; i++) {
- accum3 += FastMath.pow(values[i] - mean, 4.0);
+ accum3 += AccurateMath.pow(values[i] - mean, 4.0);
}
- accum3 /= FastMath.pow(stdDev, 4.0d);
+ accum3 /= AccurateMath.pow(stdDev, 4.0d);
// Get N
double n0 = length;
@@ -187,7 +187,7 @@ public class Kurtosis extends AbstractStorelessUnivariateStatistic implements S
double coefficientOne =
(n0 * (n0 + 1)) / ((n0 - 1) * (n0 - 2) * (n0 - 3));
double termTwo =
- (3 * FastMath.pow(n0 - 1, 2.0)) / ((n0 - 2) * (n0 - 3));
+ (3 * AccurateMath.pow(n0 - 1, 2.0)) / ((n0 - 2) * (n0 - 3));
// Calculate kurtosis
kurt = (coefficientOne * accum3) - termTwo;
diff --git a/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/stat/descriptive/moment/Mean.java b/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/stat/descriptive/moment/Mean.java
index 82b23d2c7..91de459c4 100644
--- a/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/stat/descriptive/moment/Mean.java
+++ b/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/stat/descriptive/moment/Mean.java
@@ -23,7 +23,7 @@ import org.apache.commons.math4.legacy.exception.NullArgumentException;
import org.apache.commons.math4.legacy.stat.descriptive.AbstractStorelessUnivariateStatistic;
import org.apache.commons.math4.legacy.stat.descriptive.WeightedEvaluation;
import org.apache.commons.math4.legacy.stat.descriptive.summary.Sum;
-import org.apache.commons.math4.legacy.util.MathArrays;
+import org.apache.commons.math4.legacy.core.MathArrays;
/**
* Computes the arithmetic mean of a set of values. Uses the definitional
diff --git a/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/stat/descriptive/moment/SemiVariance.java b/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/stat/descriptive/moment/SemiVariance.java
index f590a841d..475a68be6 100644
--- a/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/stat/descriptive/moment/SemiVariance.java
+++ b/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/stat/descriptive/moment/SemiVariance.java
@@ -22,7 +22,7 @@ import java.io.Serializable;
import org.apache.commons.math4.legacy.exception.MathIllegalArgumentException;
import org.apache.commons.math4.legacy.exception.NullArgumentException;
import org.apache.commons.math4.legacy.stat.descriptive.AbstractUnivariateStatistic;
-import org.apache.commons.math4.legacy.util.MathArrays;
+import org.apache.commons.math4.legacy.core.MathArrays;
/**
* Computes the semivariance of a set of values with respect to a given cutoff value.
diff --git a/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/stat/descriptive/moment/Skewness.java b/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/stat/descriptive/moment/Skewness.java
index 204924517..7945614c7 100644
--- a/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/stat/descriptive/moment/Skewness.java
+++ b/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/stat/descriptive/moment/Skewness.java
@@ -21,8 +21,8 @@ import java.io.Serializable;
import org.apache.commons.math4.legacy.exception.MathIllegalArgumentException;
import org.apache.commons.math4.legacy.exception.NullArgumentException;
import org.apache.commons.math4.legacy.stat.descriptive.AbstractStorelessUnivariateStatistic;
-import org.apache.commons.math4.legacy.util.FastMath;
-import org.apache.commons.math4.legacy.util.MathArrays;
+import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
+import org.apache.commons.math4.legacy.core.MathArrays;
/**
* Computes the skewness of the available values.
@@ -120,7 +120,7 @@ public class Skewness extends AbstractStorelessUnivariateStatistic implements Se
} else {
double n0 = moment.getN();
return (n0 * moment.m3) /
- ((n0 - 1) * (n0 -2) * FastMath.sqrt(variance) * variance);
+ ((n0 - 1) * (n0 -2) * AccurateMath.sqrt(variance) * variance);
}
}
@@ -186,7 +186,7 @@ public class Skewness extends AbstractStorelessUnivariateStatistic implements Se
final double d = values[i] - m;
accum3 += d * d * d;
}
- accum3 /= variance * FastMath.sqrt(variance);
+ accum3 /= variance * AccurateMath.sqrt(variance);
// Get N
double n0 = length;
diff --git a/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/stat/descriptive/moment/StandardDeviation.java b/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/stat/descriptive/moment/StandardDeviation.java
index cae7c12ec..b747f77c8 100644
--- a/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/stat/descriptive/moment/StandardDeviation.java
+++ b/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/stat/descriptive/moment/StandardDeviation.java
@@ -21,7 +21,7 @@ import java.io.Serializable;
import org.apache.commons.math4.legacy.exception.MathIllegalArgumentException;
import org.apache.commons.math4.legacy.exception.NullArgumentException;
import org.apache.commons.math4.legacy.stat.descriptive.AbstractStorelessUnivariateStatistic;
-import org.apache.commons.math4.legacy.util.FastMath;
+import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
/**
* Computes the sample standard deviation. The standard deviation
@@ -125,7 +125,7 @@ public class StandardDeviation extends AbstractStorelessUnivariateStatistic
*/
@Override
public double getResult() {
- return FastMath.sqrt(variance.getResult());
+ return AccurateMath.sqrt(variance.getResult());
}
/**
@@ -152,7 +152,7 @@ public class StandardDeviation extends AbstractStorelessUnivariateStatistic
*/
@Override
public double evaluate(final double[] values) throws MathIllegalArgumentException {
- return FastMath.sqrt(variance.evaluate(values));
+ return AccurateMath.sqrt(variance.evaluate(values));
}
/**
@@ -176,7 +176,7 @@ public class StandardDeviation extends AbstractStorelessUnivariateStatistic
@Override
public double evaluate(final double[] values, final int begin, final int length)
throws MathIllegalArgumentException {
- return FastMath.sqrt(variance.evaluate(values, begin, length));
+ return AccurateMath.sqrt(variance.evaluate(values, begin, length));
}
/**
@@ -205,7 +205,7 @@ public class StandardDeviation extends AbstractStorelessUnivariateStatistic
*/
public double evaluate(final double[] values, final double mean,
final int begin, final int length) throws MathIllegalArgumentException {
- return FastMath.sqrt(variance.evaluate(values, mean, begin, length));
+ return AccurateMath.sqrt(variance.evaluate(values, mean, begin, length));
}
/**
@@ -231,7 +231,7 @@ public class StandardDeviation extends AbstractStorelessUnivariateStatistic
*/
public double evaluate(final double[] values, final double mean)
throws MathIllegalArgumentException {
- return FastMath.sqrt(variance.evaluate(values, mean));
+ return AccurateMath.sqrt(variance.evaluate(values, mean));
}
/**
diff --git a/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/stat/descriptive/moment/Variance.java b/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/stat/descriptive/moment/Variance.java
index a58810a8b..974051863 100644
--- a/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/stat/descriptive/moment/Variance.java
+++ b/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/stat/descriptive/moment/Variance.java
@@ -23,7 +23,7 @@ import org.apache.commons.math4.legacy.exception.NullArgumentException;
import org.apache.commons.math4.legacy.exception.util.LocalizedFormats;
import org.apache.commons.math4.legacy.stat.descriptive.AbstractStorelessUnivariateStatistic;
import org.apache.commons.math4.legacy.stat.descriptive.WeightedEvaluation;
-import org.apache.commons.math4.legacy.util.MathArrays;
+import org.apache.commons.math4.legacy.core.MathArrays;
/**
* Computes the variance of the available values. By default, the unbiased
diff --git a/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/stat/descriptive/rank/CentralPivotingStrategy.java b/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/stat/descriptive/rank/CentralPivotingStrategy.java
index 7632e3221..e6e0d2ad4 100644
--- a/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/stat/descriptive/rank/CentralPivotingStrategy.java
+++ b/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/stat/descriptive/rank/CentralPivotingStrategy.java
@@ -19,7 +19,7 @@ package org.apache.commons.math4.legacy.stat.descriptive.rank;
import java.io.Serializable;
import org.apache.commons.math4.legacy.exception.MathIllegalArgumentException;
-import org.apache.commons.math4.legacy.util.MathArrays;
+import org.apache.commons.math4.legacy.core.MathArrays;
/**
* A mid point strategy based on the average of begin and end indices.
diff --git a/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/stat/descriptive/rank/KthSelector.java b/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/stat/descriptive/rank/KthSelector.java
index 3b764a7ac..7e4877698 100644
--- a/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/stat/descriptive/rank/KthSelector.java
+++ b/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/stat/descriptive/rank/KthSelector.java
@@ -20,7 +20,7 @@ import java.io.Serializable;
import java.util.Arrays;
import org.apache.commons.math4.legacy.exception.NullArgumentException;
-import org.apache.commons.math4.legacy.util.FastMath;
+import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
/**
* A Simple Kth selector implementation to pick up the
@@ -101,11 +101,11 @@ public class KthSelector implements Serializable {
} else if (k < pivot) {
// the element is in the left partition
end = pivot;
- node = FastMath.min(2 * node + 1, usePivotsHeap ? pivotsHeap.length : end);
+ node = AccurateMath.min(2 * node + 1, usePivotsHeap ? pivotsHeap.length : end);
} else {
// the element is in the right partition
begin = pivot + 1;
- node = FastMath.min(2 * node + 2, usePivotsHeap ? pivotsHeap.length : end);
+ node = AccurateMath.min(2 * node + 2, usePivotsHeap ? pivotsHeap.length : end);
}
}
Arrays.sort(work, begin, end);
diff --git a/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/stat/descriptive/rank/Max.java b/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/stat/descriptive/rank/Max.java
index 0e4f85e00..b3b7a90e4 100644
--- a/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/stat/descriptive/rank/Max.java
+++ b/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/stat/descriptive/rank/Max.java
@@ -21,7 +21,7 @@ import java.io.Serializable;
import org.apache.commons.math4.legacy.exception.MathIllegalArgumentException;
import org.apache.commons.math4.legacy.exception.NullArgumentException;
import org.apache.commons.math4.legacy.stat.descriptive.AbstractStorelessUnivariateStatistic;
-import org.apache.commons.math4.legacy.util.MathArrays;
+import org.apache.commons.math4.legacy.core.MathArrays;
/**
* Returns the maximum of the available values.
diff --git a/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/stat/descriptive/rank/MedianOf3PivotingStrategy.java b/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/stat/descriptive/rank/MedianOf3PivotingStrategy.java
index 7d2842f40..671ccca43 100644
--- a/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/stat/descriptive/rank/MedianOf3PivotingStrategy.java
+++ b/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/stat/descriptive/rank/MedianOf3PivotingStrategy.java
@@ -19,7 +19,7 @@ package org.apache.commons.math4.legacy.stat.descriptive.rank;
import java.io.Serializable;
import org.apache.commons.math4.legacy.exception.MathIllegalArgumentException;
-import org.apache.commons.math4.legacy.util.MathArrays;
+import org.apache.commons.math4.legacy.core.MathArrays;
/**
diff --git a/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/stat/descriptive/rank/Min.java b/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/stat/descriptive/rank/Min.java
index 0ce7b45d5..760ba36d3 100644
--- a/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/stat/descriptive/rank/Min.java
+++ b/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/stat/descriptive/rank/Min.java
@@ -21,7 +21,7 @@ import java.io.Serializable;
import org.apache.commons.math4.legacy.exception.MathIllegalArgumentException;
import org.apache.commons.math4.legacy.exception.NullArgumentException;
import org.apache.commons.math4.legacy.stat.descriptive.AbstractStorelessUnivariateStatistic;
-import org.apache.commons.math4.legacy.util.MathArrays;
+import org.apache.commons.math4.legacy.core.MathArrays;
/**
* Returns the minimum of the available values.
diff --git a/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/stat/descriptive/rank/PSquarePercentile.java b/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/stat/descriptive/rank/PSquarePercentile.java
index ee06b41b3..29a54c6d5 100644
--- a/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/stat/descriptive/rank/PSquarePercentile.java
+++ b/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/stat/descriptive/rank/PSquarePercentile.java
@@ -36,7 +36,7 @@ import org.apache.commons.math4.legacy.exception.NullArgumentException;
import org.apache.commons.math4.legacy.exception.util.LocalizedFormats;
import org.apache.commons.math4.legacy.stat.descriptive.AbstractStorelessUnivariateStatistic;
import org.apache.commons.math4.legacy.stat.descriptive.StorelessUnivariateStatistic;
-import org.apache.commons.math4.legacy.util.MathArrays;
+import org.apache.commons.math4.legacy.core.MathArrays;
import org.apache.commons.numbers.core.Precision;
/**
diff --git a/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/stat/descriptive/rank/Percentile.java b/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/stat/descriptive/rank/Percentile.java
index 8fe9c5136..777fce6dd 100644
--- a/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/stat/descriptive/rank/Percentile.java
+++ b/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/stat/descriptive/rank/Percentile.java
@@ -28,8 +28,8 @@ import org.apache.commons.math4.legacy.exception.OutOfRangeException;
import org.apache.commons.math4.legacy.exception.util.LocalizedFormats;
import org.apache.commons.math4.legacy.stat.descriptive.AbstractUnivariateStatistic;
import org.apache.commons.math4.legacy.stat.ranking.NaNStrategy;
-import org.apache.commons.math4.legacy.util.FastMath;
-import org.apache.commons.math4.legacy.util.MathArrays;
+import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
+import org.apache.commons.math4.legacy.core.MathArrays;
import org.apache.commons.numbers.core.Precision;
/**
@@ -964,7 +964,7 @@ public class Percentile extends AbstractUnivariateStatistic implements Serializa
protected double estimate(final double[] values,
final int[] pivotsHeap, final double pos,
final int length, final KthSelector selector) {
- return super.estimate(values, pivotsHeap, FastMath.ceil(pos - 0.5), length, selector);
+ return super.estimate(values, pivotsHeap, AccurateMath.ceil(pos - 0.5), length, selector);
}
@Override
public double evaluate(final double[] work, final double[] sampleWeights,
@@ -1001,9 +1001,9 @@ public class Percentile extends AbstractUnivariateStatistic implements Serializa
final int[] pivotsHeap, final double pos,
final int length, final KthSelector selector) {
final double low =
- super.estimate(values, pivotsHeap, FastMath.ceil(pos - 0.5), length, selector);
+ super.estimate(values, pivotsHeap, AccurateMath.ceil(pos - 0.5), length, selector);
final double high =
- super.estimate(values, pivotsHeap,FastMath.floor(pos + 0.5), length, selector);
+ super.estimate(values, pivotsHeap,AccurateMath.floor(pos + 0.5), length, selector);
return (low + high) / 2;
}
@Override
@@ -1025,7 +1025,7 @@ public class Percentile extends AbstractUnivariateStatistic implements Serializa
protected double index(final double p, final int length) {
final double minLimit = 1d/2 / length;
return Double.compare(p, minLimit) <= 0 ?
- 0 : FastMath.rint(length * p);
+ 0 : AccurateMath.rint(length * p);
}
@Override
public double evaluate(final double[] work, final double[] sampleWeights,
@@ -1271,7 +1271,7 @@ public class Percentile extends AbstractUnivariateStatistic implements Serializa
final double pos, final int length,
final KthSelector selector) {
- final double fpos = FastMath.floor(pos);
+ final double fpos = AccurateMath.floor(pos);
final int intPos = (int) fpos;
final double dif = pos - fpos;
diff --git a/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/stat/descriptive/rank/RandomPivotingStrategy.java b/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/stat/descriptive/rank/RandomPivotingStrategy.java
index 279738f9e..70efe5ff1 100644
--- a/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/stat/descriptive/rank/RandomPivotingStrategy.java
+++ b/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/stat/descriptive/rank/RandomPivotingStrategy.java
@@ -21,7 +21,7 @@ import java.io.IOException;
import java.io.ObjectOutputStream;
import java.io.ObjectInputStream;
import org.apache.commons.math4.legacy.exception.MathIllegalArgumentException;
-import org.apache.commons.math4.legacy.util.MathArrays;
+import org.apache.commons.math4.legacy.core.MathArrays;
import org.apache.commons.rng.RestorableUniformRandomProvider;
import org.apache.commons.rng.simple.RandomSource;
import org.apache.commons.rng.core.RandomProviderDefaultState;
diff --git a/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/stat/descriptive/summary/Product.java b/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/stat/descriptive/summary/Product.java
index 2ac140a7e..cd697fe32 100644
--- a/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/stat/descriptive/summary/Product.java
+++ b/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/stat/descriptive/summary/Product.java
@@ -22,8 +22,8 @@ import org.apache.commons.math4.legacy.exception.MathIllegalArgumentException;
import org.apache.commons.math4.legacy.exception.NullArgumentException;
import org.apache.commons.math4.legacy.stat.descriptive.AbstractStorelessUnivariateStatistic;
import org.apache.commons.math4.legacy.stat.descriptive.WeightedEvaluation;
-import org.apache.commons.math4.legacy.util.FastMath;
-import org.apache.commons.math4.legacy.util.MathArrays;
+import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
+import org.apache.commons.math4.legacy.core.MathArrays;
/**
* Returns the product of the available values.
@@ -165,7 +165,7 @@ public class Product extends AbstractStorelessUnivariateStatistic implements Ser
if (MathArrays.verifyValues(values, weights, begin, length, true)) {
product = 1.0;
for (int i = begin; i < begin + length; i++) {
- product *= FastMath.pow(values[i], weights[i]);
+ product *= AccurateMath.pow(values[i], weights[i]);
}
}
return product;
diff --git a/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/stat/descriptive/summary/Sum.java b/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/stat/descriptive/summary/Sum.java
index fc8b72388..ecb102bff 100644
--- a/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/stat/descriptive/summary/Sum.java
+++ b/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/stat/descriptive/summary/Sum.java
@@ -21,7 +21,7 @@ import java.io.Serializable;
import org.apache.commons.math4.legacy.exception.MathIllegalArgumentException;
import org.apache.commons.math4.legacy.exception.NullArgumentException;
import org.apache.commons.math4.legacy.stat.descriptive.AbstractStorelessUnivariateStatistic;
-import org.apache.commons.math4.legacy.util.MathArrays;
+import org.apache.commons.math4.legacy.core.MathArrays;
/**
diff --git a/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/stat/descriptive/summary/SumOfLogs.java b/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/stat/descriptive/summary/SumOfLogs.java
index dd709eb73..1b8832a74 100644
--- a/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/stat/descriptive/summary/SumOfLogs.java
+++ b/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/stat/descriptive/summary/SumOfLogs.java
@@ -21,13 +21,13 @@ import java.io.Serializable;
import org.apache.commons.math4.legacy.exception.MathIllegalArgumentException;
import org.apache.commons.math4.legacy.exception.NullArgumentException;
import org.apache.commons.math4.legacy.stat.descriptive.AbstractStorelessUnivariateStatistic;
-import org.apache.commons.math4.legacy.util.FastMath;
-import org.apache.commons.math4.legacy.util.MathArrays;
+import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
+import org.apache.commons.math4.legacy.core.MathArrays;
/**
* Returns the sum of the natural logs for this collection of values.
*
- * Uses {@link org.apache.commons.math4.legacy.util.FastMath#log(double)} to compute the logs.
+ * Uses {@link org.apache.commons.math4.legacy.core.jdkmath.AccurateMath#log(double)} to compute the logs.
* Therefore,
*
* - If any of values are < 0, the result is
NaN.
@@ -81,7 +81,7 @@ public class SumOfLogs extends AbstractStorelessUnivariateStatistic implements S
*/
@Override
public void increment(final double d) {
- value += FastMath.log(d);
+ value += AccurateMath.log(d);
n++;
}
@@ -135,7 +135,7 @@ public class SumOfLogs extends AbstractStorelessUnivariateStatistic implements S
if (MathArrays.verifyValues(values, begin, length, true)) {
sumLog = 0.0;
for (int i = begin; i < begin + length; i++) {
- sumLog += FastMath.log(values[i]);
+ sumLog += AccurateMath.log(values[i]);
}
}
return sumLog;
diff --git a/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/stat/descriptive/summary/SumOfSquares.java b/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/stat/descriptive/summary/SumOfSquares.java
index a0d3eeb45..f1c15fd4d 100644
--- a/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/stat/descriptive/summary/SumOfSquares.java
+++ b/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/stat/descriptive/summary/SumOfSquares.java
@@ -21,7 +21,7 @@ import java.io.Serializable;
import org.apache.commons.math4.legacy.exception.MathIllegalArgumentException;
import org.apache.commons.math4.legacy.exception.NullArgumentException;
import org.apache.commons.math4.legacy.stat.descriptive.AbstractStorelessUnivariateStatistic;
-import org.apache.commons.math4.legacy.util.MathArrays;
+import org.apache.commons.math4.legacy.core.MathArrays;
/**
* Returns the sum of the squares of the available values.
diff --git a/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/stat/inference/ChiSquareTest.java b/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/stat/inference/ChiSquareTest.java
index ccb94742e..ee6f4faf9 100644
--- a/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/stat/inference/ChiSquareTest.java
+++ b/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/stat/inference/ChiSquareTest.java
@@ -25,8 +25,8 @@ import org.apache.commons.math4.legacy.exception.NullArgumentException;
import org.apache.commons.math4.legacy.exception.OutOfRangeException;
import org.apache.commons.math4.legacy.exception.ZeroException;
import org.apache.commons.math4.legacy.exception.util.LocalizedFormats;
-import org.apache.commons.math4.legacy.util.FastMath;
-import org.apache.commons.math4.legacy.util.MathArrays;
+import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
+import org.apache.commons.math4.legacy.core.MathArrays;
/**
* Implements Chi-Square test statistics.
@@ -98,7 +98,7 @@ public class ChiSquareTest {
}
double ratio = 1.0d;
boolean rescale = false;
- if (FastMath.abs(sumExpected - sumObserved) > 10E-6) {
+ if (AccurateMath.abs(sumExpected - sumObserved) > 10E-6) {
ratio = sumObserved / sumExpected;
rescale = true;
}
@@ -438,7 +438,7 @@ public class ChiSquareTest {
// Compare and compute weight only if different
unequalCounts = countSum1 != countSum2;
if (unequalCounts) {
- weight = FastMath.sqrt((double) countSum1 / (double) countSum2);
+ weight = AccurateMath.sqrt((double) countSum1 / (double) countSum2);
}
// Compute ChiSquare statistic
double sumSq = 0.0d;
diff --git a/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/stat/inference/GTest.java b/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/stat/inference/GTest.java
index 231933f83..666f2eae7 100644
--- a/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/stat/inference/GTest.java
+++ b/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/stat/inference/GTest.java
@@ -24,8 +24,8 @@ import org.apache.commons.math4.legacy.exception.NotStrictlyPositiveException;
import org.apache.commons.math4.legacy.exception.OutOfRangeException;
import org.apache.commons.math4.legacy.exception.ZeroException;
import org.apache.commons.math4.legacy.exception.util.LocalizedFormats;
-import org.apache.commons.math4.legacy.util.FastMath;
-import org.apache.commons.math4.legacy.util.MathArrays;
+import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
+import org.apache.commons.math4.legacy.core.MathArrays;
/**
* Implements G Test
@@ -94,15 +94,15 @@ public class GTest {
}
double ratio = 1d;
boolean rescale = false;
- if (FastMath.abs(sumExpected - sumObserved) > 10E-6) {
+ if (AccurateMath.abs(sumExpected - sumObserved) > 10E-6) {
ratio = sumObserved / sumExpected;
rescale = true;
}
double sum = 0d;
for (int i = 0; i < observed.length; i++) {
final double dev = rescale ?
- FastMath.log((double) observed[i] / (ratio * expected[i])) :
- FastMath.log((double) observed[i] / expected[i]);
+ AccurateMath.log((double) observed[i] / (ratio * expected[i])) :
+ AccurateMath.log((double) observed[i] / expected[i]);
sum += ((double) observed[i]) * dev;
}
return 2d * sum;
@@ -269,7 +269,7 @@ public class GTest {
for (int j = 0; j < k[i].length; j++) {
if (k[i][j] != 0) {
final double p_ij = (double) k[i][j] / sum_k;
- h += p_ij * FastMath.log(p_ij);
+ h += p_ij * AccurateMath.log(p_ij);
}
}
}
@@ -296,7 +296,7 @@ public class GTest {
for (int i = 0; i < k.length; i++) {
if (k[i] != 0) {
final double p_i = (double) k[i] / sum_k;
- h += p_i * FastMath.log(p_i);
+ h += p_i * AccurateMath.log(p_i);
}
}
return -h;
@@ -421,7 +421,7 @@ public class GTest {
final long k21, final long k22) {
final double llr = gDataSetsComparison(
new long[]{k11, k12}, new long[]{k21, k22});
- double sqrt = FastMath.sqrt(llr);
+ double sqrt = AccurateMath.sqrt(llr);
if ((double) k11 / (k11 + k12) < (double) k21 / (k21 + k22)) {
sqrt = -sqrt;
}
diff --git a/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/stat/inference/KolmogorovSmirnovTest.java b/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/stat/inference/KolmogorovSmirnovTest.java
index fd6fec2c8..09fcb0f33 100644
--- a/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/stat/inference/KolmogorovSmirnovTest.java
+++ b/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/stat/inference/KolmogorovSmirnovTest.java
@@ -39,8 +39,8 @@ import org.apache.commons.math4.legacy.exception.NotANumberException;
import org.apache.commons.math4.legacy.exception.util.LocalizedFormats;
import org.apache.commons.math4.legacy.linear.MatrixUtils;
import org.apache.commons.math4.legacy.linear.RealMatrix;
-import org.apache.commons.math4.legacy.util.FastMath;
-import org.apache.commons.math4.legacy.util.MathArrays;
+import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
+import org.apache.commons.math4.legacy.core.MathArrays;
import org.apache.commons.math4.legacy.field.linalg.FieldDenseMatrix;
/**
@@ -112,7 +112,7 @@ import org.apache.commons.math4.legacy.field.linalg.FieldDenseMatrix;
*/
public class KolmogorovSmirnovTest {
/** pi^2. */
- private static final double PI_SQUARED = FastMath.PI * FastMath.PI;
+ private static final double PI_SQUARED = AccurateMath.PI * AccurateMath.PI;
/**
* Bound on the number of partial sums in {@link #ksSum(double, double, int)}
*/
@@ -171,7 +171,7 @@ public class KolmogorovSmirnovTest {
double d = 0d;
for (int i = 1; i <= n; i++) {
final double yi = distribution.cumulativeProbability(dataCopy[i - 1]);
- final double currD = FastMath.max(yi - (i - 1) / nd, i / nd - yi);
+ final double currD = AccurateMath.max(yi - (i - 1) / nd, i / nd - yi);
if (currD > d) {
d = currD;
}
@@ -543,7 +543,7 @@ public class KolmogorovSmirnovTest {
*/
public double pelzGood(double d, int n) {
// Change the variable since approximation is for the distribution evaluated at d / sqrt(n)
- final double sqrtN = FastMath.sqrt(n);
+ final double sqrtN = AccurateMath.sqrt(n);
final double z = d * sqrtN;
final double z2 = d * d * n;
final double z4 = z2 * z2;
@@ -561,7 +561,7 @@ public class KolmogorovSmirnovTest {
int k = 1;
for (; k < MAXIMUM_PARTIAL_SUM_COUNT; k++) {
kTerm = 2 * k - 1;
- increment = FastMath.exp(-z2Term * kTerm * kTerm);
+ increment = AccurateMath.exp(-z2Term * kTerm * kTerm);
sum += increment;
if (increment <= PG_SUM_RELATIVE_ERROR * sum) {
break;
@@ -570,7 +570,7 @@ public class KolmogorovSmirnovTest {
if (k == MAXIMUM_PARTIAL_SUM_COUNT) {
throw new TooManyIterationsException(MAXIMUM_PARTIAL_SUM_COUNT);
}
- ret = sum * FastMath.sqrt(2 * FastMath.PI) / z;
+ ret = sum * AccurateMath.sqrt(2 * AccurateMath.PI) / z;
// K_1(z)
// Sum is -inf to inf, but k term is always (k + 1/2) ^ 2, so really have
@@ -582,16 +582,16 @@ public class KolmogorovSmirnovTest {
for (k = 0; k < MAXIMUM_PARTIAL_SUM_COUNT; k++) {
kTerm = k + 0.5;
kTerm2 = kTerm * kTerm;
- increment = (PI_SQUARED * kTerm2 - z2) * FastMath.exp(-PI_SQUARED * kTerm2 / twoZ2);
+ increment = (PI_SQUARED * kTerm2 - z2) * AccurateMath.exp(-PI_SQUARED * kTerm2 / twoZ2);
sum += increment;
- if (FastMath.abs(increment) < PG_SUM_RELATIVE_ERROR * FastMath.abs(sum)) {
+ if (AccurateMath.abs(increment) < PG_SUM_RELATIVE_ERROR * AccurateMath.abs(sum)) {
break;
}
}
if (k == MAXIMUM_PARTIAL_SUM_COUNT) {
throw new TooManyIterationsException(MAXIMUM_PARTIAL_SUM_COUNT);
}
- final double sqrtHalfPi = FastMath.sqrt(FastMath.PI / 2);
+ final double sqrtHalfPi = AccurateMath.sqrt(AccurateMath.PI / 2);
// Instead of doubling sum, divide by 3 instead of 6
ret += sum * sqrtHalfPi / (3 * z4 * sqrtN);
@@ -608,9 +608,9 @@ public class KolmogorovSmirnovTest {
kTerm = k + 0.5;
kTerm2 = kTerm * kTerm;
increment = (z6Term + z4Term + PI_SQUARED * (z4Term - z2Term) * kTerm2 +
- pi4 * (1 - twoZ2) * kTerm2 * kTerm2) * FastMath.exp(-PI_SQUARED * kTerm2 / twoZ2);
+ pi4 * (1 - twoZ2) * kTerm2 * kTerm2) * AccurateMath.exp(-PI_SQUARED * kTerm2 / twoZ2);
sum += increment;
- if (FastMath.abs(increment) < PG_SUM_RELATIVE_ERROR * FastMath.abs(sum)) {
+ if (AccurateMath.abs(increment) < PG_SUM_RELATIVE_ERROR * AccurateMath.abs(sum)) {
break;
}
}
@@ -621,9 +621,9 @@ public class KolmogorovSmirnovTest {
kTerm2 = 0;
for (k = 1; k < MAXIMUM_PARTIAL_SUM_COUNT; k++) {
kTerm2 = k * k;
- increment = PI_SQUARED * kTerm2 * FastMath.exp(-PI_SQUARED * kTerm2 / twoZ2);
+ increment = PI_SQUARED * kTerm2 * AccurateMath.exp(-PI_SQUARED * kTerm2 / twoZ2);
sum2 += increment;
- if (FastMath.abs(increment) < PG_SUM_RELATIVE_ERROR * FastMath.abs(sum2)) {
+ if (AccurateMath.abs(increment) < PG_SUM_RELATIVE_ERROR * AccurateMath.abs(sum2)) {
break;
}
}
@@ -646,9 +646,9 @@ public class KolmogorovSmirnovTest {
kTerm6 = kTerm4 * kTerm2;
increment = (pi6 * kTerm6 * (5 - 30 * z2) + pi4 * kTerm4 * (-60 * z2 + 212 * z4) +
PI_SQUARED * kTerm2 * (135 * z4 - 96 * z6) - 30 * z6 - 90 * z8) *
- FastMath.exp(-PI_SQUARED * kTerm2 / twoZ2);
+ AccurateMath.exp(-PI_SQUARED * kTerm2 / twoZ2);
sum += increment;
- if (FastMath.abs(increment) < PG_SUM_RELATIVE_ERROR * FastMath.abs(sum)) {
+ if (AccurateMath.abs(increment) < PG_SUM_RELATIVE_ERROR * AccurateMath.abs(sum)) {
break;
}
}
@@ -660,9 +660,9 @@ public class KolmogorovSmirnovTest {
kTerm2 = k * k;
kTerm4 = kTerm2 * kTerm2;
increment = (-pi4 * kTerm4 + 3 * PI_SQUARED * kTerm2 * z2) *
- FastMath.exp(-PI_SQUARED * kTerm2 / twoZ2);
+ AccurateMath.exp(-PI_SQUARED * kTerm2 / twoZ2);
sum2 += increment;
- if (FastMath.abs(increment) < PG_SUM_RELATIVE_ERROR * FastMath.abs(sum2)) {
+ if (AccurateMath.abs(increment) < PG_SUM_RELATIVE_ERROR * AccurateMath.abs(sum2)) {
break;
}
}
@@ -822,7 +822,7 @@ public class KolmogorovSmirnovTest {
* (2h - 1)^m )/m!" Since 0 <= h < 1, then if h > 1/2 is sufficient to check:
*/
if (Double.compare(h, 0.5) > 0) {
- Hdata[m - 1][0] += FastMath.pow(2 * h - 1, m);
+ Hdata[m - 1][0] += AccurateMath.pow(2 * h - 1, m);
}
/*
@@ -888,7 +888,7 @@ public class KolmogorovSmirnovTest {
double partialSum = 0.5d;
double delta = 1;
while (delta > tolerance && i < maxIterations) {
- delta = FastMath.exp(x * i * i);
+ delta = AccurateMath.exp(x * i * i);
partialSum += sign * delta;
sign *= -1;
i++;
@@ -915,8 +915,8 @@ public class KolmogorovSmirnovTest {
private static long calculateIntegralD(double d, int n, int m, boolean strict) {
final double tol = 1e-12; // d-values within tol of one another are considered equal
long nm = n * (long)m;
- long upperBound = (long)FastMath.ceil((d - tol) * nm);
- long lowerBound = (long)FastMath.floor((d + tol) * nm);
+ long upperBound = (long)AccurateMath.ceil((d - tol) * nm);
+ long lowerBound = (long)AccurateMath.floor((d + tol) * nm);
if (strict && lowerBound == upperBound) {
return upperBound + 1l;
}
@@ -965,7 +965,7 @@ public class KolmogorovSmirnovTest {
public double approximateP(double d, int n, int m) {
final double dm = m;
final double dn = n;
- return 1 - ksSum(d * FastMath.sqrt((dm * dn) / (dm + dn)),
+ return 1 - ksSum(d * AccurateMath.sqrt((dm * dn) / (dm + dn)),
KS_SUM_CAUCHY_CRITERION, MAXIMUM_PARTIAL_SUM_COUNT);
}
@@ -1040,8 +1040,8 @@ public class KolmogorovSmirnovTest {
final int iterations,
UniformRandomProvider rng) {
// ensure that nn is always the max of (n, m) to require fewer random numbers
- final int nn = FastMath.max(n, m);
- final int mm = FastMath.min(n, m);
+ final int nn = AccurateMath.max(n, m);
+ final int mm = AccurateMath.min(n, m);
final int sum = nn + mm;
int tail = 0;
@@ -1186,9 +1186,9 @@ public class KolmogorovSmirnovTest {
*/
private static int c(int i, int j, int m, int n, long cmn, boolean strict) {
if (strict) {
- return FastMath.abs(i*(long)n - j*(long)m) <= cmn ? 1 : 0;
+ return AccurateMath.abs(i*(long)n - j*(long)m) <= cmn ? 1 : 0;
}
- return FastMath.abs(i*(long)n - j*(long)m) < cmn ? 1 : 0;
+ return AccurateMath.abs(i*(long)n - j*(long)m) < cmn ? 1 : 0;
}
/**
diff --git a/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/stat/inference/MannWhitneyUTest.java b/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/stat/inference/MannWhitneyUTest.java
index 53a93dc35..15d80e8f0 100644
--- a/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/stat/inference/MannWhitneyUTest.java
+++ b/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/stat/inference/MannWhitneyUTest.java
@@ -24,7 +24,7 @@ import org.apache.commons.math4.legacy.exception.NullArgumentException;
import org.apache.commons.math4.legacy.stat.ranking.NaNStrategy;
import org.apache.commons.math4.legacy.stat.ranking.NaturalRanking;
import org.apache.commons.math4.legacy.stat.ranking.TiesStrategy;
-import org.apache.commons.math4.legacy.util.FastMath;
+import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
import java.util.stream.IntStream;
@@ -150,7 +150,7 @@ public class MannWhitneyUTest {
*/
final double U2 = (long) x.length * y.length - U1;
- return FastMath.min(U1, U2);
+ return AccurateMath.min(U1, U2);
}
/**
@@ -177,7 +177,7 @@ public class MannWhitneyUTest {
final double EU = n1n2prod / 2.0;
final double VarU = n1n2prod * (n1 + n2 + 1) / 12.0;
- final double z = (Umin - EU) / FastMath.sqrt(VarU);
+ final double z = (Umin - EU) / AccurateMath.sqrt(VarU);
// No try-catch or advertised exception because args are valid
// pass a null rng to avoid unneeded overhead as we will not sample from this distribution
diff --git a/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/stat/inference/TTest.java b/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/stat/inference/TTest.java
index f4389c180..9854538cd 100644
--- a/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/stat/inference/TTest.java
+++ b/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/stat/inference/TTest.java
@@ -28,7 +28,7 @@ import org.apache.commons.math4.legacy.exception.OutOfRangeException;
import org.apache.commons.math4.legacy.exception.util.LocalizedFormats;
import org.apache.commons.math4.legacy.stat.StatUtils;
import org.apache.commons.math4.legacy.stat.descriptive.StatisticalSummary;
-import org.apache.commons.math4.legacy.util.FastMath;
+import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
/**
* An implementation for Student's t-tests.
@@ -999,7 +999,7 @@ public class TTest {
*/
protected double t(final double m, final double mu,
final double v, final double n) {
- return (m - mu) / FastMath.sqrt(v / n);
+ return (m - mu) / AccurateMath.sqrt(v / n);
}
/**
@@ -1018,7 +1018,7 @@ public class TTest {
protected double t(final double m1, final double m2,
final double v1, final double v2,
final double n1, final double n2) {
- return (m1 - m2) / FastMath.sqrt((v1 / n1) + (v2 / n2));
+ return (m1 - m2) / AccurateMath.sqrt((v1 / n1) + (v2 / n2));
}
/**
@@ -1037,7 +1037,7 @@ public class TTest {
final double v1, final double v2,
final double n1, final double n2) {
final double pooledVariance = ((n1 - 1) * v1 + (n2 -1) * v2 ) / (n1 + n2 - 2);
- return (m1 - m2) / FastMath.sqrt(pooledVariance * (1d / n1 + 1d / n2));
+ return (m1 - m2) / AccurateMath.sqrt(pooledVariance * (1d / n1 + 1d / n2));
}
/**
@@ -1055,7 +1055,7 @@ public class TTest {
final double v, final double n)
throws MaxCountExceededException, MathIllegalArgumentException {
- final double t = FastMath.abs(t(m, mu, v, n));
+ final double t = AccurateMath.abs(t(m, mu, v, n));
// pass a null rng to avoid unneeded overhead as we will not sample from this distribution
final TDistribution distribution = new TDistribution(n - 1);
return 2.0 * distribution.cumulativeProbability(-t);
@@ -1084,7 +1084,7 @@ public class TTest {
final double n1, final double n2)
throws MaxCountExceededException, NotStrictlyPositiveException {
- final double t = FastMath.abs(t(m1, m2, v1, v2, n1, n2));
+ final double t = AccurateMath.abs(t(m1, m2, v1, v2, n1, n2));
final double degreesOfFreedom = df(v1, v2, n1, n2);
// pass a null rng to avoid unneeded overhead as we will not sample from this distribution
final TDistribution distribution = new TDistribution(degreesOfFreedom);
@@ -1114,7 +1114,7 @@ public class TTest {
double n1, double n2)
throws MaxCountExceededException, NotStrictlyPositiveException {
- final double t = FastMath.abs(homoscedasticT(m1, m2, v1, v2, n1, n2));
+ final double t = AccurateMath.abs(homoscedasticT(m1, m2, v1, v2, n1, n2));
final double degreesOfFreedom = n1 + n2 - 2;
// pass a null rng to avoid unneeded overhead as we will not sample from this distribution
final TDistribution distribution = new TDistribution(degreesOfFreedom);
diff --git a/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/stat/inference/WilcoxonSignedRankTest.java b/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/stat/inference/WilcoxonSignedRankTest.java
index f2c5f44d9..1146e56d0 100644
--- a/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/stat/inference/WilcoxonSignedRankTest.java
+++ b/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/stat/inference/WilcoxonSignedRankTest.java
@@ -26,7 +26,7 @@ import org.apache.commons.math4.legacy.exception.NumberIsTooLargeException;
import org.apache.commons.math4.legacy.stat.ranking.NaNStrategy;
import org.apache.commons.math4.legacy.stat.ranking.NaturalRanking;
import org.apache.commons.math4.legacy.stat.ranking.TiesStrategy;
-import org.apache.commons.math4.legacy.util.FastMath;
+import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
/**
* An implementation of the Wilcoxon signed-rank test.
@@ -127,7 +127,7 @@ public class WilcoxonSignedRankTest {
final double[] zAbs = new double[z.length];
for (int i = 0; i < z.length; ++i) {
- zAbs[i] = FastMath.abs(z[i]);
+ zAbs[i] = AccurateMath.abs(z[i]);
}
return zAbs;
@@ -190,7 +190,7 @@ public class WilcoxonSignedRankTest {
final int N = x.length;
final double Wminus = (((double) (N * (N + 1))) / 2.0) - Wplus;
- return FastMath.max(Wplus, Wminus);
+ return AccurateMath.max(Wplus, Wminus);
}
/**
@@ -249,7 +249,7 @@ public class WilcoxonSignedRankTest {
final double VarS = ES * ((double) (2 * N + 1) / 6.0);
// - 0.5 is a continuity correction
- final double z = (Wmin - ES - 0.5) / FastMath.sqrt(VarS);
+ final double z = (Wmin - ES - 0.5) / AccurateMath.sqrt(VarS);
// No try-catch or advertised exception because args are valid
// pass a null rng to avoid unneeded overhead as we will not sample from this distribution
diff --git a/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/stat/interval/AgrestiCoullInterval.java b/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/stat/interval/AgrestiCoullInterval.java
index 18da46819..3ddb4cb60 100644
--- a/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/stat/interval/AgrestiCoullInterval.java
+++ b/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/stat/interval/AgrestiCoullInterval.java
@@ -17,7 +17,7 @@
package org.apache.commons.math4.legacy.stat.interval;
import org.apache.commons.statistics.distribution.NormalDistribution;
-import org.apache.commons.math4.legacy.util.FastMath;
+import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
/**
* Implements the Agresti-Coull method for creating a binomial proportion confidence interval.
@@ -36,11 +36,11 @@ public class AgrestiCoullInterval implements BinomialConfidenceInterval {
final double alpha = (1.0 - confidenceLevel) / 2;
final NormalDistribution normalDistribution = new NormalDistribution(0, 1);
final double z = normalDistribution.inverseCumulativeProbability(1 - alpha);
- final double zSquared = FastMath.pow(z, 2);
+ final double zSquared = AccurateMath.pow(z, 2);
final double modifiedNumberOfTrials = numberOfTrials + zSquared;
final double modifiedSuccessesRatio = (1.0 / modifiedNumberOfTrials) * (numberOfSuccesses + 0.5 * zSquared);
final double difference = z *
- FastMath.sqrt(1.0 / modifiedNumberOfTrials * modifiedSuccessesRatio *
+ AccurateMath.sqrt(1.0 / modifiedNumberOfTrials * modifiedSuccessesRatio *
(1 - modifiedSuccessesRatio));
return new ConfidenceInterval(modifiedSuccessesRatio - difference, modifiedSuccessesRatio + difference,
confidenceLevel);
diff --git a/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/stat/interval/NormalApproximationInterval.java b/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/stat/interval/NormalApproximationInterval.java
index 1eace25a1..75533e4a7 100644
--- a/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/stat/interval/NormalApproximationInterval.java
+++ b/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/stat/interval/NormalApproximationInterval.java
@@ -17,7 +17,7 @@
package org.apache.commons.math4.legacy.stat.interval;
import org.apache.commons.statistics.distribution.NormalDistribution;
-import org.apache.commons.math4.legacy.util.FastMath;
+import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
/**
* Implements the normal approximation method for creating a binomial proportion confidence interval.
@@ -38,7 +38,7 @@ public class NormalApproximationInterval implements BinomialConfidenceInterval {
final double alpha = (1.0 - confidenceLevel) / 2;
final NormalDistribution normalDistribution = new NormalDistribution(0, 1);
final double difference = normalDistribution.inverseCumulativeProbability(1 - alpha) *
- FastMath.sqrt(1.0 / numberOfTrials * mean * (1 - mean));
+ AccurateMath.sqrt(1.0 / numberOfTrials * mean * (1 - mean));
return new ConfidenceInterval(mean - difference, mean + difference, confidenceLevel);
}
diff --git a/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/stat/interval/WilsonScoreInterval.java b/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/stat/interval/WilsonScoreInterval.java
index 163d626a9..713f46e60 100644
--- a/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/stat/interval/WilsonScoreInterval.java
+++ b/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/stat/interval/WilsonScoreInterval.java
@@ -17,7 +17,7 @@
package org.apache.commons.math4.legacy.stat.interval;
import org.apache.commons.statistics.distribution.NormalDistribution;
-import org.apache.commons.math4.legacy.util.FastMath;
+import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
/**
* Implements the
@@ -41,7 +41,7 @@ public class WilsonScoreInterval implements BinomialConfidenceInterval {
final double factor = 1 / (1 + zSquaredOverNumTrials);
final double modifiedSuccessRatio = mean + zSquaredOverNumTrials / 2;
- final double difference = z * FastMath.sqrt(oneOverNumTrials * mean * (1 - mean) +
+ final double difference = z * AccurateMath.sqrt(oneOverNumTrials * mean * (1 - mean) +
(oneOverNumTrials * zSquaredOverNumTrials / 4));
final double lowerBound = factor * (modifiedSuccessRatio - difference);
diff --git a/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/stat/ranking/NaturalRanking.java b/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/stat/ranking/NaturalRanking.java
index ad1bf045f..bbab5ea0f 100644
--- a/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/stat/ranking/NaturalRanking.java
+++ b/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/stat/ranking/NaturalRanking.java
@@ -27,7 +27,7 @@ import org.apache.commons.math4.legacy.exception.NotANumberException;
import org.apache.commons.rng.UniformRandomProvider;
import org.apache.commons.rng.simple.RandomSource;
import org.apache.commons.math4.legacy.random.RandomUtils;
-import org.apache.commons.math4.legacy.util.FastMath;
+import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
/**
@@ -353,7 +353,7 @@ public class NaturalRanking implements RankingAlgorithm {
break;
case RANDOM: // Fill with random integral values in [c, c + length - 1]
Iterator iterator = tiesTrace.iterator();
- long f = FastMath.round(c);
+ long f = AccurateMath.round(c);
while (iterator.hasNext()) {
// No advertised exception because args are guaranteed valid
ranks[iterator.next()] =
@@ -363,7 +363,7 @@ public class NaturalRanking implements RankingAlgorithm {
case SEQUENTIAL: // Fill sequentially from c to c + length - 1
// walk and fill
iterator = tiesTrace.iterator();
- f = FastMath.round(c);
+ f = AccurateMath.round(c);
int i = 0;
while (iterator.hasNext()) {
ranks[iterator.next()] = f + i++;
diff --git a/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/stat/regression/AbstractMultipleLinearRegression.java b/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/stat/regression/AbstractMultipleLinearRegression.java
index e91015e7d..dae6f405b 100644
--- a/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/stat/regression/AbstractMultipleLinearRegression.java
+++ b/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/stat/regression/AbstractMultipleLinearRegression.java
@@ -28,7 +28,7 @@ import org.apache.commons.math4.legacy.linear.NonSquareMatrixException;
import org.apache.commons.math4.legacy.linear.RealMatrix;
import org.apache.commons.math4.legacy.linear.RealVector;
import org.apache.commons.math4.legacy.stat.descriptive.moment.Variance;
-import org.apache.commons.math4.legacy.util.FastMath;
+import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
/**
* Abstract base class for implementations of MultipleLinearRegression.
@@ -292,7 +292,7 @@ public abstract class AbstractMultipleLinearRegression implements
int length = betaVariance[0].length;
double[] result = new double[length];
for (int i = 0; i < length; i++) {
- result[i] = FastMath.sqrt(sigma * betaVariance[i][i]);
+ result[i] = AccurateMath.sqrt(sigma * betaVariance[i][i]);
}
return result;
}
@@ -323,7 +323,7 @@ public abstract class AbstractMultipleLinearRegression implements
* @since 2.2
*/
public double estimateRegressionStandardError() {
- return FastMath.sqrt(estimateErrorVariance());
+ return AccurateMath.sqrt(estimateErrorVariance());
}
/**
diff --git a/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/stat/regression/MillerUpdatingRegression.java b/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/stat/regression/MillerUpdatingRegression.java
index 4bc695f24..0267aa000 100644
--- a/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/stat/regression/MillerUpdatingRegression.java
+++ b/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/stat/regression/MillerUpdatingRegression.java
@@ -19,7 +19,7 @@ package org.apache.commons.math4.legacy.stat.regression;
import java.util.Arrays;
import org.apache.commons.math4.legacy.exception.util.LocalizedFormats;
-import org.apache.commons.math4.legacy.util.FastMath;
+import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
import org.apache.commons.numbers.core.Precision;
/**
@@ -258,7 +258,7 @@ public class MillerUpdatingRegression implements UpdatingMultipleLinearRegressio
if (di != 0.0) {
dpi = smartAdd(di, wxi * xi);
final double tmp = wxi * xi / di;
- if (FastMath.abs(tmp) > Precision.EPSILON) {
+ if (AccurateMath.abs(tmp) > Precision.EPSILON) {
w = (di * w) / dpi;
}
} else {
@@ -295,8 +295,8 @@ public class MillerUpdatingRegression implements UpdatingMultipleLinearRegressio
* @return the sum of the a and b
*/
private double smartAdd(double a, double b) {
- final double _a = FastMath.abs(a);
- final double _b = FastMath.abs(b);
+ final double _a = AccurateMath.abs(a);
+ final double _b = AccurateMath.abs(b);
if (_a > _b) {
final double eps = _a * Precision.EPSILON;
if (_b > eps) {
@@ -346,14 +346,14 @@ public class MillerUpdatingRegression implements UpdatingMultipleLinearRegressio
double total;
final double eps = this.epsilon;
for (int i = 0; i < nvars; i++) {
- this.work_tolset[i] = FastMath.sqrt(d[i]);
+ this.work_tolset[i] = AccurateMath.sqrt(d[i]);
}
tol[0] = eps * this.work_tolset[0];
for (int col = 1; col < nvars; col++) {
pos = col - 1;
total = work_tolset[col];
for (int row = 0; row < col; row++) {
- total += FastMath.abs(r[pos]) * work_tolset[row];
+ total += AccurateMath.abs(r[pos]) * work_tolset[row];
pos += nvars - row - 2;
}
tol[col] = eps * total;
@@ -387,7 +387,7 @@ public class MillerUpdatingRegression implements UpdatingMultipleLinearRegressio
final double[] ret = new double[nreq];
boolean rankProblem = false;
for (int i = nreq - 1; i > -1; i--) {
- if (FastMath.sqrt(d[i]) < tol[i]) {
+ if (AccurateMath.sqrt(d[i]) < tol[i]) {
ret[i] = 0.0;
d[i] = 0.0;
rankProblem = true;
@@ -417,7 +417,7 @@ public class MillerUpdatingRegression implements UpdatingMultipleLinearRegressio
private void singcheck() {
int pos;
for (int i = 0; i < nvars; i++) {
- work_sing[i] = FastMath.sqrt(d[i]);
+ work_sing[i] = AccurateMath.sqrt(d[i]);
}
for (int col = 0; col < nvars; col++) {
// Set elements within R to zero if they are less than tol(col) in
@@ -426,7 +426,7 @@ public class MillerUpdatingRegression implements UpdatingMultipleLinearRegressio
final double temp = tol[col];
pos = col - 1;
for (int row = 0; row < col - 1; row++) {
- if (FastMath.abs(r[pos]) * work_sing[row] < temp) {
+ if (AccurateMath.abs(r[pos]) * work_sing[row] < temp) {
r[pos] = 0.0;
}
pos += nvars - row - 2;
@@ -629,7 +629,7 @@ public class MillerUpdatingRegression implements UpdatingMultipleLinearRegressio
final int nvm = nvars - 1;
final int base_pos = r.length - (nvm - in) * (nvm - in + 1) / 2;
if (d[in] > 0.0) {
- rms[in + rms_off] = 1.0 / FastMath.sqrt(d[in]);
+ rms[in + rms_off] = 1.0 / AccurateMath.sqrt(d[in]);
}
for (int col = in + 1; col < nvars; col++) {
pos = base_pos + col - 1 - in;
@@ -639,7 +639,7 @@ public class MillerUpdatingRegression implements UpdatingMultipleLinearRegressio
pos += nvars - row - 2;
}
if (sumxx > 0.0) {
- rms[col + rms_off] = 1.0 / FastMath.sqrt(sumxx);
+ rms[col + rms_off] = 1.0 / AccurateMath.sqrt(sumxx);
} else {
rms[col + rms_off] = 0.0;
}
@@ -649,7 +649,7 @@ public class MillerUpdatingRegression implements UpdatingMultipleLinearRegressio
sumyy += d[row] * rhs[row] * rhs[row];
}
if (sumyy > 0.0) {
- sumyy = 1.0 / FastMath.sqrt(sumyy);
+ sumyy = 1.0 / AccurateMath.sqrt(sumyy);
}
pos = 0;
for (int col1 = in; col1 < nvars; col1++) {
@@ -733,10 +733,10 @@ public class MillerUpdatingRegression implements UpdatingMultipleLinearRegressio
// Special cases.
if (d1 > this.epsilon || d2 > this.epsilon) {
X = r[m1];
- if (FastMath.abs(X) * FastMath.sqrt(d1) < tol[mp1]) {
+ if (AccurateMath.abs(X) * AccurateMath.sqrt(d1) < tol[mp1]) {
X = 0.0;
}
- if (d1 < this.epsilon || FastMath.abs(X) < this.epsilon) {
+ if (d1 < this.epsilon || AccurateMath.abs(X) < this.epsilon) {
d[m] = d2;
d[mp1] = d1;
r[m1] = 0.0;
@@ -872,7 +872,7 @@ public class MillerUpdatingRegression implements UpdatingMultipleLinearRegressio
}
double hii = 0.0;
for (int col = 0; col < xrow.length; col++) {
- if (FastMath.sqrt(d[col]) < tol[col]) {
+ if (AccurateMath.sqrt(d[col]) < tol[col]) {
wk[col] = 0.0;
} else {
pos = col - 1;
diff --git a/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/stat/regression/RegressionResults.java b/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/stat/regression/RegressionResults.java
index 1a444d656..f18f4a365 100644
--- a/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/stat/regression/RegressionResults.java
+++ b/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/stat/regression/RegressionResults.java
@@ -20,7 +20,7 @@ import java.io.Serializable;
import java.util.Arrays;
import org.apache.commons.math4.legacy.exception.OutOfRangeException;
-import org.apache.commons.math4.legacy.util.FastMath;
+import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
/**
* Results of a Multiple Linear Regression model fit.
@@ -192,7 +192,7 @@ public class RegressionResults implements Serializable {
}
double var = this.getVcvElement(index, index);
if (!Double.isNaN(var) && var > Double.MIN_VALUE) {
- return FastMath.sqrt(var);
+ return AccurateMath.sqrt(var);
}
return Double.NaN;
}
@@ -216,7 +216,7 @@ public class RegressionResults implements Serializable {
for (int i = 0; i < this.parameters.length; i++) {
double var = this.getVcvElement(i, i);
if (!Double.isNaN(var) && var > Double.MIN_VALUE) {
- se[i] = FastMath.sqrt(var);
+ se[i] = AccurateMath.sqrt(var);
continue;
}
se[i] = Double.NaN;
diff --git a/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/stat/regression/SimpleRegression.java b/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/stat/regression/SimpleRegression.java
index a70fe8d2f..5eb282822 100644
--- a/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/stat/regression/SimpleRegression.java
+++ b/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/stat/regression/SimpleRegression.java
@@ -23,7 +23,7 @@ import org.apache.commons.math4.legacy.exception.MathIllegalArgumentException;
import org.apache.commons.math4.legacy.exception.NoDataException;
import org.apache.commons.math4.legacy.exception.OutOfRangeException;
import org.apache.commons.math4.legacy.exception.util.LocalizedFormats;
-import org.apache.commons.math4.legacy.util.FastMath;
+import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
import org.apache.commons.numbers.core.Precision;
/**
@@ -438,7 +438,7 @@ public class SimpleRegression implements Serializable, UpdatingMultipleLinearReg
if (n < 2) {
return Double.NaN; //not enough data
}
- if (FastMath.abs(sumXX) < 10 * Double.MIN_VALUE) {
+ if (AccurateMath.abs(sumXX) < 10 * Double.MIN_VALUE) {
return Double.NaN; //not enough variation in x
}
return sumXY / sumXX;
@@ -474,7 +474,7 @@ public class SimpleRegression implements Serializable, UpdatingMultipleLinearReg
* @return sum of squared errors associated with the regression model
*/
public double getSumSquaredErrors() {
- return FastMath.max(0d, sumYY - sumXY * sumXY / sumXX);
+ return AccurateMath.max(0d, sumYY - sumXY * sumXY / sumXX);
}
/**
@@ -570,7 +570,7 @@ public class SimpleRegression implements Serializable, UpdatingMultipleLinearReg
*/
public double getR() {
double b1 = getSlope();
- double result = FastMath.sqrt(getRSquare());
+ double result = AccurateMath.sqrt(getRSquare());
if (b1 < 0) {
result = -result;
}
@@ -612,7 +612,7 @@ public class SimpleRegression implements Serializable, UpdatingMultipleLinearReg
if( !hasIntercept ){
return Double.NaN;
}
- return FastMath.sqrt(
+ return AccurateMath.sqrt(
getMeanSquareError() * ((1d / n) + (xbar * xbar) / sumXX));
}
@@ -628,7 +628,7 @@ public class SimpleRegression implements Serializable, UpdatingMultipleLinearReg
* @return standard error associated with slope estimate
*/
public double getSlopeStdErr() {
- return FastMath.sqrt(getMeanSquareError() / sumXX);
+ return AccurateMath.sqrt(getMeanSquareError() / sumXX);
}
/**
@@ -732,7 +732,7 @@ public class SimpleRegression implements Serializable, UpdatingMultipleLinearReg
// No advertised NotStrictlyPositiveException here - will return NaN above
TDistribution distribution = new TDistribution(n - 2);
return 2d * (1.0 - distribution.cumulativeProbability(
- FastMath.abs(getSlope()) / getSlopeStdErr()));
+ AccurateMath.abs(getSlope()) / getSlopeStdErr()));
}
// ---------------------Private methods-----------------------------------
@@ -780,7 +780,7 @@ public class SimpleRegression implements Serializable, UpdatingMultipleLinearReg
if (n < 3) {
throw new NoDataException(LocalizedFormats.NOT_ENOUGH_DATA_REGRESSION);
}
- if (FastMath.abs(sumXX) > Precision.SAFE_MIN) {
+ if (AccurateMath.abs(sumXX) > Precision.SAFE_MIN) {
final double[] params = new double[] { getIntercept(), getSlope() };
final double mse = getMeanSquareError();
final double _syy = sumYY + sumY * sumY / n;
@@ -860,7 +860,7 @@ public class SimpleRegression implements Serializable, UpdatingMultipleLinearReg
//final double _syy = sumYY + sumY * sumY / ((double) n);
final double _sxx = sumXX + sumX * sumX / n;
final double _sxy = sumXY + sumX * sumY / n;
- final double _sse = FastMath.max(0d, _syy - _sxy * _sxy / _sxx);
+ final double _sse = AccurateMath.max(0d, _syy - _sxy * _sxy / _sxx);
final double _mse = _sse/((n-1));
if( !Double.isNaN(_sxx) ){
final double[] vcv = new double[]{ _mse / _sxx };
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/TestUtils.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/TestUtils.java
index 77f375438..03bffb137 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/TestUtils.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/TestUtils.java
@@ -26,12 +26,13 @@ import java.text.DecimalFormat;
import org.apache.commons.numbers.complex.Complex;
import org.apache.commons.numbers.core.Precision;
import org.apache.commons.statistics.distribution.ContinuousDistribution;
+import org.apache.commons.math4.legacy.core.FieldElement;
import org.apache.commons.math4.legacy.complex.ComplexFormat;
import org.apache.commons.math4.legacy.linear.FieldMatrix;
import org.apache.commons.math4.legacy.linear.RealMatrix;
import org.apache.commons.math4.legacy.linear.RealVector;
import org.apache.commons.math4.legacy.stat.inference.ChiSquareTest;
-import org.apache.commons.math4.legacy.util.FastMath;
+import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
import org.junit.Assert;
/**
@@ -169,7 +170,7 @@ public class TestUtils {
} else if (expected == 0.0) {
Assert.assertEquals(msg, actual, expected, relativeError);
} else {
- double absError = FastMath.abs(expected) * relativeError;
+ double absError = AccurateMath.abs(expected) * relativeError;
Assert.assertEquals(msg, expected, actual, absError);
}
}
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/analysis/FunctionUtilsTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/analysis/FunctionUtilsTest.java
index 01ffeb0eb..17b749cd3 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/analysis/FunctionUtilsTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/analysis/FunctionUtilsTest.java
@@ -39,7 +39,7 @@ import org.apache.commons.math4.legacy.analysis.function.Sinc;
import org.apache.commons.math4.legacy.exception.DimensionMismatchException;
import org.apache.commons.math4.legacy.exception.NotStrictlyPositiveException;
import org.apache.commons.math4.legacy.exception.NumberIsTooLargeException;
-import org.apache.commons.math4.legacy.util.FastMath;
+import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
import org.junit.Assert;
import org.junit.Test;
@@ -47,7 +47,7 @@ import org.junit.Test;
* Test for {@link FunctionUtils}.
*/
public class FunctionUtilsTest {
- private final double EPS = FastMath.ulp(1d);
+ private final double EPS = AccurateMath.ulp(1d);
@Test
public void testCompose() {
@@ -114,7 +114,7 @@ public class FunctionUtilsTest {
UnivariateDifferentiableFunction inv = new Inverse();
final double a = 123.456;
- Assert.assertEquals(- 1 / (a * a) -1 + FastMath.cos(a),
+ Assert.assertEquals(- 1 / (a * a) -1 + AccurateMath.cos(a),
FunctionUtils.add(inv, m, c, sin).value(new DerivativeStructure(1, 1, 0, a)).getPartialDerivative(1),
EPS);
}
@@ -139,11 +139,11 @@ public class FunctionUtilsTest {
UnivariateDifferentiableFunction inv = new Inverse();
UnivariateDifferentiableFunction pow = new Power(2.5);
UnivariateDifferentiableFunction cos = new Cos();
- Assert.assertEquals(1.5 * FastMath.sqrt(a) * FastMath.cos(a) - FastMath.pow(a, 1.5) * FastMath.sin(a),
+ Assert.assertEquals(1.5 * AccurateMath.sqrt(a) * AccurateMath.cos(a) - AccurateMath.pow(a, 1.5) * AccurateMath.sin(a),
FunctionUtils.multiply(inv, pow, cos).value(new DerivativeStructure(1, 1, 0, a)).getPartialDerivative(1), EPS);
UnivariateDifferentiableFunction cosh = new Cosh();
- Assert.assertEquals(1.5 * FastMath.sqrt(a) * FastMath.cosh(a) + FastMath.pow(a, 1.5) * FastMath.sinh(a),
+ Assert.assertEquals(1.5 * AccurateMath.sqrt(a) * AccurateMath.cosh(a) + AccurateMath.pow(a, 1.5) * AccurateMath.sinh(a),
FunctionUtils.multiply(inv, pow, cosh).value(new DerivativeStructure(1, 1, 0, a)).getPartialDerivative(1), 8 * EPS);
}
@@ -189,7 +189,7 @@ public class FunctionUtilsTest {
UnivariateFunction sinc2 = new Sinc();
for (int i = 0; i < 10; i++) {
- double x = FastMath.random();
+ double x = AccurateMath.random();
Assert.assertEquals(sinc1.value(x), sinc2.value(x), EPS);
}
}
@@ -203,7 +203,7 @@ public class FunctionUtilsTest {
UnivariateFunction pow2 = FunctionUtils.fix2ndArgument(new Pow(), 2);
for (int i = 0; i < 10; i++) {
- double x = FastMath.random() * 10;
+ double x = AccurateMath.random() * 10;
Assert.assertEquals(pow1.value(x), pow2.value(x), 0);
}
}
@@ -235,10 +235,10 @@ public class FunctionUtilsTest {
// x = sin(t)
DerivativeStructure dsT = new DerivativeStructure(1, 2, 0, t);
DerivativeStructure y = f.value(dsT.sin());
- Assert.assertEquals(FastMath.sin(t) * FastMath.sin(t), f.value(FastMath.sin(t)), 1.0e-15);
- Assert.assertEquals(FastMath.sin(t) * FastMath.sin(t), y.getValue(), 1.0e-15);
- Assert.assertEquals(2 * FastMath.cos(t) * FastMath.sin(t), y.getPartialDerivative(1), 1.0e-15);
- Assert.assertEquals(2 * (1 - 2 * FastMath.sin(t) * FastMath.sin(t)), y.getPartialDerivative(2), 1.0e-15);
+ Assert.assertEquals(AccurateMath.sin(t) * AccurateMath.sin(t), f.value(AccurateMath.sin(t)), 1.0e-15);
+ Assert.assertEquals(AccurateMath.sin(t) * AccurateMath.sin(t), y.getValue(), 1.0e-15);
+ Assert.assertEquals(2 * AccurateMath.cos(t) * AccurateMath.sin(t), y.getPartialDerivative(1), 1.0e-15);
+ Assert.assertEquals(2 * (1 - 2 * AccurateMath.sin(t) * AccurateMath.sin(t)), y.getPartialDerivative(2), 1.0e-15);
}
try {
@@ -273,8 +273,8 @@ public class FunctionUtilsTest {
// x = sin(t), y = cos(t), hence the method really becomes univariate
DerivativeStructure dsT = new DerivativeStructure(1, 1, 0, t);
DerivativeStructure y = mdf.value(new DerivativeStructure[] { dsT.sin(), dsT.cos() });
- Assert.assertEquals(a * FastMath.sin(t) + b * FastMath.cos(t), y.getValue(), 1.0e-15);
- Assert.assertEquals(a * FastMath.cos(t) - b * FastMath.sin(t), y.getPartialDerivative(1), 1.0e-15);
+ Assert.assertEquals(a * AccurateMath.sin(t) + b * AccurateMath.cos(t), y.getValue(), 1.0e-15);
+ Assert.assertEquals(a * AccurateMath.cos(t) - b * AccurateMath.sin(t), y.getPartialDerivative(1), 1.0e-15);
}
for (double u = -1.0; u < 1; u += 0.01) {
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/analysis/differentiation/DerivativeStructureTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/analysis/differentiation/DerivativeStructureTest.java
index 0e907447d..454d3c9bb 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/analysis/differentiation/DerivativeStructureTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/analysis/differentiation/DerivativeStructureTest.java
@@ -20,7 +20,7 @@ package org.apache.commons.math4.legacy.analysis.differentiation;
import java.util.Arrays;
import java.util.List;
-import org.apache.commons.math4.legacy.ExtendedFieldElementAbstractTest;
+import org.apache.commons.math4.legacy.field.ExtendedFieldElementAbstractTest;
import org.apache.commons.math4.legacy.TestUtils;
import org.apache.commons.math4.legacy.analysis.polynomials.PolynomialFunction;
import org.apache.commons.math4.legacy.exception.DimensionMismatchException;
@@ -29,7 +29,7 @@ import org.apache.commons.rng.UniformRandomProvider;
import org.apache.commons.rng.simple.RandomSource;
import org.apache.commons.numbers.core.ArithmeticUtils;
import org.apache.commons.numbers.combinatorics.Factorial;
-import org.apache.commons.math4.legacy.util.FastMath;
+import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
import org.apache.commons.numbers.core.Precision;
import org.junit.Assert;
import org.junit.Test;
@@ -86,8 +86,8 @@ public class DerivativeStructureTest extends ExtendedFieldElementAbstractTest 0) {
- double f1 = 1 / (2 * FastMath.sqrt(x * y));
- Assert.assertEquals(f1, f.getPartialDerivative(1), FastMath.abs(epsilon * f1));
+ double f1 = 1 / (2 * AccurateMath.sqrt(x * y));
+ Assert.assertEquals(f1, f.getPartialDerivative(1), AccurateMath.abs(epsilon * f1));
if (f.getOrder() > 1) {
double f2 = -f1 / (2 * x);
- Assert.assertEquals(f2, f.getPartialDerivative(2), FastMath.abs(epsilon * f2));
+ Assert.assertEquals(f2, f.getPartialDerivative(2), AccurateMath.abs(epsilon * f2));
if (f.getOrder() > 2) {
double f3 = (f0 + x / (2 * y * f0)) / (4 * x * x * x);
- Assert.assertEquals(f3, f.getPartialDerivative(3), FastMath.abs(epsilon * f3));
+ Assert.assertEquals(f3, f.getPartialDerivative(3), AccurateMath.abs(epsilon * f3));
}
}
}
@@ -454,30 +454,30 @@ public class DerivativeStructureTest extends ExtendedFieldElementAbstractTest 0) {
- double dfdx = FastMath.cos(x / a) / a;
- Assert.assertEquals(dfdx, f.getPartialDerivative(1, 0, 0), FastMath.abs(epsilon * dfdx));
- double dfdy = x * FastMath.sin(y) * dfdx / a;
- Assert.assertEquals(dfdy, f.getPartialDerivative(0, 1, 0), FastMath.abs(epsilon * dfdy));
- double cz = FastMath.cos(z);
+ double dfdx = AccurateMath.cos(x / a) / a;
+ Assert.assertEquals(dfdx, f.getPartialDerivative(1, 0, 0), AccurateMath.abs(epsilon * dfdx));
+ double dfdy = x * AccurateMath.sin(y) * dfdx / a;
+ Assert.assertEquals(dfdy, f.getPartialDerivative(0, 1, 0), AccurateMath.abs(epsilon * dfdy));
+ double cz = AccurateMath.cos(z);
double cz2 = cz * cz;
double dfdz = -x * dfdx / (a * cz2);
- Assert.assertEquals(dfdz, f.getPartialDerivative(0, 0, 1), FastMath.abs(epsilon * dfdz));
+ Assert.assertEquals(dfdz, f.getPartialDerivative(0, 0, 1), AccurateMath.abs(epsilon * dfdz));
if (f.getOrder() > 1) {
double df2dx2 = -(f0 / (a * a));
- Assert.assertEquals(df2dx2, f.getPartialDerivative(2, 0, 0), FastMath.abs(epsilon * df2dx2));
- double df2dy2 = x * FastMath.cos(y) * dfdx / a -
- x * x * FastMath.sin(y) * FastMath.sin(y) * f0 / (a * a * a * a) +
- 2 * FastMath.sin(y) * dfdy / a;
- Assert.assertEquals(df2dy2, f.getPartialDerivative(0, 2, 0), FastMath.abs(epsilon * df2dy2));
+ Assert.assertEquals(df2dx2, f.getPartialDerivative(2, 0, 0), AccurateMath.abs(epsilon * df2dx2));
+ double df2dy2 = x * AccurateMath.cos(y) * dfdx / a -
+ x * x * AccurateMath.sin(y) * AccurateMath.sin(y) * f0 / (a * a * a * a) +
+ 2 * AccurateMath.sin(y) * dfdy / a;
+ Assert.assertEquals(df2dy2, f.getPartialDerivative(0, 2, 0), AccurateMath.abs(epsilon * df2dy2));
double c4 = cz2 * cz2;
- double df2dz2 = x * (2 * a * (1 - a * cz * FastMath.sin(z)) * dfdx - x * f0 / a ) / (a * a * a * c4);
- Assert.assertEquals(df2dz2, f.getPartialDerivative(0, 0, 2), FastMath.abs(epsilon * df2dz2));
- double df2dxdy = dfdy / x - x * FastMath.sin(y) * f0 / (a * a * a);
- Assert.assertEquals(df2dxdy, f.getPartialDerivative(1, 1, 0), FastMath.abs(epsilon * df2dxdy));
+ double df2dz2 = x * (2 * a * (1 - a * cz * AccurateMath.sin(z)) * dfdx - x * f0 / a ) / (a * a * a * c4);
+ Assert.assertEquals(df2dz2, f.getPartialDerivative(0, 0, 2), AccurateMath.abs(epsilon * df2dz2));
+ double df2dxdy = dfdy / x - x * AccurateMath.sin(y) * f0 / (a * a * a);
+ Assert.assertEquals(df2dxdy, f.getPartialDerivative(1, 1, 0), AccurateMath.abs(epsilon * df2dxdy));
}
}
}
@@ -542,7 +542,7 @@ public class DerivativeStructureTest extends ExtendedFieldElementAbstractTest 0) {
double f1 = -x / (2 * y * y * f0);
- Assert.assertEquals(f1, f.getPartialDerivative(1), FastMath.abs(epsilon * f1));
+ Assert.assertEquals(f1, f.getPartialDerivative(1), AccurateMath.abs(epsilon * f1));
if (f.getOrder() > 1) {
double f2 = (f0 - x / (4 * y * f0)) / (y * y);
- Assert.assertEquals(f2, f.getPartialDerivative(2), FastMath.abs(epsilon * f2));
+ Assert.assertEquals(f2, f.getPartialDerivative(2), AccurateMath.abs(epsilon * f2));
if (f.getOrder() > 2) {
double f3 = (x / (8 * y * f0) - 2 * f0) / (y * y * y);
- Assert.assertEquals(f3, f.getPartialDerivative(3), FastMath.abs(epsilon * f3));
+ Assert.assertEquals(f3, f.getPartialDerivative(3), AccurateMath.abs(epsilon * f3));
}
}
}
@@ -1184,8 +1184,8 @@ public class DerivativeStructureTest extends ExtendedFieldElementAbstractTest 0) {
- prod *= FastMath.cos(xOverPow2);
+ prod *= AccurateMath.cos(xOverPow2);
xOverPow2 /= 2;
}
Assert.assertEquals(prod, s.value(x), 1e-13);
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/analysis/function/SqrtTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/analysis/function/SqrtTest.java
index f0f9c9b46..dc88b73f0 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/analysis/function/SqrtTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/analysis/function/SqrtTest.java
@@ -19,7 +19,7 @@ package org.apache.commons.math4.legacy.analysis.function;
import org.apache.commons.math4.legacy.analysis.UnivariateFunction;
import org.apache.commons.math4.legacy.analysis.differentiation.DerivativeStructure;
import org.apache.commons.math4.legacy.analysis.differentiation.UnivariateDifferentiableFunction;
-import org.apache.commons.math4.legacy.util.FastMath;
+import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
import org.junit.Assert;
import org.junit.Test;
@@ -30,7 +30,7 @@ public class SqrtTest {
final UnivariateFunction f = new UnivariateFunction() {
@Override
public double value(double x) {
- return FastMath.sqrt(x);
+ return AccurateMath.sqrt(x);
}
};
@@ -47,14 +47,14 @@ public class SqrtTest {
final UnivariateFunction f = new UnivariateFunction() {
@Override
public double value(double x) {
- return 1 / (2 * FastMath.sqrt(x));
+ return 1 / (2 * AccurateMath.sqrt(x));
}
};
for (double x = 1e-30; x < 1e10; x *= 2) {
final double fX = f.value(x);
final double sX = sPrime.value(new DerivativeStructure(1, 1, 0, x)).getPartialDerivative(1);
- Assert.assertEquals("x=" + x, fX, sX, FastMath.ulp(fX));
+ Assert.assertEquals("x=" + x, fX, sX, AccurateMath.ulp(fX));
}
}
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/analysis/function/UnivariateDifferentiableFunctionTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/analysis/function/UnivariateDifferentiableFunctionTest.java
index da070cc80..aebbd6625 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/analysis/function/UnivariateDifferentiableFunctionTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/analysis/function/UnivariateDifferentiableFunctionTest.java
@@ -18,7 +18,7 @@
package org.apache.commons.math4.legacy.analysis.function;
import org.apache.commons.math4.legacy.analysis.differentiation.DerivativeStructure;
-import org.apache.commons.math4.legacy.util.FastMath;
+import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
import org.junit.Assert;
import org.junit.Test;
@@ -32,10 +32,10 @@ public class UnivariateDifferentiableFunctionTest {
@Test
public void testAcos() {
Acos acos = new Acos();
- Assert.assertEquals(FastMath.PI/3, acos.value(0.5), EPS);
- Assert.assertEquals(FastMath.PI/4, acos.value(Double.valueOf(1/FastMath.sqrt(2))), EPS);
+ Assert.assertEquals(AccurateMath.PI/3, acos.value(0.5), EPS);
+ Assert.assertEquals(AccurateMath.PI/4, acos.value(Double.valueOf(1/AccurateMath.sqrt(2))), EPS);
double a = 0.5;
- Assert.assertEquals(-1/FastMath.sqrt(1-FastMath.pow(a,2)), acos.value(new DerivativeStructure(1,1,0,a)).getPartialDerivative(1), EPS);
+ Assert.assertEquals(-1/AccurateMath.sqrt(1-AccurateMath.pow(a,2)), acos.value(new DerivativeStructure(1,1,0,a)).getPartialDerivative(1), EPS);
}
@Test
@@ -43,48 +43,48 @@ public class UnivariateDifferentiableFunctionTest {
Acosh acosh = new Acosh();
Assert.assertEquals(0,acosh.value(1), EPS);
double a = 1.2345;
- Assert.assertEquals(a,acosh.value(FastMath.cosh(a)), EPS);
- Assert.assertEquals(1/(FastMath.sqrt(a-1)*FastMath.sqrt(a+1)),acosh.value(new DerivativeStructure(1,1,0,a)).getPartialDerivative(1), EPS);
+ Assert.assertEquals(a,acosh.value(AccurateMath.cosh(a)), EPS);
+ Assert.assertEquals(1/(AccurateMath.sqrt(a-1)*AccurateMath.sqrt(a+1)),acosh.value(new DerivativeStructure(1,1,0,a)).getPartialDerivative(1), EPS);
}
@Test
public void testAsin() {
Asin asin = new Asin();
double a = 1.2345;
- Assert.assertEquals(a, asin.value(FastMath.sin(a)), EPS);
- Assert.assertEquals(1/FastMath.sqrt(1 - FastMath.pow(a,2)), asin.value(new DerivativeStructure(1,1,0,a)).getPartialDerivative(1), EPS);
+ Assert.assertEquals(a, asin.value(AccurateMath.sin(a)), EPS);
+ Assert.assertEquals(1/AccurateMath.sqrt(1 - AccurateMath.pow(a,2)), asin.value(new DerivativeStructure(1,1,0,a)).getPartialDerivative(1), EPS);
}
@Test
public void testAsinh() {
Asinh asinh = new Asinh();
double a = 1.2345;
- Assert.assertEquals(a, asinh.value(FastMath.sinh(a)), EPS);
- Assert.assertEquals(1/FastMath.sqrt(FastMath.pow(a,2.0) + 1), asinh.value(new DerivativeStructure(1,1,0,a)).getPartialDerivative(1), EPS);
+ Assert.assertEquals(a, asinh.value(AccurateMath.sinh(a)), EPS);
+ Assert.assertEquals(1/AccurateMath.sqrt(AccurateMath.pow(a,2.0) + 1), asinh.value(new DerivativeStructure(1,1,0,a)).getPartialDerivative(1), EPS);
}
@Test
public void testAtan() {
Atan atan = new Atan();
double a = 1.2345;
- Assert.assertEquals(a, atan.value(FastMath.tan(a)), EPS);
- Assert.assertEquals(1/(FastMath.pow(a,2.0) + 1), atan.value(new DerivativeStructure(1,1,0,a)).getPartialDerivative(1), EPS);
+ Assert.assertEquals(a, atan.value(AccurateMath.tan(a)), EPS);
+ Assert.assertEquals(1/(AccurateMath.pow(a,2.0) + 1), atan.value(new DerivativeStructure(1,1,0,a)).getPartialDerivative(1), EPS);
}
@Test
public void testAtanh() {
Atanh atanh = new Atanh();
double a = 1.2345;
- Assert.assertEquals(a, atanh.value(FastMath.tanh(a)), EPS);
- Assert.assertEquals(1/(1 - FastMath.pow(a,2.0)), atanh.value(new DerivativeStructure(1,1,0,a)).getPartialDerivative(1), EPS);
+ Assert.assertEquals(a, atanh.value(AccurateMath.tanh(a)), EPS);
+ Assert.assertEquals(1/(1 - AccurateMath.pow(a,2.0)), atanh.value(new DerivativeStructure(1,1,0,a)).getPartialDerivative(1), EPS);
}
@Test
public void testCbrt() {
Cbrt cbrt = new Cbrt();
double a = 1.2345;
- Assert.assertEquals(a, cbrt.value(FastMath.pow(a,3)), EPS);
- Assert.assertEquals(1.0/(3.0*FastMath.pow(a, 2.0/3.0)), cbrt.value(new DerivativeStructure(1,1,0,a)).getPartialDerivative(1), EPS);
+ Assert.assertEquals(a, cbrt.value(AccurateMath.pow(a,3)), EPS);
+ Assert.assertEquals(1.0/(3.0*AccurateMath.pow(a, 2.0/3.0)), cbrt.value(new DerivativeStructure(1,1,0,a)).getPartialDerivative(1), EPS);
}
@Test
@@ -105,23 +105,23 @@ public class UnivariateDifferentiableFunctionTest {
public void testCos() {
Cos cos = new Cos();
double a = 0.987;
- Assert.assertEquals(a, cos.value(FastMath.acos(a)), EPS);
- Assert.assertEquals(-FastMath.sin(a), cos.value(new DerivativeStructure(1,1,0,a)).getPartialDerivative(1), EPS);
+ Assert.assertEquals(a, cos.value(AccurateMath.acos(a)), EPS);
+ Assert.assertEquals(-AccurateMath.sin(a), cos.value(new DerivativeStructure(1,1,0,a)).getPartialDerivative(1), EPS);
}
@Test
public void testCosh() {
Cosh cosh = new Cosh();
double a = 1.2345;
- Assert.assertEquals(a, cosh.value(FastMath.acosh(a)), EPS);
- Assert.assertEquals(FastMath.sinh(a), cosh.value(new DerivativeStructure(1,1,0,a)).getPartialDerivative(1), EPS);
+ Assert.assertEquals(a, cosh.value(AccurateMath.acosh(a)), EPS);
+ Assert.assertEquals(AccurateMath.sinh(a), cosh.value(new DerivativeStructure(1,1,0,a)).getPartialDerivative(1), EPS);
}
@Test
public void testExp() {
Exp exp= new Exp();
double a = 1.2345;
- Assert.assertEquals(a, exp.value(FastMath.log(a)), EPS);
+ Assert.assertEquals(a, exp.value(AccurateMath.log(a)), EPS);
Assert.assertEquals(exp.value(a), exp.value(new DerivativeStructure(1,1,0,a)).getPartialDerivative(1), EPS);
}
@@ -129,8 +129,8 @@ public class UnivariateDifferentiableFunctionTest {
public void testExpm1() {
Expm1 expm1 = new Expm1();
double a = 1.2345;
- Assert.assertEquals(a-1, expm1.value(FastMath.log(a)), EPS);
- Assert.assertEquals(FastMath.exp(a), expm1.value(new DerivativeStructure(1,1,0,a)).getPartialDerivative(1), EPS);
+ Assert.assertEquals(a-1, expm1.value(AccurateMath.log(a)), EPS);
+ Assert.assertEquals(AccurateMath.exp(a), expm1.value(new DerivativeStructure(1,1,0,a)).getPartialDerivative(1), EPS);
}
@Test
@@ -146,7 +146,7 @@ public class UnivariateDifferentiableFunctionTest {
Inverse inverse = new Inverse();
double a = 123.456;
Assert.assertEquals(1/a, inverse.value(a), EPS);
- Assert.assertEquals(-1/FastMath.pow(a,2), inverse.value(new DerivativeStructure(1,1,0,a)).getPartialDerivative(1), EPS);
+ Assert.assertEquals(-1/AccurateMath.pow(a,2), inverse.value(new DerivativeStructure(1,1,0,a)).getPartialDerivative(1), EPS);
}
@Test
@@ -161,15 +161,15 @@ public class UnivariateDifferentiableFunctionTest {
public void testLog10() {
Log10 log10 = new Log10();
double a =1.2345;
- Assert.assertEquals(a, log10.value(FastMath.pow(10, a)), EPS);
- Assert.assertEquals(1/(a*FastMath.log(10)), log10.value(new DerivativeStructure(1,1,0,a)).getPartialDerivative(1), EPS);
+ Assert.assertEquals(a, log10.value(AccurateMath.pow(10, a)), EPS);
+ Assert.assertEquals(1/(a*AccurateMath.log(10)), log10.value(new DerivativeStructure(1,1,0,a)).getPartialDerivative(1), EPS);
}
@Test
public void testLog1p() {
Log1p log1p = new Log1p();
double a = 1.2345;
- Assert.assertEquals(a+1,FastMath.exp(log1p.value(a)), EPS);
+ Assert.assertEquals(a+1,AccurateMath.exp(log1p.value(a)), EPS);
Assert.assertEquals(1/(1+a), log1p.value(new DerivativeStructure(1,1,0,a)).getPartialDerivative(1), EPS);
}
@@ -186,42 +186,42 @@ public class UnivariateDifferentiableFunctionTest {
Power squared = new Power(2);
Power power2_5 = new Power(2.5);
double a = 123.456;
- Assert.assertEquals(FastMath.pow(a,2), squared.value(a), EPS);
- Assert.assertEquals(FastMath.pow(a, 2.5), power2_5.value(a), EPS);
+ Assert.assertEquals(AccurateMath.pow(a,2), squared.value(a), EPS);
+ Assert.assertEquals(AccurateMath.pow(a, 2.5), power2_5.value(a), EPS);
Assert.assertEquals(2*a, squared.value(new DerivativeStructure(1,1,0,a)).getPartialDerivative(1), EPS);
- Assert.assertEquals(2.5*FastMath.pow(a,1.5), power2_5.value(new DerivativeStructure(1,1,0,a)).getPartialDerivative(1), EPS);
+ Assert.assertEquals(2.5*AccurateMath.pow(a,1.5), power2_5.value(new DerivativeStructure(1,1,0,a)).getPartialDerivative(1), EPS);
}
@Test
public void testSin() {
Sin sin = new Sin();
double a = 0.987;
- Assert.assertEquals(a, sin.value(FastMath.asin(a)), EPS);
- Assert.assertEquals(FastMath.cos(a), sin.value(new DerivativeStructure(1,1,0,a)).getPartialDerivative(1), EPS);
+ Assert.assertEquals(a, sin.value(AccurateMath.asin(a)), EPS);
+ Assert.assertEquals(AccurateMath.cos(a), sin.value(new DerivativeStructure(1,1,0,a)).getPartialDerivative(1), EPS);
}
@Test
public void testSinh() {
Sinh sinh = new Sinh();
double a = 1.2345;
- Assert.assertEquals(a, sinh.value(FastMath.asinh(a)), EPS);
- Assert.assertEquals(FastMath.cosh(a), sinh.value(new DerivativeStructure(1,1,0,a)).getPartialDerivative(1), EPS);
+ Assert.assertEquals(a, sinh.value(AccurateMath.asinh(a)), EPS);
+ Assert.assertEquals(AccurateMath.cosh(a), sinh.value(new DerivativeStructure(1,1,0,a)).getPartialDerivative(1), EPS);
}
@Test
public void testTan() {
Tan tan = new Tan();
double a = 0.987;
- Assert.assertEquals(a, tan.value(FastMath.atan(a)), EPS);
- Assert.assertEquals(1/(FastMath.pow(FastMath.cos(a),2)), tan.value(new DerivativeStructure(1,1,0,a)).getPartialDerivative(1), EPS);
+ Assert.assertEquals(a, tan.value(AccurateMath.atan(a)), EPS);
+ Assert.assertEquals(1/(AccurateMath.pow(AccurateMath.cos(a),2)), tan.value(new DerivativeStructure(1,1,0,a)).getPartialDerivative(1), EPS);
}
@Test
public void testTanh() {
Tanh tanh = new Tanh();
double a = 0.987;
- Assert.assertEquals(a, tanh.value(FastMath.atanh(a)), EPS);
- Assert.assertEquals(1/FastMath.pow(FastMath.cosh(a),2), tanh.value(new DerivativeStructure(1,1,0,a)).getPartialDerivative(1), EPS);
+ Assert.assertEquals(a, tanh.value(AccurateMath.atanh(a)), EPS);
+ Assert.assertEquals(1/AccurateMath.pow(AccurateMath.cosh(a),2), tanh.value(new DerivativeStructure(1,1,0,a)).getPartialDerivative(1), EPS);
}
}
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/analysis/function/UnivariateFunctionTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/analysis/function/UnivariateFunctionTest.java
index b75b5cbd4..d19d1aa0f 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/analysis/function/UnivariateFunctionTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/analysis/function/UnivariateFunctionTest.java
@@ -18,7 +18,7 @@
package org.apache.commons.math4.legacy.analysis.function;
import org.apache.commons.math4.legacy.analysis.UnivariateFunction;
-import org.apache.commons.math4.legacy.util.FastMath;
+import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
import org.junit.Assert;
import org.junit.Test;
@@ -118,7 +118,7 @@ public class UnivariateFunctionTest {
}
private double expectedUlp(double x) {
- return FastMath.abs(x - Double.longBitsToDouble(Double.doubleToRawLongBits(x) ^ 1));
+ return AccurateMath.abs(x - Double.longBitsToDouble(Double.doubleToRawLongBits(x) ^ 1));
}
}
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/analysis/integration/IterativeLegendreGaussIntegratorTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/analysis/integration/IterativeLegendreGaussIntegratorTest.java
index 8cb995c9d..f00e8f52f 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/analysis/integration/IterativeLegendreGaussIntegratorTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/analysis/integration/IterativeLegendreGaussIntegratorTest.java
@@ -24,7 +24,7 @@ import org.apache.commons.math4.legacy.analysis.function.Gaussian;
import org.apache.commons.math4.legacy.analysis.function.Sin;
import org.apache.commons.math4.legacy.analysis.polynomials.PolynomialFunction;
import org.apache.commons.math4.legacy.exception.TooManyEvaluationsException;
-import org.apache.commons.math4.legacy.util.FastMath;
+import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
import org.junit.Assert;
import org.junit.Test;
@@ -38,15 +38,15 @@ public class IterativeLegendreGaussIntegratorTest {
= new IterativeLegendreGaussIntegrator(5, 1.0e-14, 1.0e-10, 2, 15);
double min, max, expected, result, tolerance;
- min = 0; max = FastMath.PI; expected = 2;
- tolerance = FastMath.max(integrator.getAbsoluteAccuracy(),
- FastMath.abs(expected * integrator.getRelativeAccuracy()));
+ min = 0; max = AccurateMath.PI; expected = 2;
+ tolerance = AccurateMath.max(integrator.getAbsoluteAccuracy(),
+ AccurateMath.abs(expected * integrator.getRelativeAccuracy()));
result = integrator.integrate(10000, f, min, max);
Assert.assertEquals(expected, result, tolerance);
- min = -FastMath.PI/3; max = 0; expected = -0.5;
- tolerance = FastMath.max(integrator.getAbsoluteAccuracy(),
- FastMath.abs(expected * integrator.getRelativeAccuracy()));
+ min = -AccurateMath.PI/3; max = 0; expected = -0.5;
+ tolerance = AccurateMath.max(integrator.getAbsoluteAccuracy(),
+ AccurateMath.abs(expected * integrator.getRelativeAccuracy()));
result = integrator.integrate(10000, f, min, max);
Assert.assertEquals(expected, result, tolerance);
}
@@ -96,7 +96,7 @@ public class IterativeLegendreGaussIntegratorTest {
PolynomialFunction p = new PolynomialFunction(coeff);
double result = integrator.integrate(10000, p, -5.0, 15.0);
double reference = exactIntegration(p, -5.0, 15.0);
- Assert.assertEquals(n + " " + degree + " " + i, reference, result, 1.0e-12 * (1.0 + FastMath.abs(reference)));
+ Assert.assertEquals(n + " " + degree + " " + i, reference, result, 1.0e-12 * (1.0 + AccurateMath.abs(reference)));
}
}
@@ -108,7 +108,7 @@ public class IterativeLegendreGaussIntegratorTest {
public void testNormalDistributionWithLargeSigma() {
final double sigma = 1000;
final double mean = 0;
- final double factor = 1 / (sigma * FastMath.sqrt(2 * FastMath.PI));
+ final double factor = 1 / (sigma * AccurateMath.sqrt(2 * AccurateMath.PI));
final UnivariateFunction normal = new Gaussian(factor, mean, sigma);
final double tol = 1e-2;
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/analysis/integration/MidPointIntegratorTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/analysis/integration/MidPointIntegratorTest.java
index bfb90801d..a6d9ae7a0 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/analysis/integration/MidPointIntegratorTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/analysis/integration/MidPointIntegratorTest.java
@@ -21,7 +21,7 @@ import org.apache.commons.math4.legacy.analysis.UnivariateFunction;
import org.apache.commons.math4.legacy.analysis.function.Sin;
import org.apache.commons.math4.legacy.exception.NumberIsTooLargeException;
import org.apache.commons.math4.legacy.exception.NumberIsTooSmallException;
-import org.apache.commons.math4.legacy.util.FastMath;
+import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
import org.junit.Assert;
import org.junit.Test;
@@ -51,7 +51,7 @@ public final class MidPointIntegratorTest {
* (3^(n + 1) - 1) / 2 evaluations; just under 50% more.
*/
private long expectedEvaluations(int iterations) {
- return (long) FastMath.pow(3, iterations);
+ return (long) AccurateMath.pow(3, iterations);
}
/**
@@ -65,7 +65,7 @@ public final class MidPointIntegratorTest {
double min = -10;
double max = -9;
double expected = -3697001.0 / 48.0;
- double tolerance = FastMath.abs(expected * integrator.getRelativeAccuracy());
+ double tolerance = AccurateMath.abs(expected * integrator.getRelativeAccuracy());
double result = integrator.integrate(Integer.MAX_VALUE, f, min, max);
Assert.assertTrue(integrator.getEvaluations() < Integer.MAX_VALUE / 3);
Assert.assertTrue(integrator.getIterations() < NUM_ITER);
@@ -83,19 +83,19 @@ public final class MidPointIntegratorTest {
UnivariateIntegrator integrator = new MidPointIntegrator();
double min = 0;
- double max = FastMath.PI;
+ double max = AccurateMath.PI;
double expected = 2;
- double tolerance = FastMath.abs(expected * integrator.getRelativeAccuracy());
+ double tolerance = AccurateMath.abs(expected * integrator.getRelativeAccuracy());
double result = integrator.integrate(Integer.MAX_VALUE, f, min, max);
Assert.assertTrue(integrator.getEvaluations() < Integer.MAX_VALUE / 3);
Assert.assertTrue(integrator.getIterations() < NUM_ITER);
Assert.assertEquals(expectedEvaluations(integrator.getIterations()), integrator.getEvaluations());
Assert.assertEquals(expected, result, tolerance);
- min = -FastMath.PI/3;
+ min = -AccurateMath.PI/3;
max = 0;
expected = -0.5;
- tolerance = FastMath.abs(expected * integrator.getRelativeAccuracy());
+ tolerance = AccurateMath.abs(expected * integrator.getRelativeAccuracy());
result = integrator.integrate(Integer.MAX_VALUE, f, min, max);
Assert.assertTrue(integrator.getEvaluations() < Integer.MAX_VALUE / 3);
Assert.assertTrue(integrator.getIterations() < NUM_ITER);
@@ -115,7 +115,7 @@ public final class MidPointIntegratorTest {
double min = 0;
double max = 1;
double expected = -1.0 / 48;
- double tolerance = FastMath.abs(expected * integrator.getRelativeAccuracy());
+ double tolerance = AccurateMath.abs(expected * integrator.getRelativeAccuracy());
double result = integrator.integrate(Integer.MAX_VALUE, f, min, max);
Assert.assertTrue(integrator.getEvaluations() < Integer.MAX_VALUE / 3);
Assert.assertTrue(integrator.getIterations() < NUM_ITER);
@@ -125,7 +125,7 @@ public final class MidPointIntegratorTest {
min = 0;
max = 0.5;
expected = 11.0 / 768;
- tolerance = FastMath.abs(expected * integrator.getRelativeAccuracy());
+ tolerance = AccurateMath.abs(expected * integrator.getRelativeAccuracy());
result = integrator.integrate(Integer.MAX_VALUE, f, min, max);
Assert.assertTrue(integrator.getEvaluations() < Integer.MAX_VALUE / 3);
Assert.assertTrue(integrator.getIterations() < NUM_ITER);
@@ -134,7 +134,7 @@ public final class MidPointIntegratorTest {
min = -1;
max = 4;
expected = 2048 / 3.0 - 78 + 1.0 / 48;
- tolerance = FastMath.abs(expected * integrator.getRelativeAccuracy());
+ tolerance = AccurateMath.abs(expected * integrator.getRelativeAccuracy());
result = integrator.integrate(Integer.MAX_VALUE, f, min, max);
Assert.assertTrue(integrator.getEvaluations() < Integer.MAX_VALUE / 3);
Assert.assertTrue(integrator.getIterations() < NUM_ITER);
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/analysis/integration/RombergIntegratorTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/analysis/integration/RombergIntegratorTest.java
index 297f10e58..2ac0361eb 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/analysis/integration/RombergIntegratorTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/analysis/integration/RombergIntegratorTest.java
@@ -21,7 +21,7 @@ import org.apache.commons.math4.legacy.analysis.UnivariateFunction;
import org.apache.commons.math4.legacy.analysis.function.Sin;
import org.apache.commons.math4.legacy.exception.NumberIsTooLargeException;
import org.apache.commons.math4.legacy.exception.NumberIsTooSmallException;
-import org.apache.commons.math4.legacy.util.FastMath;
+import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
import org.junit.Assert;
import org.junit.Test;
@@ -45,15 +45,15 @@ public final class RombergIntegratorTest {
UnivariateIntegrator integrator = new RombergIntegrator();
double min, max, expected, result, tolerance;
- min = 0; max = FastMath.PI; expected = 2;
- tolerance = FastMath.abs(expected * integrator.getRelativeAccuracy());
+ min = 0; max = AccurateMath.PI; expected = 2;
+ tolerance = AccurateMath.abs(expected * integrator.getRelativeAccuracy());
result = integrator.integrate(100, f, min, max);
Assert.assertTrue(integrator.getEvaluations() < 50);
Assert.assertTrue(integrator.getIterations() < 10);
Assert.assertEquals(expected, result, tolerance);
- min = -FastMath.PI/3; max = 0; expected = -0.5;
- tolerance = FastMath.abs(expected * integrator.getRelativeAccuracy());
+ min = -AccurateMath.PI/3; max = 0; expected = -0.5;
+ tolerance = AccurateMath.abs(expected * integrator.getRelativeAccuracy());
result = integrator.integrate(100, f, min, max);
Assert.assertTrue(integrator.getEvaluations() < 50);
Assert.assertTrue(integrator.getIterations() < 10);
@@ -70,21 +70,21 @@ public final class RombergIntegratorTest {
double min, max, expected, result, tolerance;
min = 0; max = 1; expected = -1.0/48;
- tolerance = FastMath.abs(expected * integrator.getRelativeAccuracy());
+ tolerance = AccurateMath.abs(expected * integrator.getRelativeAccuracy());
result = integrator.integrate(100, f, min, max);
Assert.assertTrue(integrator.getEvaluations() < 10);
Assert.assertTrue(integrator.getIterations() < 5);
Assert.assertEquals(expected, result, tolerance);
min = 0; max = 0.5; expected = 11.0/768;
- tolerance = FastMath.abs(expected * integrator.getRelativeAccuracy());
+ tolerance = AccurateMath.abs(expected * integrator.getRelativeAccuracy());
result = integrator.integrate(100, f, min, max);
Assert.assertTrue(integrator.getEvaluations() < 10);
Assert.assertTrue(integrator.getIterations() < 5);
Assert.assertEquals(expected, result, tolerance);
min = -1; max = 4; expected = 2048/3.0 - 78 + 1.0/48;
- tolerance = FastMath.abs(expected * integrator.getRelativeAccuracy());
+ tolerance = AccurateMath.abs(expected * integrator.getRelativeAccuracy());
result = integrator.integrate(100, f, min, max);
Assert.assertTrue(integrator.getEvaluations() < 10);
Assert.assertTrue(integrator.getIterations() < 5);
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/analysis/integration/SimpsonIntegratorTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/analysis/integration/SimpsonIntegratorTest.java
index 3ecf35c93..672db79c1 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/analysis/integration/SimpsonIntegratorTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/analysis/integration/SimpsonIntegratorTest.java
@@ -23,7 +23,7 @@ import org.apache.commons.math4.legacy.analysis.function.Inverse;
import org.apache.commons.math4.legacy.analysis.function.Sin;
import org.apache.commons.math4.legacy.exception.NumberIsTooLargeException;
import org.apache.commons.math4.legacy.exception.NumberIsTooSmallException;
-import org.apache.commons.math4.legacy.util.FastMath;
+import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
import org.junit.Assert;
import org.junit.Test;
@@ -46,15 +46,15 @@ public final class SimpsonIntegratorTest {
UnivariateIntegrator integrator = new SimpsonIntegrator();
double min, max, expected, result, tolerance;
- min = 0; max = FastMath.PI; expected = 2;
- tolerance = FastMath.abs(expected * integrator.getRelativeAccuracy());
+ min = 0; max = AccurateMath.PI; expected = 2;
+ tolerance = AccurateMath.abs(expected * integrator.getRelativeAccuracy());
result = integrator.integrate(1000, f, min, max);
Assert.assertTrue(integrator.getEvaluations() < 100);
Assert.assertTrue(integrator.getIterations() < 10);
Assert.assertEquals(expected, result, tolerance);
- min = -FastMath.PI/3; max = 0; expected = -0.5;
- tolerance = FastMath.abs(expected * integrator.getRelativeAccuracy());
+ min = -AccurateMath.PI/3; max = 0; expected = -0.5;
+ tolerance = AccurateMath.abs(expected * integrator.getRelativeAccuracy());
result = integrator.integrate(1000, f, min, max);
Assert.assertTrue(integrator.getEvaluations() < 50);
Assert.assertTrue(integrator.getIterations() < 10);
@@ -71,21 +71,21 @@ public final class SimpsonIntegratorTest {
double min, max, expected, result, tolerance;
min = 0; max = 1; expected = -1.0/48;
- tolerance = FastMath.abs(expected * integrator.getRelativeAccuracy());
+ tolerance = AccurateMath.abs(expected * integrator.getRelativeAccuracy());
result = integrator.integrate(1000, f, min, max);
Assert.assertTrue(integrator.getEvaluations() < 150);
Assert.assertTrue(integrator.getIterations() < 10);
Assert.assertEquals(expected, result, tolerance);
min = 0; max = 0.5; expected = 11.0/768;
- tolerance = FastMath.abs(expected * integrator.getRelativeAccuracy());
+ tolerance = AccurateMath.abs(expected * integrator.getRelativeAccuracy());
result = integrator.integrate(1000, f, min, max);
Assert.assertTrue(integrator.getEvaluations() < 100);
Assert.assertTrue(integrator.getIterations() < 10);
Assert.assertEquals(expected, result, tolerance);
min = -1; max = 4; expected = 2048/3.0 - 78 + 1.0/48;
- tolerance = FastMath.abs(expected * integrator.getRelativeAccuracy());
+ tolerance = AccurateMath.abs(expected * integrator.getRelativeAccuracy());
result = integrator.integrate(1000, f, min, max);
Assert.assertTrue(integrator.getEvaluations() < 150);
Assert.assertTrue(integrator.getIterations() < 10);
@@ -162,7 +162,7 @@ public final class SimpsonIntegratorTest {
double min, max, expected, result, tolerance;
min = 0; max = 1; expected = 0.5;
- tolerance = FastMath.abs(expected * integrator.getRelativeAccuracy());
+ tolerance = AccurateMath.abs(expected * integrator.getRelativeAccuracy());
result = integrator.integrate(1000, f, min, max);
// MATH-1458: No iterations were performed when minimalIterationCount==1
Assert.assertTrue("Iteration is not above 0",
@@ -244,7 +244,7 @@ public final class SimpsonIntegratorTest {
double f01 = f.value(a + 1 * h);
double f0n = f.value(b);
expected = (b_a / 6) * (f00 + 4 * f01 + f0n);
- tolerance = FastMath.abs(expected * SimpsonIntegrator.DEFAULT_RELATIVE_ACCURACY);
+ tolerance = AccurateMath.abs(expected * SimpsonIntegrator.DEFAULT_RELATIVE_ACCURACY);
result = computeSimpsonIteration(f, a, b, 0);
Assert.assertEquals("Result", expected, result, tolerance);
@@ -253,7 +253,7 @@ public final class SimpsonIntegratorTest {
double f11 = f.value(a + 1 * h);
double f13 = f.value(a + 3 * h);
expected = (h / 3) * (f00 + 4 * f11 + 2 * f01 + 4 * f13 + f0n);
- tolerance = FastMath.abs(expected * SimpsonIntegrator.DEFAULT_RELATIVE_ACCURACY);
+ tolerance = AccurateMath.abs(expected * SimpsonIntegrator.DEFAULT_RELATIVE_ACCURACY);
result = computeSimpsonIteration(f, a, b, 1);
Assert.assertEquals("Result", expected, result, tolerance);
@@ -265,7 +265,7 @@ public final class SimpsonIntegratorTest {
double f27 = f.value(a + 7 * h);
expected = (h / 3) * (f00 + 4 * f21 + 2 * f11 + 4 * f23 + 2 * f01 + 4 * f25 +
2 * f13 + 4 * f27 + f0n);
- tolerance = FastMath.abs(expected * SimpsonIntegrator.DEFAULT_RELATIVE_ACCURACY);
+ tolerance = AccurateMath.abs(expected * SimpsonIntegrator.DEFAULT_RELATIVE_ACCURACY);
result = computeSimpsonIteration(f, a, b, 2);
Assert.assertEquals("Result", expected, result, tolerance);
}
@@ -295,7 +295,7 @@ public final class SimpsonIntegratorTest {
// Check the sum is as expected
expected = computeSimpsonIteration(f, min, max, 1);
- tolerance = FastMath.abs(expected * SimpsonIntegrator.DEFAULT_RELATIVE_ACCURACY);
+ tolerance = AccurateMath.abs(expected * SimpsonIntegrator.DEFAULT_RELATIVE_ACCURACY);
Assert.assertEquals("Result", expected, result, tolerance);
}
@@ -320,7 +320,7 @@ public final class SimpsonIntegratorTest {
// This is the expected sum.
// Each iteration will monotonically converge to this.
- expected = FastMath.log(max) - FastMath.log(min);
+ expected = AccurateMath.log(max) - AccurateMath.log(min);
// Test convergence at the given iteration
minIteration = 2;
@@ -344,7 +344,7 @@ public final class SimpsonIntegratorTest {
}
// Check the test function is correct.
- tolerance = FastMath.abs(expected * SimpsonIntegrator.DEFAULT_RELATIVE_ACCURACY);
+ tolerance = AccurateMath.abs(expected * SimpsonIntegrator.DEFAULT_RELATIVE_ACCURACY);
Assert.assertEquals("Expected result", expected, sums[maxIteration], tolerance);
// Set-up to test convergence at a specific iteration.
@@ -374,9 +374,9 @@ public final class SimpsonIntegratorTest {
// MATH-1458: minimalIterationCount>1 computes incorrect Simpson sum
// for the iteration. Check it is the correct sum.
// It should be closer to this one than the previous or next.
- final double dp = FastMath.abs(sums[i-1] - result);
- final double d = FastMath.abs(sums[i] - result);
- final double dn = FastMath.abs(sums[i+1] - result);
+ final double dp = AccurateMath.abs(sums[i-1] - result);
+ final double d = AccurateMath.abs(sums[i] - result);
+ final double dn = AccurateMath.abs(sums[i+1] - result);
Assert.assertTrue("Result closer to sum expected from previous iteration: " + i, d < dp);
Assert.assertTrue("Result closer to sum expected from next iteration: " + i, d < dn);
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/analysis/integration/TrapezoidIntegratorTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/analysis/integration/TrapezoidIntegratorTest.java
index fe457eb2a..0ea6a46a0 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/analysis/integration/TrapezoidIntegratorTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/analysis/integration/TrapezoidIntegratorTest.java
@@ -21,7 +21,7 @@ import org.apache.commons.math4.legacy.analysis.UnivariateFunction;
import org.apache.commons.math4.legacy.analysis.function.Sin;
import org.apache.commons.math4.legacy.exception.NumberIsTooLargeException;
import org.apache.commons.math4.legacy.exception.NumberIsTooSmallException;
-import org.apache.commons.math4.legacy.util.FastMath;
+import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
import org.junit.Assert;
import org.junit.Test;
@@ -44,15 +44,15 @@ public final class TrapezoidIntegratorTest {
UnivariateIntegrator integrator = new TrapezoidIntegrator();
double min, max, expected, result, tolerance;
- min = 0; max = FastMath.PI; expected = 2;
- tolerance = FastMath.abs(expected * integrator.getRelativeAccuracy());
+ min = 0; max = AccurateMath.PI; expected = 2;
+ tolerance = AccurateMath.abs(expected * integrator.getRelativeAccuracy());
result = integrator.integrate(10000, f, min, max);
Assert.assertTrue(integrator.getEvaluations() < 2500);
Assert.assertTrue(integrator.getIterations() < 15);
Assert.assertEquals(expected, result, tolerance);
- min = -FastMath.PI/3; max = 0; expected = -0.5;
- tolerance = FastMath.abs(expected * integrator.getRelativeAccuracy());
+ min = -AccurateMath.PI/3; max = 0; expected = -0.5;
+ tolerance = AccurateMath.abs(expected * integrator.getRelativeAccuracy());
result = integrator.integrate(10000, f, min, max);
Assert.assertTrue(integrator.getEvaluations() < 2500);
Assert.assertTrue(integrator.getIterations() < 15);
@@ -69,21 +69,21 @@ public final class TrapezoidIntegratorTest {
double min, max, expected, result, tolerance;
min = 0; max = 1; expected = -1.0/48;
- tolerance = FastMath.abs(expected * integrator.getRelativeAccuracy());
+ tolerance = AccurateMath.abs(expected * integrator.getRelativeAccuracy());
result = integrator.integrate(10000, f, min, max);
Assert.assertTrue(integrator.getEvaluations() < 5000);
Assert.assertTrue(integrator.getIterations() < 15);
Assert.assertEquals(expected, result, tolerance);
min = 0; max = 0.5; expected = 11.0/768;
- tolerance = FastMath.abs(expected * integrator.getRelativeAccuracy());
+ tolerance = AccurateMath.abs(expected * integrator.getRelativeAccuracy());
result = integrator.integrate(10000, f, min, max);
Assert.assertTrue(integrator.getEvaluations() < 2500);
Assert.assertTrue(integrator.getIterations() < 15);
Assert.assertEquals(expected, result, tolerance);
min = -1; max = 4; expected = 2048/3.0 - 78 + 1.0/48;
- tolerance = FastMath.abs(expected * integrator.getRelativeAccuracy());
+ tolerance = AccurateMath.abs(expected * integrator.getRelativeAccuracy());
result = integrator.integrate(10000, f, min, max);
Assert.assertTrue(integrator.getEvaluations() < 5000);
Assert.assertTrue(integrator.getIterations() < 15);
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/analysis/integration/gauss/GaussianQuadratureAbstractTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/analysis/integration/gauss/GaussianQuadratureAbstractTest.java
index d85f24f6c..f1ead3209 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/analysis/integration/gauss/GaussianQuadratureAbstractTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/analysis/integration/gauss/GaussianQuadratureAbstractTest.java
@@ -17,7 +17,7 @@
package org.apache.commons.math4.legacy.analysis.integration.gauss;
import org.apache.commons.math4.legacy.analysis.function.Power;
-import org.apache.commons.math4.legacy.util.FastMath;
+import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
import org.junit.Test;
import org.junit.Assert;
@@ -105,7 +105,7 @@ public abstract class GaussianQuadratureAbstractTest {
integrator.getNumberOfPoints() + "-point quadrature rule",
expected, actual, eps);
} else {
- double err = FastMath.abs(actual - expected) / Math.ulp(expected);
+ double err = AccurateMath.abs(actual - expected) / Math.ulp(expected);
Assert.assertEquals("while integrating monomial x**" + n + " with a " +
+ integrator.getNumberOfPoints() + "-point quadrature rule, " +
" error was " + err + " ulps",
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/analysis/integration/gauss/HermiteParametricTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/analysis/integration/gauss/HermiteParametricTest.java
index 6efe85168..06a3caf90 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/analysis/integration/gauss/HermiteParametricTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/analysis/integration/gauss/HermiteParametricTest.java
@@ -22,7 +22,7 @@ import java.util.Collection;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.junit.runners.Parameterized.Parameters;
-import org.apache.commons.math4.legacy.util.FastMath;
+import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
/**
* Test of the {@link HermiteRuleFactory}.
@@ -34,7 +34,7 @@ import org.apache.commons.math4.legacy.util.FastMath;
*/
@RunWith(value=Parameterized.class)
public class HermiteParametricTest extends GaussianQuadratureAbstractTest {
- private static final double SQRT_PI = FastMath.sqrt(Math.PI);
+ private static final double SQRT_PI = AccurateMath.sqrt(Math.PI);
private static final GaussIntegratorFactory factory = new GaussIntegratorFactory();
/**
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/analysis/integration/gauss/HermiteTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/analysis/integration/gauss/HermiteTest.java
index ea95725ab..1c094d9a6 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/analysis/integration/gauss/HermiteTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/analysis/integration/gauss/HermiteTest.java
@@ -17,7 +17,7 @@
package org.apache.commons.math4.legacy.analysis.integration.gauss;
import org.apache.commons.math4.legacy.analysis.UnivariateFunction;
-import org.apache.commons.math4.legacy.util.FastMath;
+import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
import org.junit.Test;
import org.junit.Assert;
@@ -30,7 +30,7 @@ public class HermiteTest {
@Test
public void testNormalDistribution() {
- final double oneOverSqrtPi = 1 / FastMath.sqrt(Math.PI);
+ final double oneOverSqrtPi = 1 / AccurateMath.sqrt(Math.PI);
// By definition, Gauss-Hermite quadrature readily provides the
// integral of the normal distribution density.
@@ -57,8 +57,8 @@ public class HermiteTest {
@Test
public void testNormalMean() {
- final double sqrtTwo = FastMath.sqrt(2);
- final double oneOverSqrtPi = 1 / FastMath.sqrt(Math.PI);
+ final double sqrtTwo = AccurateMath.sqrt(2);
+ final double oneOverSqrtPi = 1 / AccurateMath.sqrt(Math.PI);
final double mu = 12345.6789;
final double sigma = 987.654321;
@@ -85,7 +85,7 @@ public class HermiteTest {
@Test
public void testNormalVariance() {
- final double twoOverSqrtPi = 2 / FastMath.sqrt(Math.PI);
+ final double twoOverSqrtPi = 2 / AccurateMath.sqrt(Math.PI);
final double sigma = 987.654321;
final double sigma2 = sigma * sigma;
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/analysis/integration/gauss/LaguerreTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/analysis/integration/gauss/LaguerreTest.java
index 4ad904687..c97f48c99 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/analysis/integration/gauss/LaguerreTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/analysis/integration/gauss/LaguerreTest.java
@@ -18,7 +18,7 @@ package org.apache.commons.math4.legacy.analysis.integration.gauss;
import org.apache.commons.math4.legacy.analysis.UnivariateFunction;
import org.apache.commons.numbers.gamma.Gamma;
-import org.apache.commons.math4.legacy.util.FastMath;
+import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
import org.junit.Assert;
import org.junit.Test;
@@ -38,7 +38,7 @@ public class LaguerreTest {
final UnivariateFunction f = new UnivariateFunction() {
@Override
public double value(double x) {
- return FastMath.pow(x, t - 1);
+ return AccurateMath.pow(x, t - 1);
}
};
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/analysis/interpolation/AkimaSplineInterpolatorTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/analysis/interpolation/AkimaSplineInterpolatorTest.java
index c459c9fb7..98263973e 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/analysis/interpolation/AkimaSplineInterpolatorTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/analysis/interpolation/AkimaSplineInterpolatorTest.java
@@ -28,7 +28,7 @@ import org.apache.commons.math4.legacy.exception.NullArgumentException;
import org.apache.commons.math4.legacy.exception.NumberIsTooSmallException;
import org.apache.commons.rng.UniformRandomProvider;
import org.apache.commons.rng.simple.RandomSource;
-import org.apache.commons.math4.legacy.util.FastMath;
+import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
import org.apache.commons.numbers.core.Precision;
import org.junit.Assert;
import org.junit.Test;
@@ -258,7 +258,7 @@ public class AkimaSplineInterpolatorTest
currentX = distX.sample();
expected = f.value( currentX );
actual = interpolation.value( currentX );
- sumError += FastMath.abs( actual - expected );
+ sumError += AccurateMath.abs( actual - expected );
assertEquals( expected, actual, maxTolerance );
}
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/analysis/interpolation/BicubicInterpolatingFunctionTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/analysis/interpolation/BicubicInterpolatingFunctionTest.java
index ec88786e8..6dbad6e55 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/analysis/interpolation/BicubicInterpolatingFunctionTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/analysis/interpolation/BicubicInterpolatingFunctionTest.java
@@ -24,7 +24,7 @@ import org.apache.commons.math4.legacy.exception.MathIllegalArgumentException;
import org.apache.commons.math4.legacy.exception.OutOfRangeException;
import org.apache.commons.rng.UniformRandomProvider;
import org.apache.commons.rng.simple.RandomSource;
-import org.apache.commons.math4.legacy.util.FastMath;
+import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
import org.apache.commons.numbers.core.Precision;
import org.junit.Assert;
import org.junit.Test;
@@ -376,7 +376,7 @@ public final class BicubicInterpolatingFunctionTest {
}
actual = interpolation.value(currentX, currentY);
- sumError += FastMath.abs(actual - expected);
+ sumError += AccurateMath.abs(actual - expected);
if (print) {
System.out.println(actual + " (diff=" + (expected - actual) + ")");
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/analysis/interpolation/DividedDifferenceInterpolatorTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/analysis/interpolation/DividedDifferenceInterpolatorTest.java
index e997ef934..149dec0f7 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/analysis/interpolation/DividedDifferenceInterpolatorTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/analysis/interpolation/DividedDifferenceInterpolatorTest.java
@@ -20,7 +20,7 @@ import org.apache.commons.math4.legacy.analysis.UnivariateFunction;
import org.apache.commons.math4.legacy.analysis.function.Expm1;
import org.apache.commons.math4.legacy.analysis.function.Sin;
import org.apache.commons.math4.legacy.exception.NonMonotonicSequenceException;
-import org.apache.commons.math4.legacy.util.FastMath;
+import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
import org.junit.Assert;
import org.junit.Test;
@@ -53,7 +53,7 @@ public final class DividedDifferenceInterpolatorTest {
// 6 interpolating points on interval [0, 2*PI]
int n = 6;
- double min = 0.0, max = 2 * FastMath.PI;
+ double min = 0.0, max = 2 * AccurateMath.PI;
x = new double[n];
y = new double[n];
for (int i = 0; i < n; i++) {
@@ -63,12 +63,12 @@ public final class DividedDifferenceInterpolatorTest {
double derivativebound = 1.0;
UnivariateFunction p = interpolator.interpolate(x, y);
- z = FastMath.PI / 4; expected = f.value(z); result = p.value(z);
- tolerance = FastMath.abs(derivativebound * partialerror(x, z));
+ z = AccurateMath.PI / 4; expected = f.value(z); result = p.value(z);
+ tolerance = AccurateMath.abs(derivativebound * partialerror(x, z));
Assert.assertEquals(expected, result, tolerance);
- z = FastMath.PI * 1.5; expected = f.value(z); result = p.value(z);
- tolerance = FastMath.abs(derivativebound * partialerror(x, z));
+ z = AccurateMath.PI * 1.5; expected = f.value(z); result = p.value(z);
+ tolerance = AccurateMath.abs(derivativebound * partialerror(x, z));
Assert.assertEquals(expected, result, tolerance);
}
@@ -92,19 +92,19 @@ public final class DividedDifferenceInterpolatorTest {
x[i] = min + i * (max - min) / n;
y[i] = f.value(x[i]);
}
- double derivativebound = FastMath.E;
+ double derivativebound = AccurateMath.E;
UnivariateFunction p = interpolator.interpolate(x, y);
z = 0.0; expected = f.value(z); result = p.value(z);
- tolerance = FastMath.abs(derivativebound * partialerror(x, z));
+ tolerance = AccurateMath.abs(derivativebound * partialerror(x, z));
Assert.assertEquals(expected, result, tolerance);
z = 0.5; expected = f.value(z); result = p.value(z);
- tolerance = FastMath.abs(derivativebound * partialerror(x, z));
+ tolerance = AccurateMath.abs(derivativebound * partialerror(x, z));
Assert.assertEquals(expected, result, tolerance);
z = -0.5; expected = f.value(z); result = p.value(z);
- tolerance = FastMath.abs(derivativebound * partialerror(x, z));
+ tolerance = AccurateMath.abs(derivativebound * partialerror(x, z));
Assert.assertEquals(expected, result, tolerance);
}
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/analysis/interpolation/FieldHermiteInterpolatorTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/analysis/interpolation/FieldHermiteInterpolatorTest.java
index 1922953ec..63c6378be 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/analysis/interpolation/FieldHermiteInterpolatorTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/analysis/interpolation/FieldHermiteInterpolatorTest.java
@@ -19,12 +19,12 @@ package org.apache.commons.math4.legacy.analysis.interpolation;
import java.util.Random;
import org.apache.commons.math4.legacy.analysis.polynomials.PolynomialFunction;
-import org.apache.commons.math4.legacy.dfp.Dfp;
-import org.apache.commons.math4.legacy.dfp.DfpField;
+import org.apache.commons.math4.legacy.core.dfp.Dfp;
+import org.apache.commons.math4.legacy.core.dfp.DfpField;
import org.apache.commons.math4.legacy.linear.Dfp25;
import org.apache.commons.math4.legacy.exception.MathIllegalArgumentException;
import org.apache.commons.math4.legacy.exception.NoDataException;
-import org.apache.commons.math4.legacy.util.FastMath;
+import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
import org.junit.Assert;
import org.junit.Test;
@@ -101,7 +101,7 @@ public class FieldHermiteInterpolatorTest {
for (int k = 0; k < p.length; ++k) {
int degree = random.nextInt(7);
p[k] = randomPolynomial(degree, random);
- maxDegree = FastMath.max(maxDegree, degree);
+ maxDegree = AccurateMath.max(maxDegree, degree);
}
DfpField field = new DfpField(30);
@@ -123,7 +123,7 @@ public class FieldHermiteInterpolatorTest {
for (int k = 0; k < p.length; ++k) {
Assert.assertEquals(p[k].value(x.getReal()),
values[k].getReal(),
- 1.0e-8 * FastMath.abs(p[k].value(x.getReal())));
+ 1.0e-8 * AccurateMath.abs(p[k].value(x.getReal())));
}
}
@@ -145,7 +145,7 @@ public class FieldHermiteInterpolatorTest {
int degree = random.nextInt(7);
p[k] = randomPolynomial(degree, random);
pPrime[k] = p[k].polynomialDerivative();
- maxDegree = FastMath.max(maxDegree, degree);
+ maxDegree = AccurateMath.max(maxDegree, degree);
}
DfpField field = new DfpField(30);
@@ -172,10 +172,10 @@ public class FieldHermiteInterpolatorTest {
for (int k = 0; k < p.length; ++k) {
Assert.assertEquals(p[k].value(x.getReal()),
y[k].getReal(),
- 1.0e-8 * FastMath.abs(p[k].value(x.getReal())));
+ 1.0e-8 * AccurateMath.abs(p[k].value(x.getReal())));
Assert.assertEquals(pPrime[k].value(x.getReal()),
yP[k].subtract(yM[k]).divide(h.multiply(2)).getReal(),
- 4.0e-8 * FastMath.abs(p[k].value(x.getReal())));
+ 4.0e-8 * AccurateMath.abs(p[k].value(x.getReal())));
}
}
@@ -186,7 +186,7 @@ public class FieldHermiteInterpolatorTest {
public void testSine() {
DfpField field = new DfpField(30);
FieldHermiteInterpolator interpolator = new FieldHermiteInterpolator<>();
- for (Dfp x = field.getZero(); x.getReal() < FastMath.PI; x = x.add(0.5)) {
+ for (Dfp x = field.getZero(); x.getReal() < AccurateMath.PI; x = x.add(0.5)) {
interpolator.addSamplePoint(x, new Dfp[] { x.sin() });
}
for (Dfp x = field.newDfp(0.1); x.getReal() < 2.9; x = x.add(0.01)) {
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/analysis/interpolation/HermiteInterpolatorTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/analysis/interpolation/HermiteInterpolatorTest.java
index 501b079d3..d3cb14003 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/analysis/interpolation/HermiteInterpolatorTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/analysis/interpolation/HermiteInterpolatorTest.java
@@ -22,7 +22,7 @@ import org.apache.commons.math4.legacy.analysis.differentiation.DerivativeStruct
import org.apache.commons.math4.legacy.analysis.polynomials.PolynomialFunction;
import org.apache.commons.math4.legacy.exception.MathIllegalArgumentException;
import org.apache.commons.math4.legacy.exception.NoDataException;
-import org.apache.commons.math4.legacy.util.FastMath;
+import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
import org.junit.Assert;
import org.junit.Test;
@@ -86,7 +86,7 @@ public class HermiteInterpolatorTest {
for (int k = 0; k < p.length; ++k) {
int degree = random.nextInt(7);
p[k] = randomPolynomial(degree, random);
- maxDegree = FastMath.max(maxDegree, degree);
+ maxDegree = AccurateMath.max(maxDegree, degree);
}
HermiteInterpolator interpolator = new HermiteInterpolator();
@@ -103,7 +103,7 @@ public class HermiteInterpolatorTest {
double[] values = interpolator.value(x);
Assert.assertEquals(p.length, values.length);
for (int k = 0; k < p.length; ++k) {
- Assert.assertEquals(p[k].value(x), values[k], 1.0e-8 * FastMath.abs(p[k].value(x)));
+ Assert.assertEquals(p[k].value(x), values[k], 1.0e-8 * AccurateMath.abs(p[k].value(x)));
}
}
@@ -129,7 +129,7 @@ public class HermiteInterpolatorTest {
int degree = random.nextInt(7);
p[k] = randomPolynomial(degree, random);
pPrime[k] = p[k].polynomialDerivative();
- maxDegree = FastMath.max(maxDegree, degree);
+ maxDegree = AccurateMath.max(maxDegree, degree);
}
HermiteInterpolator interpolator = new HermiteInterpolator();
@@ -148,8 +148,8 @@ public class HermiteInterpolatorTest {
DerivativeStructure[] y = interpolator.value(new DerivativeStructure(1, 1, 0, x));
Assert.assertEquals(p.length, y.length);
for (int k = 0; k < p.length; ++k) {
- Assert.assertEquals(p[k].value(x), y[k].getValue(), 1.0e-8 * FastMath.abs(p[k].value(x)));
- Assert.assertEquals(pPrime[k].value(x), y[k].getPartialDerivative(1), 4.0e-8 * FastMath.abs(p[k].value(x)));
+ Assert.assertEquals(p[k].value(x), y[k].getValue(), 1.0e-8 * AccurateMath.abs(p[k].value(x)));
+ Assert.assertEquals(pPrime[k].value(x), y[k].getPartialDerivative(1), 4.0e-8 * AccurateMath.abs(p[k].value(x)));
}
}
@@ -164,14 +164,14 @@ public class HermiteInterpolatorTest {
@Test
public void testSine() {
HermiteInterpolator interpolator = new HermiteInterpolator();
- for (double x = 0; x < FastMath.PI; x += 0.5) {
- interpolator.addSamplePoint(x, new double[] { FastMath.sin(x) });
+ for (double x = 0; x < AccurateMath.PI; x += 0.5) {
+ interpolator.addSamplePoint(x, new double[] { AccurateMath.sin(x) });
}
for (double x = 0.1; x <= 2.9; x += 0.01) {
DerivativeStructure y = interpolator.value(new DerivativeStructure(1, 2, 0, x))[0];
- Assert.assertEquals( FastMath.sin(x), y.getValue(), 3.5e-5);
- Assert.assertEquals( FastMath.cos(x), y.getPartialDerivative(1), 1.3e-4);
- Assert.assertEquals(-FastMath.sin(x), y.getPartialDerivative(2), 2.9e-3);
+ Assert.assertEquals( AccurateMath.sin(x), y.getValue(), 3.5e-5);
+ Assert.assertEquals( AccurateMath.cos(x), y.getPartialDerivative(1), 1.3e-4);
+ Assert.assertEquals(-AccurateMath.sin(x), y.getPartialDerivative(2), 2.9e-3);
}
}
@@ -179,12 +179,12 @@ public class HermiteInterpolatorTest {
public void testSquareRoot() {
HermiteInterpolator interpolator = new HermiteInterpolator();
for (double x = 1.0; x < 3.6; x += 0.5) {
- interpolator.addSamplePoint(x, new double[] { FastMath.sqrt(x) });
+ interpolator.addSamplePoint(x, new double[] { AccurateMath.sqrt(x) });
}
for (double x = 1.1; x < 3.5; x += 0.01) {
DerivativeStructure y = interpolator.value(new DerivativeStructure(1, 1, 0, x))[0];
- Assert.assertEquals(FastMath.sqrt(x), y.getValue(), 1.5e-4);
- Assert.assertEquals(0.5 / FastMath.sqrt(x), y.getPartialDerivative(1), 8.5e-4);
+ Assert.assertEquals(AccurateMath.sqrt(x), y.getValue(), 1.5e-4);
+ Assert.assertEquals(0.5 / AccurateMath.sqrt(x), y.getPartialDerivative(1), 8.5e-4);
}
}
@@ -246,7 +246,7 @@ public class HermiteInterpolatorTest {
double[] cE = expected.getCoefficients();
double[] cR = result.getCoefficients();
for (int i = 0; i < cE.length; ++i) {
- Assert.assertEquals(cE[i], cR[i], 1.0e-8 * FastMath.abs(cE[i]));
+ Assert.assertEquals(cE[i], cR[i], 1.0e-8 * AccurateMath.abs(cE[i]));
}
for (int i = cE.length; i < cR.length; ++i) {
Assert.assertEquals(0.0, cR[i], 1.0e-9);
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/analysis/interpolation/LoessInterpolatorTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/analysis/interpolation/LoessInterpolatorTest.java
index 65bcc9a5a..6f47e58b2 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/analysis/interpolation/LoessInterpolatorTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/analysis/interpolation/LoessInterpolatorTest.java
@@ -22,7 +22,7 @@ import org.apache.commons.math4.legacy.exception.NonMonotonicSequenceException;
import org.apache.commons.math4.legacy.exception.NotFiniteNumberException;
import org.apache.commons.math4.legacy.exception.NumberIsTooSmallException;
import org.apache.commons.math4.legacy.exception.OutOfRangeException;
-import org.apache.commons.math4.legacy.util.FastMath;
+import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
import org.junit.Assert;
import org.junit.Test;
@@ -83,12 +83,12 @@ public class LoessInterpolatorTest {
double fitResidualSum = 0;
for(int i = 0; i < numPoints; ++i) {
- double expected = FastMath.sin(xval[i]);
+ double expected = AccurateMath.sin(xval[i]);
double noisy = yval[i];
double fit = res[i];
- noisyResidualSum += FastMath.pow(noisy - expected, 2);
- fitResidualSum += FastMath.pow(fit - expected, 2);
+ noisyResidualSum += AccurateMath.pow(noisy - expected, 2);
+ fitResidualSum += AccurateMath.pow(fit - expected, 2);
}
Assert.assertTrue(fitResidualSum < noisyResidualSum);
@@ -116,7 +116,7 @@ public class LoessInterpolatorTest {
double[] res = li.smooth(xval, yval);
for (int j = 1; j < res.length; ++j) {
- variances[i] += FastMath.pow(res[j] - res[j-1], 2);
+ variances[i] += AccurateMath.pow(res[j] - res[j-1], 2);
}
}
@@ -149,7 +149,7 @@ public class LoessInterpolatorTest {
double[] res = li.smooth(xval, yval);
for (int j = 1; j < res.length; ++j) {
- variances[i] += FastMath.abs(res[j] - res[j-1]);
+ variances[i] += AccurateMath.abs(res[j] - res[j-1]);
}
}
@@ -248,12 +248,12 @@ public class LoessInterpolatorTest {
}
private void generateSineData(double[] xval, double[] yval, double xnoise, double ynoise) {
- double dx = 2 * FastMath.PI / xval.length;
+ double dx = 2 * AccurateMath.PI / xval.length;
double x = 0;
for(int i = 0; i < xval.length; ++i) {
xval[i] = x;
- yval[i] = FastMath.sin(x) + (2 * FastMath.random() - 1) * ynoise;
- x += dx * (1 + (2 * FastMath.random() - 1) * xnoise);
+ yval[i] = AccurateMath.sin(x) + (2 * AccurateMath.random() - 1) * ynoise;
+ x += dx * (1 + (2 * AccurateMath.random() - 1) * xnoise);
}
}
}
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/analysis/interpolation/MicrosphereProjectionInterpolatorTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/analysis/interpolation/MicrosphereProjectionInterpolatorTest.java
index 76247147e..c99e9f357 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/analysis/interpolation/MicrosphereProjectionInterpolatorTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/analysis/interpolation/MicrosphereProjectionInterpolatorTest.java
@@ -17,7 +17,7 @@
package org.apache.commons.math4.legacy.analysis.interpolation;
import org.apache.commons.math4.legacy.analysis.MultivariateFunction;
-import org.apache.commons.math4.legacy.util.FastMath;
+import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
import org.junit.Assert;
import org.junit.Test;
@@ -102,8 +102,8 @@ public final class MicrosphereProjectionInterpolatorTest {
expected = f.value(c);
result = p.value(c);
result2D = p2D.value(c);
- Assert.assertEquals("on sample point (exact)", expected, result2D, FastMath.ulp(1d));
- Assert.assertEquals("on sample point (ND vs 2D)", result2D, result, FastMath.ulp(1d));
+ Assert.assertEquals("on sample point (exact)", expected, result2D, AccurateMath.ulp(1d));
+ Assert.assertEquals("on sample point (ND vs 2D)", result2D, result, AccurateMath.ulp(1d));
// Interpolation.
c[0] = 0.654321;
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/analysis/interpolation/NevilleInterpolatorTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/analysis/interpolation/NevilleInterpolatorTest.java
index cbaa25512..8b9bce197 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/analysis/interpolation/NevilleInterpolatorTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/analysis/interpolation/NevilleInterpolatorTest.java
@@ -20,7 +20,7 @@ import org.apache.commons.math4.legacy.analysis.UnivariateFunction;
import org.apache.commons.math4.legacy.analysis.function.Expm1;
import org.apache.commons.math4.legacy.analysis.function.Sin;
import org.apache.commons.math4.legacy.exception.NonMonotonicSequenceException;
-import org.apache.commons.math4.legacy.util.FastMath;
+import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
import org.junit.Assert;
import org.junit.Test;
@@ -53,7 +53,7 @@ public final class NevilleInterpolatorTest {
// 6 interpolating points on interval [0, 2*PI]
int n = 6;
- double min = 0.0, max = 2 * FastMath.PI;
+ double min = 0.0, max = 2 * AccurateMath.PI;
x = new double[n];
y = new double[n];
for (int i = 0; i < n; i++) {
@@ -63,12 +63,12 @@ public final class NevilleInterpolatorTest {
double derivativebound = 1.0;
UnivariateFunction p = interpolator.interpolate(x, y);
- z = FastMath.PI / 4; expected = f.value(z); result = p.value(z);
- tolerance = FastMath.abs(derivativebound * partialerror(x, z));
+ z = AccurateMath.PI / 4; expected = f.value(z); result = p.value(z);
+ tolerance = AccurateMath.abs(derivativebound * partialerror(x, z));
Assert.assertEquals(expected, result, tolerance);
- z = FastMath.PI * 1.5; expected = f.value(z); result = p.value(z);
- tolerance = FastMath.abs(derivativebound * partialerror(x, z));
+ z = AccurateMath.PI * 1.5; expected = f.value(z); result = p.value(z);
+ tolerance = AccurateMath.abs(derivativebound * partialerror(x, z));
Assert.assertEquals(expected, result, tolerance);
}
@@ -92,19 +92,19 @@ public final class NevilleInterpolatorTest {
x[i] = min + i * (max - min) / n;
y[i] = f.value(x[i]);
}
- double derivativebound = FastMath.E;
+ double derivativebound = AccurateMath.E;
UnivariateFunction p = interpolator.interpolate(x, y);
z = 0.0; expected = f.value(z); result = p.value(z);
- tolerance = FastMath.abs(derivativebound * partialerror(x, z));
+ tolerance = AccurateMath.abs(derivativebound * partialerror(x, z));
Assert.assertEquals(expected, result, tolerance);
z = 0.5; expected = f.value(z); result = p.value(z);
- tolerance = FastMath.abs(derivativebound * partialerror(x, z));
+ tolerance = AccurateMath.abs(derivativebound * partialerror(x, z));
Assert.assertEquals(expected, result, tolerance);
z = -0.5; expected = f.value(z); result = p.value(z);
- tolerance = FastMath.abs(derivativebound * partialerror(x, z));
+ tolerance = AccurateMath.abs(derivativebound * partialerror(x, z));
Assert.assertEquals(expected, result, tolerance);
}
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/analysis/interpolation/PiecewiseBicubicSplineInterpolatingFunctionTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/analysis/interpolation/PiecewiseBicubicSplineInterpolatingFunctionTest.java
index e7a784950..6984f31e4 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/analysis/interpolation/PiecewiseBicubicSplineInterpolatingFunctionTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/analysis/interpolation/PiecewiseBicubicSplineInterpolatingFunctionTest.java
@@ -25,7 +25,7 @@ import org.apache.commons.math4.legacy.exception.NonMonotonicSequenceException;
import org.apache.commons.math4.legacy.exception.NullArgumentException;
import org.apache.commons.rng.UniformRandomProvider;
import org.apache.commons.rng.simple.RandomSource;
-import org.apache.commons.math4.legacy.util.FastMath;
+import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
import org.apache.commons.numbers.core.Precision;
import org.junit.Assert;
import org.junit.Test;
@@ -261,7 +261,7 @@ public final class PiecewiseBicubicSplineInterpolatingFunctionTest {
currentY = distY.sample();
expected = f.value(currentX, currentY);
actual = interpolation.value(currentX, currentY);
- sumError += FastMath.abs(actual - expected);
+ sumError += AccurateMath.abs(actual - expected);
Assert.assertEquals(expected, actual, maxTolerance);
}
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/analysis/interpolation/SplineInterpolatorTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/analysis/interpolation/SplineInterpolatorTest.java
index 37e34f9a3..7d48afe09 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/analysis/interpolation/SplineInterpolatorTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/analysis/interpolation/SplineInterpolatorTest.java
@@ -23,7 +23,7 @@ import org.apache.commons.math4.legacy.analysis.polynomials.PolynomialSplineFunc
import org.apache.commons.math4.legacy.exception.DimensionMismatchException;
import org.apache.commons.math4.legacy.exception.NonMonotonicSequenceException;
import org.apache.commons.math4.legacy.exception.NumberIsTooSmallException;
-import org.apache.commons.math4.legacy.util.FastMath;
+import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
import org.junit.Assert;
import org.junit.Test;
@@ -115,14 +115,14 @@ public class SplineInterpolatorTest {
double x[] =
{
0.0,
- FastMath.PI / 6d,
- FastMath.PI / 2d,
- 5d * FastMath.PI / 6d,
- FastMath.PI,
- 7d * FastMath.PI / 6d,
- 3d * FastMath.PI / 2d,
- 11d * FastMath.PI / 6d,
- 2.d * FastMath.PI };
+ AccurateMath.PI / 6d,
+ AccurateMath.PI / 2d,
+ 5d * AccurateMath.PI / 6d,
+ AccurateMath.PI,
+ 7d * AccurateMath.PI / 6d,
+ 3d * AccurateMath.PI / 2d,
+ 11d * AccurateMath.PI / 6d,
+ 2.d * AccurateMath.PI };
double y[] = { 0d, 0.5d, 1d, 0.5d, 0d, -0.5d, -1d, -0.5d, 0d };
UnivariateInterpolator i = new SplineInterpolator();
UnivariateFunction f = i.interpolate(x, y);
@@ -157,8 +157,8 @@ public class SplineInterpolatorTest {
TestUtils.assertEquals(polynomials[7].getCoefficients(), target, sineCoefficientTolerance);
//Check interpolation
- Assert.assertEquals(FastMath.sqrt(2d) / 2d,f.value(FastMath.PI/4d),sineInterpolationTolerance);
- Assert.assertEquals(FastMath.sqrt(2d) / 2d,f.value(3d*FastMath.PI/4d),sineInterpolationTolerance);
+ Assert.assertEquals(AccurateMath.sqrt(2d) / 2d,f.value(AccurateMath.PI/4d),sineInterpolationTolerance);
+ Assert.assertEquals(AccurateMath.sqrt(2d) / 2d,f.value(3d*AccurateMath.PI/4d),sineInterpolationTolerance);
}
@Test
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/analysis/interpolation/TricubicInterpolatingFunctionTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/analysis/interpolation/TricubicInterpolatingFunctionTest.java
index 4534d023a..3c0d71de8 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/analysis/interpolation/TricubicInterpolatingFunctionTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/analysis/interpolation/TricubicInterpolatingFunctionTest.java
@@ -23,7 +23,7 @@ import org.apache.commons.math4.legacy.exception.DimensionMismatchException;
import org.apache.commons.math4.legacy.exception.MathIllegalArgumentException;
import org.apache.commons.rng.UniformRandomProvider;
import org.apache.commons.rng.simple.RandomSource;
-import org.apache.commons.math4.legacy.util.FastMath;
+import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
import org.apache.commons.numbers.core.Precision;
import org.junit.Assert;
import org.junit.Test;
@@ -393,7 +393,7 @@ public final class TricubicInterpolatingFunctionTest {
expected = f.value(currentX, currentY, currentZ);
actual = interpolation.value(currentX, currentY, currentZ);
- final double relativeError = FastMath.abs(actual - expected) / FastMath.max(FastMath.abs(actual), FastMath.abs(expected));
+ final double relativeError = AccurateMath.abs(actual - expected) / AccurateMath.max(AccurateMath.abs(actual), AccurateMath.abs(expected));
sumError += relativeError;
if (print) {
@@ -579,56 +579,56 @@ public final class TricubicInterpolatingFunctionTest {
final TrivariateFunction f = new TrivariateFunction() {
@Override
public double value(double x, double y, double z) {
- return a * FastMath.cos(arg.value(x, y, z));
+ return a * AccurateMath.cos(arg.value(x, y, z));
}
};
final TrivariateFunction dfdx = new TrivariateFunction() {
@Override
public double value(double x, double y, double z) {
- return kx * a * FastMath.sin(arg.value(x, y, z));
+ return kx * a * AccurateMath.sin(arg.value(x, y, z));
}
};
final TrivariateFunction dfdy = new TrivariateFunction() {
@Override
public double value(double x, double y, double z) {
- return ky * a * FastMath.sin(arg.value(x, y, z));
+ return ky * a * AccurateMath.sin(arg.value(x, y, z));
}
};
final TrivariateFunction dfdz = new TrivariateFunction() {
@Override
public double value(double x, double y, double z) {
- return -omega * a * FastMath.sin(arg.value(x, y, z));
+ return -omega * a * AccurateMath.sin(arg.value(x, y, z));
}
};
final TrivariateFunction d2fdxdy = new TrivariateFunction() {
@Override
public double value(double x, double y, double z) {
- return -ky * kx * a * FastMath.cos(arg.value(x, y, z));
+ return -ky * kx * a * AccurateMath.cos(arg.value(x, y, z));
}
};
final TrivariateFunction d2fdxdz = new TrivariateFunction() {
@Override
public double value(double x, double y, double z) {
- return omega * kx * a * FastMath.cos(arg.value(x, y, z));
+ return omega * kx * a * AccurateMath.cos(arg.value(x, y, z));
}
};
final TrivariateFunction d2fdydz = new TrivariateFunction() {
@Override
public double value(double x, double y, double z) {
- return omega * ky * a * FastMath.cos(arg.value(x, y, z));
+ return omega * ky * a * AccurateMath.cos(arg.value(x, y, z));
}
};
final TrivariateFunction d3fdxdydz = new TrivariateFunction() {
@Override
public double value(double x, double y, double z) {
- return omega * ky * kx * a * FastMath.sin(arg.value(x, y, z));
+ return omega * ky * kx * a * AccurateMath.sin(arg.value(x, y, z));
}
};
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/analysis/interpolation/TricubicInterpolatorTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/analysis/interpolation/TricubicInterpolatorTest.java
index b0d37372c..a735d34d4 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/analysis/interpolation/TricubicInterpolatorTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/analysis/interpolation/TricubicInterpolatorTest.java
@@ -19,7 +19,7 @@ package org.apache.commons.math4.legacy.analysis.interpolation;
import org.apache.commons.math4.legacy.analysis.TrivariateFunction;
import org.apache.commons.math4.legacy.exception.DimensionMismatchException;
import org.apache.commons.math4.legacy.exception.MathIllegalArgumentException;
-import org.apache.commons.math4.legacy.util.FastMath;
+import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
import org.junit.Assert;
import org.junit.Test;
@@ -187,7 +187,7 @@ public final class TricubicInterpolatorTest {
TrivariateFunction f = new TrivariateFunction() {
@Override
public double value(double x, double y, double z) {
- return a * FastMath.cos(omega * z - kx * x - ky * y);
+ return a * AccurateMath.cos(omega * z - kx * x - ky * y);
}
};
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/analysis/interpolation/UnivariatePeriodicInterpolatorTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/analysis/interpolation/UnivariatePeriodicInterpolatorTest.java
index 5213f65ce..4880a7bcb 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/analysis/interpolation/UnivariatePeriodicInterpolatorTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/analysis/interpolation/UnivariatePeriodicInterpolatorTest.java
@@ -25,7 +25,7 @@ import org.apache.commons.rng.simple.RandomSource;
import org.apache.commons.math4.legacy.analysis.UnivariateFunction;
import org.apache.commons.math4.legacy.exception.NonMonotonicSequenceException;
import org.apache.commons.math4.legacy.exception.NumberIsTooSmallException;
-import org.apache.commons.math4.legacy.util.FastMath;
+import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
/**
@@ -46,7 +46,7 @@ public class UnivariatePeriodicInterpolatorTest {
for (int i = 0; i < n; i++) {
delta += rng.nextDouble() * period / n;
xval[i] = offset + delta;
- yval[i] = FastMath.sin(xval[i]);
+ yval[i] = AccurateMath.sin(xval[i]);
}
final UnivariateInterpolator inter = new LinearInterpolator();
@@ -91,7 +91,7 @@ public class UnivariatePeriodicInterpolatorTest {
for (int i = 0; i < n; i++) {
delta += period / (2 * n) * rng.nextDouble();
xval[i] = offset + delta;
- yval[i] = FastMath.sin(xval[i]);
+ yval[i] = AccurateMath.sin(xval[i]);
}
final UnivariateInterpolator interP
@@ -122,7 +122,7 @@ public class UnivariatePeriodicInterpolatorTest {
for (int i = 0; i < n; i++) {
delta += 10 * period / n * rng.nextDouble();
xval[i] = offset + delta;
- yval[i] = FastMath.sin(xval[i]);
+ yval[i] = AccurateMath.sin(xval[i]);
}
final UnivariateInterpolator interP
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/analysis/polynomials/PolynomialFunctionTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/analysis/polynomials/PolynomialFunctionTest.java
index 77d8cbf7a..298515b89 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/analysis/polynomials/PolynomialFunctionTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/analysis/polynomials/PolynomialFunctionTest.java
@@ -17,7 +17,7 @@
package org.apache.commons.math4.legacy.analysis.polynomials;
import org.apache.commons.math4.legacy.TestUtils;
-import org.apache.commons.math4.legacy.util.FastMath;
+import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
import org.junit.Assert;
import org.junit.Test;
@@ -148,8 +148,8 @@ public final class PolynomialFunctionTest {
Assert.assertEquals(f.polynomialDerivative().value(-3.25), g.value(-3.25), tolerance);
// compare g' = h
- Assert.assertEquals(g.polynomialDerivative().value(FastMath.PI), h.value(FastMath.PI), tolerance);
- Assert.assertEquals(g.polynomialDerivative().value(FastMath.E), h.value(FastMath.E), tolerance);
+ Assert.assertEquals(g.polynomialDerivative().value(AccurateMath.PI), h.value(AccurateMath.PI), tolerance);
+ Assert.assertEquals(g.polynomialDerivative().value(AccurateMath.E), h.value(AccurateMath.E), tolerance);
}
@Test
@@ -247,8 +247,8 @@ public final class PolynomialFunctionTest {
Assert.assertEquals(f.polynomialDerivative().value(-3.25), g.value(-3.25), tolerance);
// compare g' = h
- Assert.assertEquals(g.polynomialDerivative().value(FastMath.PI), h.value(FastMath.PI), tolerance);
- Assert.assertEquals(g.polynomialDerivative().value(FastMath.E), h.value(FastMath.E), tolerance);
+ Assert.assertEquals(g.polynomialDerivative().value(AccurateMath.PI), h.value(AccurateMath.PI), tolerance);
+ Assert.assertEquals(g.polynomialDerivative().value(AccurateMath.E), h.value(AccurateMath.E), tolerance);
}
public void checkPolynomial(PolynomialFunction p, String reference) {
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/analysis/polynomials/PolynomialsUtilsTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/analysis/polynomials/PolynomialsUtilsTest.java
index 8ab5eb989..62fe6f81a 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/analysis/polynomials/PolynomialsUtilsTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/analysis/polynomials/PolynomialsUtilsTest.java
@@ -19,7 +19,7 @@ package org.apache.commons.math4.legacy.analysis.polynomials;
import org.apache.commons.math4.legacy.analysis.UnivariateFunction;
import org.apache.commons.math4.legacy.analysis.integration.IterativeLegendreGaussIntegrator;
import org.apache.commons.numbers.combinatorics.BinomialCoefficient;
-import org.apache.commons.math4.legacy.util.FastMath;
+import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
import org.apache.commons.numbers.core.Precision;
import org.junit.Assert;
import org.junit.Test;
@@ -49,7 +49,7 @@ public class PolynomialsUtilsTest {
for (int k = 0; k < 12; ++k) {
PolynomialFunction Tk = PolynomialsUtils.createChebyshevPolynomial(k);
for (double x = -1; x <= 1; x += 0.02) {
- Assert.assertTrue(k + " " + Tk.value(x), FastMath.abs(Tk.value(x)) < (1 + 1e-12));
+ Assert.assertTrue(k + " " + Tk.value(x), AccurateMath.abs(Tk.value(x)) < (1 + 1e-12));
}
}
}
@@ -80,7 +80,7 @@ public class PolynomialsUtilsTest {
UnivariateFunction weight = new UnivariateFunction() {
@Override
public double value(double x) {
- return 1 / FastMath.sqrt(1 - x * x);
+ return 1 / AccurateMath.sqrt(1 - x * x);
}
};
for (int i = 0; i < 10; ++i) {
@@ -132,7 +132,7 @@ public class PolynomialsUtilsTest {
UnivariateFunction weight = new UnivariateFunction() {
@Override
public double value(double x) {
- return FastMath.exp(-x * x);
+ return AccurateMath.exp(-x * x);
}
};
for (int i = 0; i < 10; ++i) {
@@ -190,7 +190,7 @@ public class PolynomialsUtilsTest {
UnivariateFunction weight = new UnivariateFunction() {
@Override
public double value(double x) {
- return FastMath.exp(-x);
+ return AccurateMath.exp(-x);
}
};
for (int i = 0; i < 10; ++i) {
@@ -270,7 +270,7 @@ public class PolynomialsUtilsTest {
for (int i = 0; i < l40.length; ++i) {
if (i % 2 == 0) {
double ci = numerators[i / 2] / denominator;
- Assert.assertEquals(ci, l40[i], FastMath.abs(ci) * 1e-15);
+ Assert.assertEquals(ci, l40[i], AccurateMath.abs(ci) * 1e-15);
} else {
Assert.assertEquals(0, l40[i], 0);
}
@@ -308,7 +308,7 @@ public class PolynomialsUtilsTest {
UnivariateFunction weight = new UnivariateFunction() {
@Override
public double value(double x) {
- return FastMath.pow(1 - x, vv) * FastMath.pow(1 + x, ww);
+ return AccurateMath.pow(1 - x, vv) * AccurateMath.pow(1 + x, ww);
}
};
for (int i = 0; i < 10; ++i) {
@@ -384,11 +384,11 @@ public class PolynomialsUtilsTest {
if (p1.degree() == p2.degree()) {
// integral should be non-zero
Assert.assertTrue("I(" + p1.degree() + ", " + p2.degree() + ") = "+ dotProduct,
- FastMath.abs(dotProduct) > nonZeroThreshold);
+ AccurateMath.abs(dotProduct) > nonZeroThreshold);
} else {
// integral should be zero
Assert.assertEquals("I(" + p1.degree() + ", " + p2.degree() + ") = "+ dotProduct,
- 0.0, FastMath.abs(dotProduct), zeroThreshold);
+ 0.0, AccurateMath.abs(dotProduct), zeroThreshold);
}
}
}
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/analysis/solvers/BaseSecantSolverAbstractTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/analysis/solvers/BaseSecantSolverAbstractTest.java
index 7d2cb808e..cf90ac3c8 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/analysis/solvers/BaseSecantSolverAbstractTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/analysis/solvers/BaseSecantSolverAbstractTest.java
@@ -22,7 +22,7 @@ import org.apache.commons.math4.legacy.analysis.XMinus5Function;
import org.apache.commons.math4.legacy.analysis.function.Sin;
import org.apache.commons.math4.legacy.exception.NoBracketingException;
import org.apache.commons.math4.legacy.exception.NumberIsTooLargeException;
-import org.apache.commons.math4.legacy.util.FastMath;
+import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
import org.junit.Assert;
import org.junit.Test;
@@ -57,12 +57,12 @@ public abstract class BaseSecantSolverAbstractTest {
result = solver.solve(100, f, 3, 4);
//System.out.println(
// "Root: " + result + " Evaluations: " + solver.getEvaluations());
- Assert.assertEquals(result, FastMath.PI, solver.getAbsoluteAccuracy());
+ Assert.assertEquals(result, AccurateMath.PI, solver.getAbsoluteAccuracy());
Assert.assertTrue(solver.getEvaluations() <= 6);
result = solver.solve(100, f, 1, 4);
//System.out.println(
// "Root: " + result + " Evaluations: " + solver.getEvaluations());
- Assert.assertEquals(result, FastMath.PI, solver.getAbsoluteAccuracy());
+ Assert.assertEquals(result, AccurateMath.PI, solver.getAbsoluteAccuracy());
Assert.assertTrue(solver.getEvaluations() <= 7);
}
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/analysis/solvers/BisectionSolverTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/analysis/solvers/BisectionSolverTest.java
index 7c167a3ee..70c9ee3de 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/analysis/solvers/BisectionSolverTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/analysis/solvers/BisectionSolverTest.java
@@ -19,7 +19,7 @@ package org.apache.commons.math4.legacy.analysis.solvers;
import org.apache.commons.math4.legacy.analysis.QuinticFunction;
import org.apache.commons.math4.legacy.analysis.UnivariateFunction;
import org.apache.commons.math4.legacy.analysis.function.Sin;
-import org.apache.commons.math4.legacy.util.FastMath;
+import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
import org.junit.Assert;
import org.junit.Test;
@@ -33,10 +33,10 @@ public final class BisectionSolverTest {
BisectionSolver solver = new BisectionSolver();
result = solver.solve(100, f, 3, 4);
- Assert.assertEquals(result, FastMath.PI, solver.getAbsoluteAccuracy());
+ Assert.assertEquals(result, AccurateMath.PI, solver.getAbsoluteAccuracy());
result = solver.solve(100, f, 1, 4);
- Assert.assertEquals(result, FastMath.PI, solver.getAbsoluteAccuracy());
+ Assert.assertEquals(result, AccurateMath.PI, solver.getAbsoluteAccuracy());
}
@Test
@@ -85,6 +85,6 @@ public final class BisectionSolverTest {
public void testMath369() {
UnivariateFunction f = new Sin();
BisectionSolver solver = new BisectionSolver();
- Assert.assertEquals(FastMath.PI, solver.solve(100, f, 3.0, 3.2, 3.1), solver.getAbsoluteAccuracy());
+ Assert.assertEquals(AccurateMath.PI, solver.solve(100, f, 3.0, 3.2, 3.1), solver.getAbsoluteAccuracy());
}
}
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/analysis/solvers/BrentSolverTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/analysis/solvers/BrentSolverTest.java
index c5c1dcfdc..174055d04 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/analysis/solvers/BrentSolverTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/analysis/solvers/BrentSolverTest.java
@@ -29,7 +29,7 @@ import org.apache.commons.math4.legacy.analysis.function.Sqrt;
import org.apache.commons.math4.legacy.exception.NoBracketingException;
import org.apache.commons.math4.legacy.exception.NumberIsTooLargeException;
import org.apache.commons.math4.legacy.exception.TooManyEvaluationsException;
-import org.apache.commons.math4.legacy.util.FastMath;
+import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
import org.junit.Assert;
import org.junit.Test;
@@ -56,13 +56,13 @@ public final class BrentSolverTest {
result = solver.solve(100, f, 3, 4);
// System.out.println(
// "Root: " + result + " Evaluations: " + solver.getEvaluations());
- Assert.assertEquals(result, FastMath.PI, solver.getAbsoluteAccuracy());
+ Assert.assertEquals(result, AccurateMath.PI, solver.getAbsoluteAccuracy());
Assert.assertTrue(solver.getEvaluations() <= 7);
// Larger and somewhat less benign interval. The function is grows first.
result = solver.solve(100, f, 1, 4);
// System.out.println(
// "Root: " + result + " Evaluations: " + solver.getEvaluations());
- Assert.assertEquals(result, FastMath.PI, solver.getAbsoluteAccuracy());
+ Assert.assertEquals(result, AccurateMath.PI, solver.getAbsoluteAccuracy());
Assert.assertTrue(solver.getEvaluations() <= 8);
}
@@ -166,17 +166,17 @@ public final class BrentSolverTest {
BrentSolver solver = new BrentSolver();
// endpoint is root
- double result = solver.solve(100, f, FastMath.PI, 4);
- Assert.assertEquals(FastMath.PI, result, solver.getAbsoluteAccuracy());
+ double result = solver.solve(100, f, AccurateMath.PI, 4);
+ Assert.assertEquals(AccurateMath.PI, result, solver.getAbsoluteAccuracy());
- result = solver.solve(100, f, 3, FastMath.PI);
- Assert.assertEquals(FastMath.PI, result, solver.getAbsoluteAccuracy());
+ result = solver.solve(100, f, 3, AccurateMath.PI);
+ Assert.assertEquals(AccurateMath.PI, result, solver.getAbsoluteAccuracy());
- result = solver.solve(100, f, FastMath.PI, 4, 3.5);
- Assert.assertEquals(FastMath.PI, result, solver.getAbsoluteAccuracy());
+ result = solver.solve(100, f, AccurateMath.PI, 4, 3.5);
+ Assert.assertEquals(AccurateMath.PI, result, solver.getAbsoluteAccuracy());
- result = solver.solve(100, f, 3, FastMath.PI, 3.07);
- Assert.assertEquals(FastMath.PI, result, solver.getAbsoluteAccuracy());
+ result = solver.solve(100, f, 3, AccurateMath.PI, 3.07);
+ Assert.assertEquals(AccurateMath.PI, result, solver.getAbsoluteAccuracy());
}
@Test
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/analysis/solvers/FieldBracketingNthOrderBrentSolverTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/analysis/solvers/FieldBracketingNthOrderBrentSolverTest.java
index 2c9600419..a0d2f9b38 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/analysis/solvers/FieldBracketingNthOrderBrentSolverTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/analysis/solvers/FieldBracketingNthOrderBrentSolverTest.java
@@ -18,9 +18,9 @@
package org.apache.commons.math4.legacy.analysis.solvers;
import org.apache.commons.math4.legacy.analysis.RealFieldUnivariateFunction;
-import org.apache.commons.math4.legacy.dfp.Dfp;
-import org.apache.commons.math4.legacy.dfp.DfpField;
-import org.apache.commons.math4.legacy.dfp.DfpMath;
+import org.apache.commons.math4.legacy.core.dfp.Dfp;
+import org.apache.commons.math4.legacy.core.dfp.DfpField;
+import org.apache.commons.math4.legacy.core.dfp.DfpMath;
import org.apache.commons.math4.legacy.exception.MathInternalError;
import org.apache.commons.math4.legacy.exception.NumberIsTooSmallException;
import org.junit.Assert;
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/analysis/solvers/LaguerreSolverTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/analysis/solvers/LaguerreSolverTest.java
index 37fa07e92..83b6c9553 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/analysis/solvers/LaguerreSolverTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/analysis/solvers/LaguerreSolverTest.java
@@ -20,7 +20,7 @@ import org.apache.commons.numbers.complex.Complex;
import org.apache.commons.math4.legacy.analysis.polynomials.PolynomialFunction;
import org.apache.commons.math4.legacy.exception.NoBracketingException;
import org.apache.commons.math4.legacy.exception.NumberIsTooLargeException;
-import org.apache.commons.math4.legacy.util.FastMath;
+import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
import org.apache.commons.math4.legacy.TestUtils;
import org.junit.Assert;
import org.junit.Test;
@@ -48,8 +48,8 @@ public final class LaguerreSolverTest {
LaguerreSolver solver = new LaguerreSolver();
min = 0.0; max = 1.0; expected = 0.25;
- tolerance = FastMath.max(solver.getAbsoluteAccuracy(),
- FastMath.abs(expected * solver.getRelativeAccuracy()));
+ tolerance = AccurateMath.max(solver.getAbsoluteAccuracy(),
+ AccurateMath.abs(expected * solver.getRelativeAccuracy()));
result = solver.solve(100, f, min, max);
Assert.assertEquals(expected, result, tolerance);
}
@@ -67,14 +67,14 @@ public final class LaguerreSolverTest {
LaguerreSolver solver = new LaguerreSolver();
min = 0.0; max = 2.0; expected = 0.5;
- tolerance = FastMath.max(solver.getAbsoluteAccuracy(),
- FastMath.abs(expected * solver.getRelativeAccuracy()));
+ tolerance = AccurateMath.max(solver.getAbsoluteAccuracy(),
+ AccurateMath.abs(expected * solver.getRelativeAccuracy()));
result = solver.solve(100, f, min, max);
Assert.assertEquals(expected, result, tolerance);
min = -4.0; max = -1.0; expected = -3.0;
- tolerance = FastMath.max(solver.getAbsoluteAccuracy(),
- FastMath.abs(expected * solver.getRelativeAccuracy()));
+ tolerance = AccurateMath.max(solver.getAbsoluteAccuracy(),
+ AccurateMath.abs(expected * solver.getRelativeAccuracy()));
result = solver.solve(100, f, min, max);
Assert.assertEquals(expected, result, tolerance);
}
@@ -92,20 +92,20 @@ public final class LaguerreSolverTest {
LaguerreSolver solver = new LaguerreSolver();
min = -2.0; max = 2.0; expected = -1.0;
- tolerance = FastMath.max(solver.getAbsoluteAccuracy(),
- FastMath.abs(expected * solver.getRelativeAccuracy()));
+ tolerance = AccurateMath.max(solver.getAbsoluteAccuracy(),
+ AccurateMath.abs(expected * solver.getRelativeAccuracy()));
result = solver.solve(100, f, min, max);
Assert.assertEquals(expected, result, tolerance);
min = -5.0; max = -2.5; expected = -3.0;
- tolerance = FastMath.max(solver.getAbsoluteAccuracy(),
- FastMath.abs(expected * solver.getRelativeAccuracy()));
+ tolerance = AccurateMath.max(solver.getAbsoluteAccuracy(),
+ AccurateMath.abs(expected * solver.getRelativeAccuracy()));
result = solver.solve(100, f, min, max);
Assert.assertEquals(expected, result, tolerance);
min = 3.0; max = 6.0; expected = 4.0;
- tolerance = FastMath.max(solver.getAbsoluteAccuracy(),
- FastMath.abs(expected * solver.getRelativeAccuracy()));
+ tolerance = AccurateMath.max(solver.getAbsoluteAccuracy(),
+ AccurateMath.abs(expected * solver.getRelativeAccuracy()));
result = solver.solve(100, f, min, max);
Assert.assertEquals(expected, result, tolerance);
}
@@ -123,11 +123,11 @@ public final class LaguerreSolverTest {
for (Complex expected : new Complex[] { Complex.ofCartesian(0, -2),
Complex.ofCartesian(0, 2),
- Complex.ofCartesian(0.5, 0.5 * FastMath.sqrt(3)),
+ Complex.ofCartesian(0.5, 0.5 * AccurateMath.sqrt(3)),
Complex.ofCartesian(-1, 0),
- Complex.ofCartesian(0.5, -0.5 * FastMath.sqrt(3.0)) }) {
- final double tolerance = FastMath.max(solver.getAbsoluteAccuracy(),
- FastMath.abs(expected.abs() * solver.getRelativeAccuracy()));
+ Complex.ofCartesian(0.5, -0.5 * AccurateMath.sqrt(3.0)) }) {
+ final double tolerance = AccurateMath.max(solver.getAbsoluteAccuracy(),
+ AccurateMath.abs(expected.abs() * solver.getRelativeAccuracy()));
TestUtils.assertContains(result, expected, tolerance);
}
}
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/analysis/solvers/MullerSolver2Test.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/analysis/solvers/MullerSolver2Test.java
index 07668f340..aca22e75d 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/analysis/solvers/MullerSolver2Test.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/analysis/solvers/MullerSolver2Test.java
@@ -22,7 +22,7 @@ import org.apache.commons.math4.legacy.analysis.function.Expm1;
import org.apache.commons.math4.legacy.analysis.function.Sin;
import org.apache.commons.math4.legacy.exception.NoBracketingException;
import org.apache.commons.math4.legacy.exception.NumberIsTooLargeException;
-import org.apache.commons.math4.legacy.util.FastMath;
+import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
import org.junit.Assert;
import org.junit.Test;
@@ -48,15 +48,15 @@ public final class MullerSolver2Test {
UnivariateSolver solver = new MullerSolver2();
double min, max, expected, result, tolerance;
- min = 3.0; max = 4.0; expected = FastMath.PI;
- tolerance = FastMath.max(solver.getAbsoluteAccuracy(),
- FastMath.abs(expected * solver.getRelativeAccuracy()));
+ min = 3.0; max = 4.0; expected = AccurateMath.PI;
+ tolerance = AccurateMath.max(solver.getAbsoluteAccuracy(),
+ AccurateMath.abs(expected * solver.getRelativeAccuracy()));
result = solver.solve(100, f, min, max);
Assert.assertEquals(expected, result, tolerance);
min = -1.0; max = 1.5; expected = 0.0;
- tolerance = FastMath.max(solver.getAbsoluteAccuracy(),
- FastMath.abs(expected * solver.getRelativeAccuracy()));
+ tolerance = AccurateMath.max(solver.getAbsoluteAccuracy(),
+ AccurateMath.abs(expected * solver.getRelativeAccuracy()));
result = solver.solve(100, f, min, max);
Assert.assertEquals(expected, result, tolerance);
}
@@ -71,20 +71,20 @@ public final class MullerSolver2Test {
double min, max, expected, result, tolerance;
min = -0.4; max = 0.2; expected = 0.0;
- tolerance = FastMath.max(solver.getAbsoluteAccuracy(),
- FastMath.abs(expected * solver.getRelativeAccuracy()));
+ tolerance = AccurateMath.max(solver.getAbsoluteAccuracy(),
+ AccurateMath.abs(expected * solver.getRelativeAccuracy()));
result = solver.solve(100, f, min, max);
Assert.assertEquals(expected, result, tolerance);
min = 0.75; max = 1.5; expected = 1.0;
- tolerance = FastMath.max(solver.getAbsoluteAccuracy(),
- FastMath.abs(expected * solver.getRelativeAccuracy()));
+ tolerance = AccurateMath.max(solver.getAbsoluteAccuracy(),
+ AccurateMath.abs(expected * solver.getRelativeAccuracy()));
result = solver.solve(100, f, min, max);
Assert.assertEquals(expected, result, tolerance);
min = -0.9; max = -0.2; expected = -0.5;
- tolerance = FastMath.max(solver.getAbsoluteAccuracy(),
- FastMath.abs(expected * solver.getRelativeAccuracy()));
+ tolerance = AccurateMath.max(solver.getAbsoluteAccuracy(),
+ AccurateMath.abs(expected * solver.getRelativeAccuracy()));
result = solver.solve(100, f, min, max);
Assert.assertEquals(expected, result, tolerance);
}
@@ -101,20 +101,20 @@ public final class MullerSolver2Test {
double min, max, expected, result, tolerance;
min = -1.0; max = 2.0; expected = 0.0;
- tolerance = FastMath.max(solver.getAbsoluteAccuracy(),
- FastMath.abs(expected * solver.getRelativeAccuracy()));
+ tolerance = AccurateMath.max(solver.getAbsoluteAccuracy(),
+ AccurateMath.abs(expected * solver.getRelativeAccuracy()));
result = solver.solve(100, f, min, max);
Assert.assertEquals(expected, result, tolerance);
min = -20.0; max = 10.0; expected = 0.0;
- tolerance = FastMath.max(solver.getAbsoluteAccuracy(),
- FastMath.abs(expected * solver.getRelativeAccuracy()));
+ tolerance = AccurateMath.max(solver.getAbsoluteAccuracy(),
+ AccurateMath.abs(expected * solver.getRelativeAccuracy()));
result = solver.solve(100, f, min, max);
Assert.assertEquals(expected, result, tolerance);
min = -50.0; max = 100.0; expected = 0.0;
- tolerance = FastMath.max(solver.getAbsoluteAccuracy(),
- FastMath.abs(expected * solver.getRelativeAccuracy()));
+ tolerance = AccurateMath.max(solver.getAbsoluteAccuracy(),
+ AccurateMath.abs(expected * solver.getRelativeAccuracy()));
result = solver.solve(100, f, min, max);
Assert.assertEquals(expected, result, tolerance);
}
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/analysis/solvers/MullerSolverTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/analysis/solvers/MullerSolverTest.java
index c87d0751d..2f8740d35 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/analysis/solvers/MullerSolverTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/analysis/solvers/MullerSolverTest.java
@@ -22,7 +22,7 @@ import org.apache.commons.math4.legacy.analysis.function.Expm1;
import org.apache.commons.math4.legacy.analysis.function.Sin;
import org.apache.commons.math4.legacy.exception.NoBracketingException;
import org.apache.commons.math4.legacy.exception.NumberIsTooLargeException;
-import org.apache.commons.math4.legacy.util.FastMath;
+import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
import org.junit.Assert;
import org.junit.Test;
@@ -48,15 +48,15 @@ public final class MullerSolverTest {
UnivariateSolver solver = new MullerSolver();
double min, max, expected, result, tolerance;
- min = 3.0; max = 4.0; expected = FastMath.PI;
- tolerance = FastMath.max(solver.getAbsoluteAccuracy(),
- FastMath.abs(expected * solver.getRelativeAccuracy()));
+ min = 3.0; max = 4.0; expected = AccurateMath.PI;
+ tolerance = AccurateMath.max(solver.getAbsoluteAccuracy(),
+ AccurateMath.abs(expected * solver.getRelativeAccuracy()));
result = solver.solve(100, f, min, max);
Assert.assertEquals(expected, result, tolerance);
min = -1.0; max = 1.5; expected = 0.0;
- tolerance = FastMath.max(solver.getAbsoluteAccuracy(),
- FastMath.abs(expected * solver.getRelativeAccuracy()));
+ tolerance = AccurateMath.max(solver.getAbsoluteAccuracy(),
+ AccurateMath.abs(expected * solver.getRelativeAccuracy()));
result = solver.solve(100, f, min, max);
Assert.assertEquals(expected, result, tolerance);
}
@@ -71,20 +71,20 @@ public final class MullerSolverTest {
double min, max, expected, result, tolerance;
min = -0.4; max = 0.2; expected = 0.0;
- tolerance = FastMath.max(solver.getAbsoluteAccuracy(),
- FastMath.abs(expected * solver.getRelativeAccuracy()));
+ tolerance = AccurateMath.max(solver.getAbsoluteAccuracy(),
+ AccurateMath.abs(expected * solver.getRelativeAccuracy()));
result = solver.solve(100, f, min, max);
Assert.assertEquals(expected, result, tolerance);
min = 0.75; max = 1.5; expected = 1.0;
- tolerance = FastMath.max(solver.getAbsoluteAccuracy(),
- FastMath.abs(expected * solver.getRelativeAccuracy()));
+ tolerance = AccurateMath.max(solver.getAbsoluteAccuracy(),
+ AccurateMath.abs(expected * solver.getRelativeAccuracy()));
result = solver.solve(100, f, min, max);
Assert.assertEquals(expected, result, tolerance);
min = -0.9; max = -0.2; expected = -0.5;
- tolerance = FastMath.max(solver.getAbsoluteAccuracy(),
- FastMath.abs(expected * solver.getRelativeAccuracy()));
+ tolerance = AccurateMath.max(solver.getAbsoluteAccuracy(),
+ AccurateMath.abs(expected * solver.getRelativeAccuracy()));
result = solver.solve(100, f, min, max);
Assert.assertEquals(expected, result, tolerance);
}
@@ -103,20 +103,20 @@ public final class MullerSolverTest {
double min, max, expected, result, tolerance;
min = -1.0; max = 2.0; expected = 0.0;
- tolerance = FastMath.max(solver.getAbsoluteAccuracy(),
- FastMath.abs(expected * solver.getRelativeAccuracy()));
+ tolerance = AccurateMath.max(solver.getAbsoluteAccuracy(),
+ AccurateMath.abs(expected * solver.getRelativeAccuracy()));
result = solver.solve(100, f, min, max);
Assert.assertEquals(expected, result, tolerance);
min = -20.0; max = 10.0; expected = 0.0;
- tolerance = FastMath.max(solver.getAbsoluteAccuracy(),
- FastMath.abs(expected * solver.getRelativeAccuracy()));
+ tolerance = AccurateMath.max(solver.getAbsoluteAccuracy(),
+ AccurateMath.abs(expected * solver.getRelativeAccuracy()));
result = solver.solve(100, f, min, max);
Assert.assertEquals(expected, result, tolerance);
min = -50.0; max = 100.0; expected = 0.0;
- tolerance = FastMath.max(solver.getAbsoluteAccuracy(),
- FastMath.abs(expected * solver.getRelativeAccuracy()));
+ tolerance = AccurateMath.max(solver.getAbsoluteAccuracy(),
+ AccurateMath.abs(expected * solver.getRelativeAccuracy()));
result = solver.solve(100, f, min, max);
Assert.assertEquals(expected, result, tolerance);
}
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/analysis/solvers/NewtonRaphsonSolverTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/analysis/solvers/NewtonRaphsonSolverTest.java
index 2a1243947..9aec41a81 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/analysis/solvers/NewtonRaphsonSolverTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/analysis/solvers/NewtonRaphsonSolverTest.java
@@ -19,7 +19,7 @@ package org.apache.commons.math4.legacy.analysis.solvers;
import org.apache.commons.math4.legacy.analysis.QuinticFunction;
import org.apache.commons.math4.legacy.analysis.differentiation.UnivariateDifferentiableFunction;
import org.apache.commons.math4.legacy.analysis.function.Sin;
-import org.apache.commons.math4.legacy.util.FastMath;
+import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
import org.junit.Assert;
import org.junit.Test;
@@ -37,10 +37,10 @@ public final class NewtonRaphsonSolverTest {
NewtonRaphsonSolver solver = new NewtonRaphsonSolver();
result = solver.solve(100, f, 3, 4);
- Assert.assertEquals(result, FastMath.PI, solver.getAbsoluteAccuracy());
+ Assert.assertEquals(result, AccurateMath.PI, solver.getAbsoluteAccuracy());
result = solver.solve(100, f, 1, 4);
- Assert.assertEquals(result, FastMath.PI, solver.getAbsoluteAccuracy());
+ Assert.assertEquals(result, AccurateMath.PI, solver.getAbsoluteAccuracy());
Assert.assertTrue(solver.getEvaluations() > 0);
}
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/analysis/solvers/RegulaFalsiSolverTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/analysis/solvers/RegulaFalsiSolverTest.java
index 8c8193af7..a560fbf13 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/analysis/solvers/RegulaFalsiSolverTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/analysis/solvers/RegulaFalsiSolverTest.java
@@ -19,7 +19,7 @@ package org.apache.commons.math4.legacy.analysis.solvers;
import org.apache.commons.math4.legacy.analysis.UnivariateFunction;
import org.apache.commons.math4.legacy.exception.ConvergenceException;
-import org.apache.commons.math4.legacy.util.FastMath;
+import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
import org.junit.Test;
import org.junit.Assert;
@@ -49,7 +49,7 @@ public final class RegulaFalsiSolverTest extends BaseSecantSolverAbstractTest {
/** {@inheritDoc} */
@Override
public double value(double x) {
- return FastMath.exp(x) - FastMath.pow(Math.PI, 3.0);
+ return AccurateMath.exp(x) - AccurateMath.pow(Math.PI, 3.0);
}
};
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/analysis/solvers/RiddersSolverTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/analysis/solvers/RiddersSolverTest.java
index a7ebb388b..3edee2e66 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/analysis/solvers/RiddersSolverTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/analysis/solvers/RiddersSolverTest.java
@@ -22,7 +22,7 @@ import org.apache.commons.math4.legacy.analysis.function.Expm1;
import org.apache.commons.math4.legacy.analysis.function.Sin;
import org.apache.commons.math4.legacy.exception.NoBracketingException;
import org.apache.commons.math4.legacy.exception.NumberIsTooLargeException;
-import org.apache.commons.math4.legacy.util.FastMath;
+import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
import org.junit.Assert;
import org.junit.Test;
@@ -46,15 +46,15 @@ public final class RiddersSolverTest {
UnivariateSolver solver = new RiddersSolver();
double min, max, expected, result, tolerance;
- min = 3.0; max = 4.0; expected = FastMath.PI;
- tolerance = FastMath.max(solver.getAbsoluteAccuracy(),
- FastMath.abs(expected * solver.getRelativeAccuracy()));
+ min = 3.0; max = 4.0; expected = AccurateMath.PI;
+ tolerance = AccurateMath.max(solver.getAbsoluteAccuracy(),
+ AccurateMath.abs(expected * solver.getRelativeAccuracy()));
result = solver.solve(100, f, min, max);
Assert.assertEquals(expected, result, tolerance);
min = -1.0; max = 1.5; expected = 0.0;
- tolerance = FastMath.max(solver.getAbsoluteAccuracy(),
- FastMath.abs(expected * solver.getRelativeAccuracy()));
+ tolerance = AccurateMath.max(solver.getAbsoluteAccuracy(),
+ AccurateMath.abs(expected * solver.getRelativeAccuracy()));
result = solver.solve(100, f, min, max);
Assert.assertEquals(expected, result, tolerance);
}
@@ -69,20 +69,20 @@ public final class RiddersSolverTest {
double min, max, expected, result, tolerance;
min = -0.4; max = 0.2; expected = 0.0;
- tolerance = FastMath.max(solver.getAbsoluteAccuracy(),
- FastMath.abs(expected * solver.getRelativeAccuracy()));
+ tolerance = AccurateMath.max(solver.getAbsoluteAccuracy(),
+ AccurateMath.abs(expected * solver.getRelativeAccuracy()));
result = solver.solve(100, f, min, max);
Assert.assertEquals(expected, result, tolerance);
min = 0.75; max = 1.5; expected = 1.0;
- tolerance = FastMath.max(solver.getAbsoluteAccuracy(),
- FastMath.abs(expected * solver.getRelativeAccuracy()));
+ tolerance = AccurateMath.max(solver.getAbsoluteAccuracy(),
+ AccurateMath.abs(expected * solver.getRelativeAccuracy()));
result = solver.solve(100, f, min, max);
Assert.assertEquals(expected, result, tolerance);
min = -0.9; max = -0.2; expected = -0.5;
- tolerance = FastMath.max(solver.getAbsoluteAccuracy(),
- FastMath.abs(expected * solver.getRelativeAccuracy()));
+ tolerance = AccurateMath.max(solver.getAbsoluteAccuracy(),
+ AccurateMath.abs(expected * solver.getRelativeAccuracy()));
result = solver.solve(100, f, min, max);
Assert.assertEquals(expected, result, tolerance);
}
@@ -97,20 +97,20 @@ public final class RiddersSolverTest {
double min, max, expected, result, tolerance;
min = -1.0; max = 2.0; expected = 0.0;
- tolerance = FastMath.max(solver.getAbsoluteAccuracy(),
- FastMath.abs(expected * solver.getRelativeAccuracy()));
+ tolerance = AccurateMath.max(solver.getAbsoluteAccuracy(),
+ AccurateMath.abs(expected * solver.getRelativeAccuracy()));
result = solver.solve(100, f, min, max);
Assert.assertEquals(expected, result, tolerance);
min = -20.0; max = 10.0; expected = 0.0;
- tolerance = FastMath.max(solver.getAbsoluteAccuracy(),
- FastMath.abs(expected * solver.getRelativeAccuracy()));
+ tolerance = AccurateMath.max(solver.getAbsoluteAccuracy(),
+ AccurateMath.abs(expected * solver.getRelativeAccuracy()));
result = solver.solve(100, f, min, max);
Assert.assertEquals(expected, result, tolerance);
min = -50.0; max = 100.0; expected = 0.0;
- tolerance = FastMath.max(solver.getAbsoluteAccuracy(),
- FastMath.abs(expected * solver.getRelativeAccuracy()));
+ tolerance = AccurateMath.max(solver.getAbsoluteAccuracy(),
+ AccurateMath.abs(expected * solver.getRelativeAccuracy()));
result = solver.solve(100, f, min, max);
Assert.assertEquals(expected, result, tolerance);
}
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/analysis/solvers/UnivariateSolverUtilsTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/analysis/solvers/UnivariateSolverUtilsTest.java
index b710144cd..4548cd155 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/analysis/solvers/UnivariateSolverUtilsTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/analysis/solvers/UnivariateSolverUtilsTest.java
@@ -23,7 +23,7 @@ import org.apache.commons.math4.legacy.analysis.function.Sin;
import org.apache.commons.math4.legacy.exception.MathIllegalArgumentException;
import org.apache.commons.math4.legacy.exception.NoBracketingException;
import org.apache.commons.math4.legacy.exception.NullArgumentException;
-import org.apache.commons.math4.legacy.util.FastMath;
+import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
import org.junit.Assert;
import org.junit.Test;
@@ -57,7 +57,7 @@ public class UnivariateSolverUtilsTest {
@Test
public void testSolveSin() {
double x = UnivariateSolverUtils.solve(sin, 1.0, 4.0);
- Assert.assertEquals(FastMath.PI, x, 1.0e-4);
+ Assert.assertEquals(AccurateMath.PI, x, 1.0e-4);
}
@Test(expected=NullArgumentException.class)
@@ -71,7 +71,7 @@ public class UnivariateSolverUtilsTest {
double accuracy = 1.0e-6;
double x = UnivariateSolverUtils.solve(sin, 1.0,
4.0, accuracy);
- Assert.assertEquals(FastMath.PI, x, accuracy);
+ Assert.assertEquals(AccurateMath.PI, x, accuracy);
}
@Test(expected=MathIllegalArgumentException.class)
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/complex/ComplexFormatAbstractTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/complex/ComplexFormatAbstractTest.java
index 46178b750..3ffc5d687 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/complex/ComplexFormatAbstractTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/complex/ComplexFormatAbstractTest.java
@@ -29,7 +29,7 @@ import org.apache.commons.numbers.complex.Complex;
import org.apache.commons.math4.legacy.exception.MathIllegalArgumentException;
import org.apache.commons.math4.legacy.exception.NoDataException;
import org.apache.commons.math4.legacy.exception.NullArgumentException;
-import org.apache.commons.math4.legacy.util.FastMath;
+import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
public abstract class ComplexFormatAbstractTest {
@@ -402,7 +402,7 @@ public abstract class ComplexFormatAbstractTest {
@Test
public void testFormatNumber() {
ComplexFormat cf = ComplexFormat.getInstance(getLocale());
- Double pi = Double.valueOf(FastMath.PI);
+ Double pi = Double.valueOf(AccurateMath.PI);
String text = cf.format(pi);
Assert.assertEquals("3" + getDecimalCharacter() + "1415926536", text);
}
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/distribution/EmpiricalDistributionTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/distribution/EmpiricalDistributionTest.java
index b725c29cc..f64217fa3 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/distribution/EmpiricalDistributionTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/distribution/EmpiricalDistributionTest.java
@@ -39,7 +39,7 @@ import org.apache.commons.math4.legacy.exception.MathIllegalStateException;
import org.apache.commons.math4.legacy.exception.NullArgumentException;
import org.apache.commons.math4.legacy.exception.NotStrictlyPositiveException;
import org.apache.commons.math4.legacy.stat.descriptive.SummaryStatistics;
-import org.apache.commons.math4.legacy.util.FastMath;
+import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
@@ -579,10 +579,10 @@ public final class EmpiricalDistributionTest extends RealDistributionAbstractTes
*/
private int findBin(double x) {
// Number of bins below x should be trunc(x/10)
- final double nMinus = FastMath.floor(x / 10);
- final int bin = (int) FastMath.round(nMinus);
+ final double nMinus = AccurateMath.floor(x / 10);
+ final int bin = (int) AccurateMath.round(nMinus);
// If x falls on a bin boundary, it is in the lower bin
- return FastMath.floor(x / 10) == x / 10 ? bin - 1 : bin;
+ return AccurateMath.floor(x / 10) == x / 10 ? bin - 1 : bin;
}
/**
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/distribution/EnumeratedIntegerDistributionTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/distribution/EnumeratedIntegerDistributionTest.java
index 1c11ec956..eed344364 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/distribution/EnumeratedIntegerDistributionTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/distribution/EnumeratedIntegerDistributionTest.java
@@ -23,7 +23,7 @@ import org.apache.commons.math4.legacy.exception.MathArithmeticException;
import org.apache.commons.math4.legacy.exception.NotANumberException;
import org.apache.commons.math4.legacy.exception.NotFiniteNumberException;
import org.apache.commons.math4.legacy.exception.NotPositiveException;
-import org.apache.commons.math4.legacy.util.FastMath;
+import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
import org.apache.commons.rng.simple.RandomSource;
import org.junit.Assert;
import org.junit.Test;
@@ -170,7 +170,7 @@ public class EnumeratedIntegerDistributionTest {
Assert.assertEquals(testDistribution.getMean(),
sum / n, 1e-2);
Assert.assertEquals(testDistribution.getVariance(),
- sumOfSquares / n - FastMath.pow(sum / n, 2), 1e-2);
+ sumOfSquares / n - AccurateMath.pow(sum / n, 2), 1e-2);
}
@Test
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/distribution/EnumeratedRealDistributionTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/distribution/EnumeratedRealDistributionTest.java
index 8746909b4..9c678309d 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/distribution/EnumeratedRealDistributionTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/distribution/EnumeratedRealDistributionTest.java
@@ -27,7 +27,7 @@ import org.apache.commons.math4.legacy.exception.MathArithmeticException;
import org.apache.commons.math4.legacy.exception.NotANumberException;
import org.apache.commons.math4.legacy.exception.NotFiniteNumberException;
import org.apache.commons.math4.legacy.exception.NotPositiveException;
-import org.apache.commons.math4.legacy.util.FastMath;
+import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
import org.apache.commons.math4.legacy.util.Pair;
import org.apache.commons.rng.UniformRandomProvider;
import org.apache.commons.rng.simple.RandomSource;
@@ -189,7 +189,7 @@ public class EnumeratedRealDistributionTest {
Assert.assertEquals(testDistribution.getMean(),
sum / n, 1e-2);
Assert.assertEquals(testDistribution.getVariance(),
- sumOfSquares / n - FastMath.pow(sum / n, 2), 1e-2);
+ sumOfSquares / n - AccurateMath.pow(sum / n, 2), 1e-2);
}
@Test
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/distribution/IntegerDistributionAbstractTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/distribution/IntegerDistributionAbstractTest.java
index e7233ada5..5e3771006 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/distribution/IntegerDistributionAbstractTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/distribution/IntegerDistributionAbstractTest.java
@@ -20,7 +20,7 @@ import org.apache.commons.statistics.distribution.DiscreteDistribution;
import org.apache.commons.math4.legacy.TestUtils;
import org.apache.commons.math4.legacy.exception.MathIllegalArgumentException;
import org.apache.commons.rng.simple.RandomSource;
-import org.apache.commons.math4.legacy.util.FastMath;
+import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
@@ -99,7 +99,7 @@ public abstract class IntegerDistributionAbstractTest {
final double[] densityTestValues = makeDensityTestValues();
final double[] logDensityTestValues = new double[densityTestValues.length];
for (int i = 0; i < densityTestValues.length; i++) {
- logDensityTestValues[i] = FastMath.log(densityTestValues[i]);
+ logDensityTestValues[i] = AccurateMath.log(densityTestValues[i]);
}
return logDensityTestValues;
}
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/distribution/RealDistributionAbstractTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/distribution/RealDistributionAbstractTest.java
index 4e9573ec4..13e122db5 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/distribution/RealDistributionAbstractTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/distribution/RealDistributionAbstractTest.java
@@ -33,7 +33,7 @@ import org.apache.commons.math4.legacy.analysis.integration.IterativeLegendreGau
import org.apache.commons.math4.legacy.exception.MathIllegalArgumentException;
import org.apache.commons.math4.legacy.exception.NumberIsTooLargeException;
import org.apache.commons.rng.simple.RandomSource;
-import org.apache.commons.math4.legacy.util.FastMath;
+import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
@@ -117,7 +117,7 @@ public abstract class RealDistributionAbstractTest {
final double[] densityTestValues = makeDensityTestValues();
final double[] logDensityTestValues = new double[densityTestValues.length];
for (int i = 0; i < densityTestValues.length; i++) {
- logDensityTestValues[i] = FastMath.log(densityTestValues[i]);
+ logDensityTestValues[i] = AccurateMath.log(densityTestValues[i]);
}
return logDensityTestValues;
}
@@ -285,8 +285,8 @@ public abstract class RealDistributionAbstractTest {
(cumulativeTestPoints[i], cumulativeTestPoints[i]), tolerance);
// check that P(a < X <= b) = P(X <= b) - P(X <= a)
- double upper = FastMath.max(cumulativeTestPoints[i], cumulativeTestPoints[i -1]);
- double lower = FastMath.min(cumulativeTestPoints[i], cumulativeTestPoints[i -1]);
+ double upper = AccurateMath.max(cumulativeTestPoints[i], cumulativeTestPoints[i -1]);
+ double lower = AccurateMath.min(cumulativeTestPoints[i], cumulativeTestPoints[i -1]);
double diff = distribution.cumulativeProbability(upper) -
distribution.cumulativeProbability(lower);
double direct = distribution.probability(lower, upper);
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/field/ExtendedFieldElementAbstractTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/field/ExtendedFieldElementAbstractTest.java
new file mode 100644
index 000000000..a1b2670cd
--- /dev/null
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/field/ExtendedFieldElementAbstractTest.java
@@ -0,0 +1,542 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.math4.legacy.field;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+import org.apache.commons.numbers.arrays.LinearCombination;
+import org.apache.commons.rng.UniformRandomProvider;
+import org.apache.commons.rng.simple.RandomSource;
+import org.apache.commons.math4.legacy.core.RealFieldElement;
+import org.apache.commons.math4.legacy.core.MathArrays;
+import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
+
+public abstract class ExtendedFieldElementAbstractTest> {
+
+ protected abstract T build(double x);
+
+ @Test
+ public void testAddField() {
+ for (double x = -3; x < 3; x += 0.2) {
+ for (double y = -3; y < 3; y += 0.2) {
+ checkRelative(x + y, build(x).add(build(y)));
+ }
+ }
+ }
+
+ @Test
+ public void testAddDouble() {
+ for (double x = -3; x < 3; x += 0.2) {
+ for (double y = -3; y < 3; y += 0.2) {
+ checkRelative(x + y, build(x).add(y));
+ }
+ }
+ }
+
+ @Test
+ public void testSubtractField() {
+ for (double x = -3; x < 3; x += 0.2) {
+ for (double y = -3; y < 3; y += 0.2) {
+ checkRelative(x - y, build(x).subtract(build(y)));
+ }
+ }
+ }
+
+ @Test
+ public void testSubtractDouble() {
+ for (double x = -3; x < 3; x += 0.2) {
+ for (double y = -3; y < 3; y += 0.2) {
+ checkRelative(x - y, build(x).subtract(y));
+ }
+ }
+ }
+
+ @Test
+ public void testMultiplyField() {
+ for (double x = -3; x < 3; x += 0.2) {
+ for (double y = -3; y < 3; y += 0.2) {
+ checkRelative(x * y, build(x).multiply(build(y)));
+ }
+ }
+ }
+
+ @Test
+ public void testMultiplyDouble() {
+ for (double x = -3; x < 3; x += 0.2) {
+ for (double y = -3; y < 3; y += 0.2) {
+ checkRelative(x * y, build(x).multiply(y));
+ }
+ }
+ }
+
+ @Test
+ public void testMultiplyInt() {
+ for (double x = -3; x < 3; x += 0.2) {
+ for (int y = -10; y < 10; y += 1) {
+ checkRelative(x * y, build(x).multiply(y));
+ }
+ }
+ }
+
+ @Test
+ public void testDivideField() {
+ for (double x = -3; x < 3; x += 0.2) {
+ for (double y = -3; y < 3; y += 0.2) {
+ checkRelative(x / y, build(x).divide(build(y)));
+ }
+ }
+ }
+
+ @Test
+ public void testDivideDouble() {
+ for (double x = -3; x < 3; x += 0.2) {
+ for (double y = -3; y < 3; y += 0.2) {
+ checkRelative(x / y, build(x).divide(y));
+ }
+ }
+ }
+
+ @Test
+ public void testRemainderField() {
+ for (double x = -3; x < 3; x += 0.2) {
+ for (double y = -3; y < 3; y += 0.2) {
+ checkRelative(AccurateMath.IEEEremainder(x, y), build(x).remainder(build(y)));
+ }
+ }
+ }
+
+ @Test
+ public void testRemainderDouble() {
+ for (double x = -3; x < 3; x += 0.2) {
+ for (double y = -3.2; y < 3.2; y += 0.25) {
+ checkRelative(AccurateMath.IEEEremainder(x, y), build(x).remainder(y));
+ }
+ }
+ }
+
+ @Test
+ public void testCos() {
+ for (double x = -0.9; x < 0.9; x += 0.05) {
+ checkRelative(AccurateMath.cos(x), build(x).cos());
+ }
+ }
+
+ @Test
+ public void testAcos() {
+ for (double x = -0.9; x < 0.9; x += 0.05) {
+ checkRelative(AccurateMath.acos(x), build(x).acos());
+ }
+ }
+
+ @Test
+ public void testSin() {
+ for (double x = -0.9; x < 0.9; x += 0.05) {
+ checkRelative(AccurateMath.sin(x), build(x).sin());
+ }
+ }
+
+ @Test
+ public void testAsin() {
+ for (double x = -0.9; x < 0.9; x += 0.05) {
+ checkRelative(AccurateMath.asin(x), build(x).asin());
+ }
+ }
+
+ @Test
+ public void testTan() {
+ for (double x = -0.9; x < 0.9; x += 0.05) {
+ checkRelative(AccurateMath.tan(x), build(x).tan());
+ }
+ }
+
+ @Test
+ public void testAtan() {
+ for (double x = -0.9; x < 0.9; x += 0.05) {
+ checkRelative(AccurateMath.atan(x), build(x).atan());
+ }
+ }
+
+ @Test
+ public void testAtan2() {
+ for (double x = -3; x < 3; x += 0.2) {
+ for (double y = -3; y < 3; y += 0.2) {
+ checkRelative(AccurateMath.atan2(x, y), build(x).atan2(build(y)));
+ }
+ }
+ }
+
+ @Test
+ public void testCosh() {
+ for (double x = -0.9; x < 0.9; x += 0.05) {
+ checkRelative(AccurateMath.cosh(x), build(x).cosh());
+ }
+ }
+
+ @Test
+ public void testAcosh() {
+ for (double x = 1.1; x < 5.0; x += 0.05) {
+ checkRelative(AccurateMath.acosh(x), build(x).acosh());
+ }
+ }
+
+ @Test
+ public void testSinh() {
+ for (double x = -0.9; x < 0.9; x += 0.05) {
+ checkRelative(AccurateMath.sinh(x), build(x).sinh());
+ }
+ }
+
+ @Test
+ public void testAsinh() {
+ for (double x = -0.9; x < 0.9; x += 0.05) {
+ checkRelative(AccurateMath.asinh(x), build(x).asinh());
+ }
+ }
+
+ @Test
+ public void testTanh() {
+ for (double x = -0.9; x < 0.9; x += 0.05) {
+ checkRelative(AccurateMath.tanh(x), build(x).tanh());
+ }
+ }
+
+ @Test
+ public void testAtanh() {
+ for (double x = -0.9; x < 0.9; x += 0.05) {
+ checkRelative(AccurateMath.atanh(x), build(x).atanh());
+ }
+ }
+
+ @Test
+ public void testSqrt() {
+ for (double x = 0.01; x < 0.9; x += 0.05) {
+ checkRelative(AccurateMath.sqrt(x), build(x).sqrt());
+ }
+ }
+
+ @Test
+ public void testCbrt() {
+ for (double x = -0.9; x < 0.9; x += 0.05) {
+ checkRelative(AccurateMath.cbrt(x), build(x).cbrt());
+ }
+ }
+
+ @Test
+ public void testHypot() {
+ for (double x = -3; x < 3; x += 0.2) {
+ for (double y = -3; y < 3; y += 0.2) {
+ checkRelative(AccurateMath.hypot(x, y), build(x).hypot(build(y)));
+ }
+ }
+ }
+
+ @Test
+ public void testRootN() {
+ for (double x = -0.9; x < 0.9; x += 0.05) {
+ for (int n = 1; n < 5; ++n) {
+ if (x < 0) {
+ if (n % 2 == 1) {
+ checkRelative(-AccurateMath.pow(-x, 1.0 / n), build(x).rootN(n));
+ }
+ } else {
+ checkRelative(AccurateMath.pow(x, 1.0 / n), build(x).rootN(n));
+ }
+ }
+ }
+ }
+
+ @Test
+ public void testPowField() {
+ for (double x = -0.9; x < 0.9; x += 0.05) {
+ for (double y = 0.1; y < 4; y += 0.2) {
+ checkRelative(AccurateMath.pow(x, y), build(x).pow(build(y)));
+ }
+ }
+ }
+
+ @Test
+ public void testPowDouble() {
+ for (double x = -0.9; x < 0.9; x += 0.05) {
+ for (double y = 0.1; y < 4; y += 0.2) {
+ checkRelative(AccurateMath.pow(x, y), build(x).pow(y));
+ }
+ }
+ }
+
+ @Test
+ public void testPowInt() {
+ for (double x = -0.9; x < 0.9; x += 0.05) {
+ for (int n = 0; n < 5; ++n) {
+ checkRelative(AccurateMath.pow(x, n), build(x).pow(n));
+ }
+ }
+ }
+
+ @Test
+ public void testExp() {
+ for (double x = -0.9; x < 0.9; x += 0.05) {
+ checkRelative(AccurateMath.exp(x), build(x).exp());
+ }
+ }
+
+ @Test
+ public void testExpm1() {
+ for (double x = -0.9; x < 0.9; x += 0.05) {
+ checkRelative(AccurateMath.expm1(x), build(x).expm1());
+ }
+ }
+
+ @Test
+ public void testLog() {
+ for (double x = 0.01; x < 0.9; x += 0.05) {
+ checkRelative(AccurateMath.log(x), build(x).log());
+ }
+ }
+
+ @Test
+ public void testLog1p() {
+ for (double x = -0.9; x < 0.9; x += 0.05) {
+ checkRelative(AccurateMath.log1p(x), build(x).log1p());
+ }
+ }
+
+// TODO: add this test in 4.0, as it is not possible to do it in 3.2
+// due to incompatibility of the return type in the Dfp class
+// @Test
+// public void testLog10() {
+// for (double x = -0.9; x < 0.9; x += 0.05) {
+// checkRelative(AccurateMath.log10(x), build(x).log10());
+// }
+// }
+
+ @Test
+ public void testAbs() {
+ for (double x = -0.9; x < 0.9; x += 0.05) {
+ checkRelative(AccurateMath.abs(x), build(x).abs());
+ }
+ }
+
+ @Test
+ public void testCeil() {
+ for (double x = -0.9; x < 0.9; x += 0.05) {
+ checkRelative(AccurateMath.ceil(x), build(x).ceil());
+ }
+ }
+
+ @Test
+ public void testFloor() {
+ for (double x = -0.9; x < 0.9; x += 0.05) {
+ checkRelative(AccurateMath.floor(x), build(x).floor());
+ }
+ }
+
+ @Test
+ public void testRint() {
+ for (double x = -0.9; x < 0.9; x += 0.05) {
+ checkRelative(AccurateMath.rint(x), build(x).rint());
+ }
+ }
+
+ @Test
+ public void testRound() {
+ for (double x = -0.9; x < 0.9; x += 0.05) {
+ Assert.assertEquals(AccurateMath.round(x), build(x).round());
+ }
+ }
+
+ @Test
+ public void testSignum() {
+ for (double x = -0.9; x < 0.9; x += 0.05) {
+ checkRelative(AccurateMath.signum(x), build(x).signum());
+ }
+ }
+
+ @Test
+ public void testCopySignField() {
+ for (double x = -3; x < 3; x += 0.2) {
+ for (double y = -3; y < 3; y += 0.2) {
+ checkRelative(AccurateMath.copySign(x, y), build(x).copySign(build(y)));
+ }
+ }
+ }
+
+ @Test
+ public void testCopySignDouble() {
+ for (double x = -3; x < 3; x += 0.2) {
+ for (double y = -3; y < 3; y += 0.2) {
+ checkRelative(AccurateMath.copySign(x, y), build(x).copySign(y));
+ }
+ }
+ }
+
+ @Test
+ public void testScalb() {
+ for (double x = -0.9; x < 0.9; x += 0.05) {
+ for (int n = -100; n < 100; ++n) {
+ checkRelative(AccurateMath.scalb(x, n), build(x).scalb(n));
+ }
+ }
+ }
+
+ @Test
+ public void testLinearCombinationFaFa() {
+ UniformRandomProvider r = RandomSource.create(RandomSource.WELL_1024_A, 0xfafal);
+ for (int i = 0; i < 50; ++i) {
+ double[] aD = generateDouble(r, 10);
+ double[] bD = generateDouble(r, 10);
+ T[] aF = toFieldArray(aD);
+ T[] bF = toFieldArray(bD);
+ checkRelative(LinearCombination.value(aD, bD),
+ aF[0].linearCombination(aF, bF));
+ }
+ }
+
+ @Test
+ public void testLinearCombinationDaFa() {
+ UniformRandomProvider r = RandomSource.create(RandomSource.WELL_1024_A, 0xdafal);
+ for (int i = 0; i < 50; ++i) {
+ double[] aD = generateDouble(r, 10);
+ double[] bD = generateDouble(r, 10);
+ T[] bF = toFieldArray(bD);
+ checkRelative(LinearCombination.value(aD, bD),
+ bF[0].linearCombination(aD, bF));
+ }
+ }
+
+ @Test
+ public void testLinearCombinationFF2() {
+ UniformRandomProvider r = RandomSource.create(RandomSource.WELL_1024_A, 0xff2l);
+ for (int i = 0; i < 50; ++i) {
+ double[] aD = generateDouble(r, 2);
+ double[] bD = generateDouble(r, 2);
+ T[] aF = toFieldArray(aD);
+ T[] bF = toFieldArray(bD);
+ checkRelative(LinearCombination.value(aD[0], bD[0], aD[1], bD[1]),
+ aF[0].linearCombination(aF[0], bF[0], aF[1], bF[1]));
+ }
+ }
+
+ @Test
+ public void testLinearCombinationDF2() {
+ UniformRandomProvider r = RandomSource.create(RandomSource.WELL_1024_A, 0xdf2l);
+ for (int i = 0; i < 50; ++i) {
+ double[] aD = generateDouble(r, 2);
+ double[] bD = generateDouble(r, 2);
+ T[] bF = toFieldArray(bD);
+ checkRelative(LinearCombination.value(aD[0], bD[0], aD[1], bD[1]),
+ bF[0].linearCombination(aD[0], bF[0], aD[1], bF[1]));
+ }
+ }
+
+ @Test
+ public void testLinearCombinationFF3() {
+ UniformRandomProvider r = RandomSource.create(RandomSource.WELL_1024_A, 0xff3l);
+ for (int i = 0; i < 50; ++i) {
+ double[] aD = generateDouble(r, 3);
+ double[] bD = generateDouble(r, 3);
+ T[] aF = toFieldArray(aD);
+ T[] bF = toFieldArray(bD);
+ checkRelative(LinearCombination.value(aD[0], bD[0], aD[1], bD[1], aD[2], bD[2]),
+ aF[0].linearCombination(aF[0], bF[0], aF[1], bF[1], aF[2], bF[2]));
+ }
+ }
+
+ @Test
+ public void testLinearCombinationDF3() {
+ UniformRandomProvider r = RandomSource.create(RandomSource.WELL_1024_A, 0xdf3l);
+ for (int i = 0; i < 50; ++i) {
+ double[] aD = generateDouble(r, 3);
+ double[] bD = generateDouble(r, 3);
+ T[] bF = toFieldArray(bD);
+ checkRelative(LinearCombination.value(aD[0], bD[0], aD[1], bD[1], aD[2], bD[2]),
+ bF[0].linearCombination(aD[0], bF[0], aD[1], bF[1], aD[2], bF[2]));
+ }
+ }
+
+ @Test
+ public void testLinearCombinationFF4() {
+ UniformRandomProvider r = RandomSource.create(RandomSource.WELL_1024_A, 0xff4l);
+ for (int i = 0; i < 50; ++i) {
+ double[] aD = generateDouble(r, 4);
+ double[] bD = generateDouble(r, 4);
+ T[] aF = toFieldArray(aD);
+ T[] bF = toFieldArray(bD);
+ checkRelative(LinearCombination.value(aD[0], bD[0], aD[1], bD[1], aD[2], bD[2], aD[3], bD[3]),
+ aF[0].linearCombination(aF[0], bF[0], aF[1], bF[1], aF[2], bF[2], aF[3], bF[3]));
+ }
+ }
+
+ @Test
+ public void testLinearCombinationDF4() {
+ UniformRandomProvider r = RandomSource.create(RandomSource.WELL_1024_A, 0xdf4l);
+ for (int i = 0; i < 50; ++i) {
+ double[] aD = generateDouble(r, 4);
+ double[] bD = generateDouble(r, 4);
+ T[] bF = toFieldArray(bD);
+ checkRelative(LinearCombination.value(aD[0], bD[0], aD[1], bD[1], aD[2], bD[2], aD[3], bD[3]),
+ bF[0].linearCombination(aD[0], bF[0], aD[1], bF[1], aD[2], bF[2], aD[3], bF[3]));
+ }
+ }
+
+ @Test
+ public void testGetField() {
+ checkRelative(1.0, build(-10).getField().getOne());
+ checkRelative(0.0, build(-10).getField().getZero());
+ }
+
+ private void checkRelative(double expected, T obtained) {
+ Assert.assertEquals(expected, obtained.getReal(), 1.0e-15 * (1 + AccurateMath.abs(expected)));
+ }
+
+ @Test
+ public void testEquals() {
+ T t1a = build(1.0);
+ T t1b = build(1.0);
+ T t2 = build(2.0);
+ Assert.assertTrue(t1a.equals(t1a));
+ Assert.assertTrue(t1a.equals(t1b));
+ Assert.assertFalse(t1a.equals(t2));
+ Assert.assertFalse(t1a.equals(new Object()));
+ }
+
+ @Test
+ public void testHash() {
+ T t1a = build(1.0);
+ T t1b = build(1.0);
+ T t2 = build(2.0);
+ Assert.assertEquals(t1a.hashCode(), t1b.hashCode());
+ Assert.assertTrue(t1a.hashCode() != t2.hashCode());
+ }
+
+ private double[] generateDouble (final UniformRandomProvider r, int n) {
+ double[] a = new double[n];
+ for (int i = 0; i < n; ++i) {
+ a[i] = r.nextDouble();
+ }
+ return a;
+ }
+
+ private T[] toFieldArray (double[] a) {
+ T[] f = MathArrays.buildArray(build(0).getField(), a.length);
+ for (int i = 0; i < a.length; ++i) {
+ f[i] = build(a[i]);
+ }
+ return f;
+ }
+
+}
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/filter/KalmanFilterTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/filter/KalmanFilterTest.java
index d985b392c..b21e7fcd3 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/filter/KalmanFilterTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/filter/KalmanFilterTest.java
@@ -23,7 +23,7 @@ import org.apache.commons.math4.legacy.linear.MatrixUtils;
import org.apache.commons.math4.legacy.linear.RealMatrix;
import org.apache.commons.math4.legacy.linear.RealVector;
import org.apache.commons.rng.simple.RandomSource;
-import org.apache.commons.math4.legacy.util.FastMath;
+import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
import org.apache.commons.numbers.core.Precision;
import org.junit.Assert;
import org.junit.Test;
@@ -142,7 +142,7 @@ public class KalmanFilterTest {
filter.correct(z);
// state estimate shouldn't be larger than measurement noise
- double diff = FastMath.abs(constantValue - filter.getStateEstimation()[0]);
+ double diff = AccurateMath.abs(constantValue - filter.getStateEstimation()[0]);
// System.out.println(diff);
Assert.assertTrue(Precision.compareTo(diff, measurementNoise, 1e-6) < 0);
}
@@ -170,7 +170,7 @@ public class KalmanFilterTest {
// B = [ dt^2/2 ]
// [ dt ]
RealMatrix B = new Array2DRowRealMatrix(
- new double[][] { { FastMath.pow(dt, 2d) / 2d }, { dt } });
+ new double[][] { { AccurateMath.pow(dt, 2d) / 2d }, { dt } });
// H = [ 1 0 ]
RealMatrix H = new Array2DRowRealMatrix(new double[][] { { 1d, 0d } });
@@ -179,12 +179,12 @@ public class KalmanFilterTest {
RealVector x = new ArrayRealVector(new double[] { 0, 0 });
RealMatrix tmp = new Array2DRowRealMatrix(
- new double[][] { { FastMath.pow(dt, 4d) / 4d, FastMath.pow(dt, 3d) / 2d },
- { FastMath.pow(dt, 3d) / 2d, FastMath.pow(dt, 2d) } });
+ new double[][] { { AccurateMath.pow(dt, 4d) / 4d, AccurateMath.pow(dt, 3d) / 2d },
+ { AccurateMath.pow(dt, 3d) / 2d, AccurateMath.pow(dt, 2d) } });
// Q = [ dt^4/4 dt^3/2 ]
// [ dt^3/2 dt^2 ]
- RealMatrix Q = tmp.scalarMultiply(FastMath.pow(accelNoise, 2));
+ RealMatrix Q = tmp.scalarMultiply(AccurateMath.pow(accelNoise, 2));
// P0 = [ 1 1 ]
// [ 1 1 ]
@@ -192,7 +192,7 @@ public class KalmanFilterTest {
// R = [ measurementNoise^2 ]
RealMatrix R = new Array2DRowRealMatrix(
- new double[] { FastMath.pow(measurementNoise, 2) });
+ new double[] { AccurateMath.pow(measurementNoise, 2) });
// constant control input, increase velocity by 0.1 m/s per cycle
RealVector u = new ArrayRealVector(new double[] { 0.1d });
@@ -213,7 +213,7 @@ public class KalmanFilterTest {
final ContinuousDistribution.Sampler rand = new NormalDistribution(0, 1).createSampler(RandomSource.create(RandomSource.WELL_19937_C));
RealVector tmpPNoise = new ArrayRealVector(
- new double[] { FastMath.pow(dt, 2d) / 2d, dt });
+ new double[] { AccurateMath.pow(dt, 2d) / 2d, dt });
// iterate 60 steps
for (int i = 0; i < 60; i++) {
@@ -234,7 +234,7 @@ public class KalmanFilterTest {
filter.correct(z);
// state estimate shouldn't be larger than the measurement noise
- double diff = FastMath.abs(x.getEntry(0) - filter.getStateEstimation()[0]);
+ double diff = AccurateMath.abs(x.getEntry(0) - filter.getStateEstimation()[0]);
Assert.assertTrue(Precision.compareTo(diff, measurementNoise, 1e-6) < 0);
}
@@ -258,10 +258,10 @@ public class KalmanFilterTest {
public Cannonball(double timeslice, double angle, double initialVelocity) {
this.timeslice = timeslice;
- final double angleInRadians = FastMath.toRadians(angle);
+ final double angleInRadians = AccurateMath.toRadians(angle);
this.velocity = new double[] {
- initialVelocity * FastMath.cos(angleInRadians),
- initialVelocity * FastMath.sin(angleInRadians)
+ initialVelocity * AccurateMath.cos(angleInRadians),
+ initialVelocity * AccurateMath.sin(angleInRadians)
};
this.location = new double[] { 0, 0 };
@@ -405,7 +405,7 @@ public class KalmanFilterTest {
filter.correct(new double[] { nx, 0, ny, 0 } );
// state estimate shouldn't be larger than the measurement noise
- double diff = FastMath.abs(cannonball.getY() - filter.getStateEstimation()[2]);
+ double diff = AccurateMath.abs(cannonball.getY() - filter.getStateEstimation()[2]);
Assert.assertTrue(Precision.compareTo(diff, measurementNoise, 1e-6) < 0);
}
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/fitting/HarmonicCurveFitterTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/fitting/HarmonicCurveFitterTest.java
index 05c3f8251..99b80da48 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/fitting/HarmonicCurveFitterTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/fitting/HarmonicCurveFitterTest.java
@@ -24,7 +24,7 @@ import org.apache.commons.numbers.angle.PlaneAngleRadians;
import org.apache.commons.math4.legacy.analysis.function.HarmonicOscillator;
import org.apache.commons.math4.legacy.exception.MathIllegalStateException;
import org.apache.commons.math4.legacy.exception.NumberIsTooSmallException;
-import org.apache.commons.math4.legacy.util.FastMath;
+import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
import org.junit.Assert;
import org.junit.Test;
@@ -57,7 +57,7 @@ public class HarmonicCurveFitterTest {
final HarmonicOscillator ff = new HarmonicOscillator(fitted[0], fitted[1], fitted[2]);
for (double x = -1.0; x < 1.0; x += 0.01) {
- Assert.assertTrue(FastMath.abs(f.value(x) - ff.value(x)) < 1e-13);
+ Assert.assertTrue(AccurateMath.abs(f.value(x) - ff.value(x)) < 1e-13);
}
}
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/fitting/PolynomialCurveFitterTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/fitting/PolynomialCurveFitterTest.java
index c540e248e..da359a251 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/fitting/PolynomialCurveFitterTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/fitting/PolynomialCurveFitterTest.java
@@ -23,7 +23,7 @@ import org.apache.commons.math4.legacy.analysis.polynomials.PolynomialFunction;
import org.apache.commons.statistics.distribution.ContinuousDistribution;
import org.apache.commons.statistics.distribution.UniformContinuousDistribution;
import org.apache.commons.math4.legacy.exception.ConvergenceException;
-import org.apache.commons.math4.legacy.util.FastMath;
+import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
import org.apache.commons.rng.simple.RandomSource;
import org.junit.Assert;
import org.junit.Test;
@@ -70,8 +70,8 @@ public class PolynomialCurveFitterTest {
final PolynomialFunction fitted = new PolynomialFunction(fitter.fit(obs.toList()));
for (double x = -1.0; x < 1.0; x += 0.01) {
- final double error = FastMath.abs(p.value(x) - fitted.value(x)) /
- (1.0 + FastMath.abs(p.value(x)));
+ final double error = AccurateMath.abs(p.value(x) - fitted.value(x)) /
+ (1.0 + AccurateMath.abs(p.value(x)));
Assert.assertEquals(0.0, error, 1.0e-6);
}
}
@@ -93,10 +93,10 @@ public class PolynomialCurveFitterTest {
final PolynomialFunction fitted = new PolynomialFunction(fitter.fit(obs.toList()));
for (double x = -1.0; x < 1.0; x += 0.01) {
- final double error = FastMath.abs(p.value(x) - fitted.value(x)) /
- (1.0 + FastMath.abs(p.value(x)));
- maxError = FastMath.max(maxError, error);
- Assert.assertTrue(FastMath.abs(error) < 0.1);
+ final double error = AccurateMath.abs(p.value(x) - fitted.value(x)) /
+ (1.0 + AccurateMath.abs(p.value(x)));
+ maxError = AccurateMath.max(maxError, error);
+ Assert.assertTrue(AccurateMath.abs(error) < 0.1);
}
}
Assert.assertTrue(maxError > 0.01);
@@ -124,10 +124,10 @@ public class PolynomialCurveFitterTest {
final PolynomialFunction fitted = new PolynomialFunction(fitter.fit(obs.toList()));
for (double x = -1.0; x < 1.0; x += 0.01) {
- final double error = FastMath.abs(p.value(x) - fitted.value(x)) /
- (1.0 + FastMath.abs(p.value(x)));
- maxError = FastMath.max(maxError, error);
- Assert.assertTrue(FastMath.abs(error) < 0.01);
+ final double error = AccurateMath.abs(p.value(x) - fitted.value(x)) /
+ (1.0 + AccurateMath.abs(p.value(x)));
+ maxError = AccurateMath.max(maxError, error);
+ Assert.assertTrue(AccurateMath.abs(error) < 0.01);
}
}
Assert.assertTrue(maxError > 0.001);
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/fitting/leastsquares/AbstractLeastSquaresOptimizerAbstractTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/fitting/leastsquares/AbstractLeastSquaresOptimizerAbstractTest.java
index 3648acd11..a5a858020 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/fitting/leastsquares/AbstractLeastSquaresOptimizerAbstractTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/fitting/leastsquares/AbstractLeastSquaresOptimizerAbstractTest.java
@@ -31,7 +31,7 @@ import org.apache.commons.math4.legacy.linear.RealMatrix;
import org.apache.commons.math4.legacy.linear.RealVector;
import org.apache.commons.math4.legacy.optim.ConvergenceChecker;
import org.apache.commons.math4.legacy.optim.SimpleVectorValueChecker;
-import org.apache.commons.math4.legacy.util.FastMath;
+import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
import org.apache.commons.math4.legacy.util.Pair;
import org.junit.Assert;
import org.junit.Test;
@@ -132,12 +132,12 @@ public abstract class AbstractLeastSquaresOptimizerAbstractTest {
return new Pair(
new ArrayRealVector(
new double[]{
- FastMath.pow(point.getEntry(0), 4)
+ AccurateMath.pow(point.getEntry(0), 4)
},
false),
new Array2DRowRealMatrix(
new double[][]{
- {0.25 * FastMath.pow(point.getEntry(0), 3)}
+ {0.25 * AccurateMath.pow(point.getEntry(0), 3)}
},
false)
);
@@ -406,7 +406,7 @@ public abstract class AbstractLeastSquaresOptimizerAbstractTest {
Assert.assertTrue(optimum.getEvaluations() < 10);
double rms = optimum.getRMS();
- Assert.assertEquals(1.768262623567235, FastMath.sqrt(circle.getN()) * rms, TOl);
+ Assert.assertEquals(1.768262623567235, AccurateMath.sqrt(circle.getN()) * rms, TOl);
Vector2D center = Vector2D.of(optimum.getPoint().getEntry(0), optimum.getPoint().getEntry(1));
Assert.assertEquals(69.96016176931406, circle.getRadius(center), 1e-6);
@@ -421,8 +421,8 @@ public abstract class AbstractLeastSquaresOptimizerAbstractTest {
// add perfect measurements and check formal errors are reduced
double r = circle.getRadius(center);
- for (double d = 0; d < 2 * FastMath.PI; d += 0.01) {
- circle.addPoint(center.getX() + r * FastMath.cos(d), center.getY() + r * FastMath.sin(d));
+ for (double d = 0; d < 2 * AccurateMath.PI; d += 0.01) {
+ circle.addPoint(center.getX() + r * AccurateMath.cos(d), center.getY() + r * AccurateMath.sin(d));
}
double[] weights = new double[circle.getN()];
@@ -519,7 +519,7 @@ public abstract class AbstractLeastSquaresOptimizerAbstractTest {
final RealVector actual = optimum.getPoint();
for (int i = 0; i < actual.getDimension(); i++) {
double expected = dataset.getParameter(i);
- double delta = FastMath.abs(errParams * expected);
+ double delta = AccurateMath.abs(errParams * expected);
Assert.assertEquals(dataset.getName() + ", param #" + i,
expected, actual.getEntry(i), delta);
}
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/fitting/leastsquares/BevingtonProblem.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/fitting/leastsquares/BevingtonProblem.java
index 62c052c29..202a66475 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/fitting/leastsquares/BevingtonProblem.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/fitting/leastsquares/BevingtonProblem.java
@@ -18,7 +18,7 @@ package org.apache.commons.math4.legacy.fitting.leastsquares;
import org.apache.commons.math4.legacy.analysis.MultivariateMatrixFunction;
import org.apache.commons.math4.legacy.analysis.MultivariateVectorFunction;
-import org.apache.commons.math4.legacy.util.FastMath;
+import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
import java.util.ArrayList;
import java.util.List;
@@ -45,8 +45,8 @@ class BevingtonProblem {
for (int i = 0; i < values.length; ++i) {
final double t = time.get(i);
values[i] = params[0] +
- params[1] * FastMath.exp(-t / params[3]) +
- params[2] * FastMath.exp(-t / params[4]);
+ params[1] * AccurateMath.exp(-t / params[3]) +
+ params[2] * AccurateMath.exp(-t / params[4]);
}
return values;
}
@@ -67,10 +67,10 @@ class BevingtonProblem {
final double p4 = params[4];
final double tOp3 = t / p3;
final double tOp4 = t / p4;
- jacobian[i][1] = FastMath.exp(-tOp3);
- jacobian[i][2] = FastMath.exp(-tOp4);
- jacobian[i][3] = params[1] * FastMath.exp(-tOp3) * tOp3 / p3;
- jacobian[i][4] = params[2] * FastMath.exp(-tOp4) * tOp4 / p4;
+ jacobian[i][1] = AccurateMath.exp(-tOp3);
+ jacobian[i][2] = AccurateMath.exp(-tOp4);
+ jacobian[i][3] = params[1] * AccurateMath.exp(-tOp3) * tOp3 / p3;
+ jacobian[i][4] = params[2] * AccurateMath.exp(-tOp4) * tOp4 / p4;
}
return jacobian;
}
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/fitting/leastsquares/CircleProblem.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/fitting/leastsquares/CircleProblem.java
index 3d9d4d696..d18672eff 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/fitting/leastsquares/CircleProblem.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/fitting/leastsquares/CircleProblem.java
@@ -20,7 +20,7 @@ import java.util.ArrayList;
import org.apache.commons.math4.legacy.analysis.MultivariateMatrixFunction;
import org.apache.commons.math4.legacy.analysis.MultivariateVectorFunction;
-import org.apache.commons.math4.legacy.util.FastMath;
+import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
import org.apache.commons.numbers.angle.PlaneAngleRadians;
/**
@@ -125,8 +125,8 @@ class CircleProblem {
// current point (using a resolution of 100 points along the
// circumference).
for (double theta = 0; theta <= PlaneAngleRadians.TWO_PI; theta += deltaTheta) {
- final double currentX = cx + r * FastMath.cos(theta);
- final double currentY = cy + r * FastMath.sin(theta);
+ final double currentX = cx + r * AccurateMath.cos(theta);
+ final double currentY = cy + r * AccurateMath.sin(theta);
final double dX = currentX - px;
final double dY = currentY - py;
final double d = dX * dX + dY * dY;
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/fitting/leastsquares/DifferentiatorVectorMultivariateJacobianFunctionTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/fitting/leastsquares/DifferentiatorVectorMultivariateJacobianFunctionTest.java
index c0811fef2..d309d4532 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/fitting/leastsquares/DifferentiatorVectorMultivariateJacobianFunctionTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/fitting/leastsquares/DifferentiatorVectorMultivariateJacobianFunctionTest.java
@@ -22,7 +22,7 @@ import org.apache.commons.math4.legacy.linear.DiagonalMatrix;
import org.apache.commons.math4.legacy.linear.RealMatrix;
import org.apache.commons.math4.legacy.linear.RealVector;
import org.apache.commons.math4.legacy.optim.SimpleVectorValueChecker;
-import org.apache.commons.math4.legacy.util.FastMath;
+import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
import org.junit.Assert;
import org.junit.Test;
@@ -81,7 +81,7 @@ public class DifferentiatorVectorMultivariateJacobianFunctionTest {
// Check that the automatic solution is within the reference error range.
for (int i = 0; i < numParams; i++) {
- final double error = FastMath.sqrt(analyticalCovarianceMatrix.getEntry(i, i));
+ final double error = AccurateMath.sqrt(analyticalCovarianceMatrix.getEntry(i, i));
Assert.assertEquals("Parameter " + i, analyticalSolution.getEntry(i), automaticSolution.getEntry(i), error);
}
@@ -92,7 +92,7 @@ public class DifferentiatorVectorMultivariateJacobianFunctionTest {
Assert.assertEquals("Covariance matrix [" + i + "][" + j + "]",
analyticalCovarianceMatrix.getEntry(i, j),
automaticCovarianceMatrix.getEntry(i, j),
- FastMath.abs(0.01 * analyticalCovarianceMatrix.getEntry(i, j)));
+ AccurateMath.abs(0.01 * analyticalCovarianceMatrix.getEntry(i, j)));
}
}
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/fitting/leastsquares/EvaluationTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/fitting/leastsquares/EvaluationTest.java
index efc64c9ee..7ba0218c5 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/fitting/leastsquares/EvaluationTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/fitting/leastsquares/EvaluationTest.java
@@ -24,7 +24,7 @@ import org.apache.commons.math4.legacy.linear.MatrixUtils;
import org.apache.commons.math4.legacy.linear.RealMatrix;
import org.apache.commons.math4.legacy.linear.RealVector;
import org.apache.commons.math4.legacy.linear.SingularMatrixException;
-import org.apache.commons.math4.legacy.util.FastMath;
+import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
import org.apache.commons.math4.legacy.util.Pair;
import org.apache.commons.numbers.core.Precision;
import org.junit.Assert;
@@ -109,14 +109,14 @@ public class EvaluationTest {
//action
TestUtils.assertEquals(
"covariance",
- evaluation.getCovariances(FastMath.nextAfter(1e-4, 0.0)),
+ evaluation.getCovariances(AccurateMath.nextAfter(1e-4, 0.0)),
MatrixUtils.createRealMatrix(new double[][]{{1, 0}, {0, 1e4}}),
Precision.EPSILON
);
//singularity fail
try {
- evaluation.getCovariances(FastMath.nextAfter(1e-4, 1.0));
+ evaluation.getCovariances(AccurateMath.nextAfter(1e-4, 1.0));
Assert.fail("Expected Exception");
} catch (SingularMatrixException e) {
//expected
@@ -180,7 +180,7 @@ public class EvaluationTest {
final LeastSquaresProblem lsp = builder(dataset).build();
- final double expected = FastMath.sqrt(dataset.getResidualSumOfSquares() /
+ final double expected = AccurateMath.sqrt(dataset.getResidualSumOfSquares() /
dataset.getNumObservations());
final double actual = lsp.evaluate(lsp.getStart()).getRMS();
Assert.assertEquals(dataset.getName(), expected, actual, 1e-11 * expected);
@@ -200,7 +200,7 @@ public class EvaluationTest {
final RealVector sig = evaluation.getSigma(1e-14);
final int dof = lsp.getObservationSize() - lsp.getParameterSize();
for (int i = 0; i < sig.getDimension(); i++) {
- final double actual = FastMath.sqrt(cost * cost / dof) * sig.getEntry(i);
+ final double actual = AccurateMath.sqrt(cost * cost / dof) * sig.getEntry(i);
Assert.assertEquals(dataset.getName() + ", parameter #" + i,
expected[i], actual, 1e-6 * expected[i]);
}
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/fitting/leastsquares/EvaluationTestValidation.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/fitting/leastsquares/EvaluationTestValidation.java
index d22716b16..84e058830 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/fitting/leastsquares/EvaluationTestValidation.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/fitting/leastsquares/EvaluationTestValidation.java
@@ -18,7 +18,7 @@ import org.apache.commons.math4.legacy.linear.DiagonalMatrix;
import org.apache.commons.math4.legacy.linear.RealVector;
import org.apache.commons.math4.legacy.stat.descriptive.StatisticalSummary;
import org.apache.commons.math4.legacy.stat.descriptive.SummaryStatistics;
-import org.apache.commons.math4.legacy.util.FastMath;
+import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
import org.junit.Assert;
import org.junit.Test;
@@ -224,7 +224,7 @@ public class EvaluationTestValidation {
// Monte-Carlo (generates a grid of parameters).
final int mcRepeat = MONTE_CARLO_RUNS;
- final int gridSize = (int) FastMath.sqrt(mcRepeat);
+ final int gridSize = (int) AccurateMath.sqrt(mcRepeat);
// Parameters found for each of Monte-Carlo run.
// Index 0 = slope
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/fitting/leastsquares/GaussNewtonOptimizerWithSVDTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/fitting/leastsquares/GaussNewtonOptimizerWithSVDTest.java
index 771d0b60a..87d0ee796 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/fitting/leastsquares/GaussNewtonOptimizerWithSVDTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/fitting/leastsquares/GaussNewtonOptimizerWithSVDTest.java
@@ -26,7 +26,7 @@ import org.apache.commons.math4.legacy.exception.TooManyEvaluationsException;
import org.apache.commons.math4.legacy.fitting.leastsquares.GaussNewtonOptimizer.Decomposition;
import org.apache.commons.math4.legacy.fitting.leastsquares.LeastSquaresOptimizer.Optimum;
import org.apache.commons.math4.legacy.optim.SimpleVectorValueChecker;
-import org.apache.commons.math4.legacy.util.FastMath;
+import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
import org.junit.Assert;
import org.junit.Test;
@@ -141,7 +141,7 @@ public class GaussNewtonOptimizerWithSVDTest
Plane span = Planes.fromPoints(Vector3D.ZERO, Vector3D.of(1, 2, -3), Vector3D.of(2, 1, 0),
new EpsilonDoublePrecisionContext(TOl));
- double expected = FastMath.abs(span.offset(Vector3D.of(1, 1, 1)));
+ double expected = AccurateMath.abs(span.offset(Vector3D.of(1, 1, 1)));
double actual = optimum.getResiduals().getNorm();
//verify
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/fitting/leastsquares/LevenbergMarquardtOptimizerTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/fitting/leastsquares/LevenbergMarquardtOptimizerTest.java
index 5f6b2e32a..cf610c3a1 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/fitting/leastsquares/LevenbergMarquardtOptimizerTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/fitting/leastsquares/LevenbergMarquardtOptimizerTest.java
@@ -27,7 +27,7 @@ import org.apache.commons.math4.legacy.linear.RealMatrix;
import org.apache.commons.math4.legacy.linear.RealVector;
import org.apache.commons.math4.legacy.linear.SingularMatrixException;
import org.apache.commons.math4.legacy.optim.ConvergenceChecker;
-import org.apache.commons.math4.legacy.util.FastMath;
+import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
import org.apache.commons.numbers.core.Precision;
import org.junit.Assert;
import org.junit.Test;
@@ -85,7 +85,7 @@ public class LevenbergMarquardtOptimizerTest
problem.getBuilder().maxIterations(20).build());
//TODO check that it is a bad fit? Why the extra conditions?
- Assert.assertTrue(FastMath.sqrt(problem.getTarget().length) * optimum.getRMS() > 0.6);
+ Assert.assertTrue(AccurateMath.sqrt(problem.getTarget().length) * optimum.getRMS() > 0.6);
optimum.getCovariances(1.5e-14);
@@ -209,7 +209,7 @@ public class LevenbergMarquardtOptimizerTest
// Check that the computed solution is within the reference error range.
for (int i = 0; i < numParams; i++) {
- final double error = FastMath.sqrt(expectedCovarMatrix[i][i]);
+ final double error = AccurateMath.sqrt(expectedCovarMatrix[i][i]);
Assert.assertEquals("Parameter " + i, expectedSolution[i], solution.getEntry(i), error);
}
@@ -220,7 +220,7 @@ public class LevenbergMarquardtOptimizerTest
Assert.assertEquals("Covariance matrix [" + i + "][" + j + "]",
expectedCovarMatrix[i][j],
covarMatrix.getEntry(i, j),
- FastMath.abs(0.1 * expectedCovarMatrix[i][j]));
+ AccurateMath.abs(0.1 * expectedCovarMatrix[i][j]));
}
}
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/fitting/leastsquares/MinpackTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/fitting/leastsquares/MinpackTest.java
index 540bbd887..7d748aa9a 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/fitting/leastsquares/MinpackTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/fitting/leastsquares/MinpackTest.java
@@ -24,7 +24,7 @@ import org.apache.commons.math4.legacy.analysis.MultivariateVectorFunction;
import org.apache.commons.math4.legacy.exception.TooManyEvaluationsException;
import org.apache.commons.math4.legacy.fitting.leastsquares.LeastSquaresOptimizer.Optimum;
import org.apache.commons.math4.legacy.linear.DiagonalMatrix;
-import org.apache.commons.math4.legacy.util.FastMath;
+import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
import org.junit.Assert;
import org.junit.Test;
@@ -117,11 +117,11 @@ public class MinpackTest {
@Test
public void testMinpackRosenbrok() {
minpackTest(new RosenbrockFunction(new double[] { -1.2, 1.0 },
- FastMath.sqrt(24.2)), false);
+ AccurateMath.sqrt(24.2)), false);
minpackTest(new RosenbrockFunction(new double[] { -12.0, 10.0 },
- FastMath.sqrt(1795769.0)), false);
+ AccurateMath.sqrt(1795769.0)), false);
minpackTest(new RosenbrockFunction(new double[] { -120.0, 100.0 },
- 11.0 * FastMath.sqrt(169000121.0)), false);
+ 11.0 * AccurateMath.sqrt(169000121.0)), false);
}
@Test
@@ -498,7 +498,7 @@ public class MinpackTest {
private void minpackTest(MinpackFunction function, boolean exceptionExpected) {
final double tol = 2.22044604926e-16;
- final double sqrtTol = FastMath.sqrt(tol);
+ final double sqrtTol = AccurateMath.sqrt(tol);
LevenbergMarquardtOptimizer optimizer = new LevenbergMarquardtOptimizer()
.withCostRelativeTolerance(sqrtTol)
@@ -577,7 +577,7 @@ public class MinpackTest {
public void checkTheoreticalMinCost(double rms) {
double threshold = costAccuracy * (1.0 + theoreticalMinCost);
- Assert.assertEquals(theoreticalMinCost, FastMath.sqrt(m) * rms, threshold);
+ Assert.assertEquals(theoreticalMinCost, AccurateMath.sqrt(m) * rms, threshold);
}
public void checkTheoreticalMinParams(double[] params) {
@@ -585,7 +585,7 @@ public class MinpackTest {
for (int i = 0; i < theoreticalMinParams.length; ++i) {
double mi = theoreticalMinParams[i];
double vi = params[i];
- Assert.assertEquals(mi, vi, paramsAccuracy * (1.0 + FastMath.abs(mi)));
+ Assert.assertEquals(mi, vi, paramsAccuracy * (1.0 + AccurateMath.abs(mi)));
}
}
}
@@ -688,7 +688,7 @@ public class MinpackTest {
public LinearRank1ZeroColsAndRowsFunction(int m, int n, double x0) {
super(m, buildArray(n, x0),
- FastMath.sqrt((m * (m + 3) - 6) / (2.0 * (2 * m - 3))),
+ AccurateMath.sqrt((m * (m + 3) - 6) / (2.0 * (2 * m - 3))),
null);
}
@@ -758,7 +758,7 @@ public class MinpackTest {
double x2 = variables[1];
double tmpSquare = x1 * x1 + x2 * x2;
double tmp1 = twoPi * tmpSquare;
- double tmp2 = FastMath.sqrt(tmpSquare);
+ double tmp2 = AccurateMath.sqrt(tmpSquare);
return new double[][] {
{ 100 * x2 / tmp1, -100 * x1 / tmp1, 10 },
{ 10 * x1 / tmp2, 10 * x2 / tmp2, 0 },
@@ -775,12 +775,12 @@ public class MinpackTest {
if (x1 == 0) {
tmp1 = (x2 >= 0) ? 0.25 : -0.25;
} else {
- tmp1 = FastMath.atan(x2 / x1) / twoPi;
+ tmp1 = AccurateMath.atan(x2 / x1) / twoPi;
if (x1 < 0) {
tmp1 += 0.5;
}
}
- double tmp2 = FastMath.sqrt(x1 * x1 + x2 * x2);
+ double tmp2 = AccurateMath.sqrt(x1 * x1 + x2 * x2);
return new double[] {
10.0 * (x3 - 10 * tmp1),
10.0 * (tmp2 - 1),
@@ -788,7 +788,7 @@ public class MinpackTest {
};
}
- private static final double twoPi = 2.0 * FastMath.PI;
+ private static final double twoPi = 2.0 * AccurateMath.PI;
}
private static class PowellSingularFunction extends MinpackFunction {
@@ -826,8 +826,8 @@ public class MinpackTest {
};
}
- private static final double sqrt5 = FastMath.sqrt( 5.0);
- private static final double sqrt10 = FastMath.sqrt(10.0);
+ private static final double sqrt5 = AccurateMath.sqrt( 5.0);
+ private static final double sqrt10 = AccurateMath.sqrt(10.0);
}
private static class FreudensteinRothFunction extends MinpackFunction {
@@ -986,7 +986,7 @@ public class MinpackTest {
for (int i = 0; i < m; ++i) {
double temp = 5.0 * (i + 1) + 45.0 + x3;
double tmp1 = x2 / temp;
- double tmp2 = FastMath.exp(tmp1);
+ double tmp2 = AccurateMath.exp(tmp1);
double tmp3 = x1 * tmp2 / temp;
jacobian[i] = new double[] { tmp2, tmp3, -tmp1 * tmp3 };
}
@@ -1000,7 +1000,7 @@ public class MinpackTest {
double x3 = variables[2];
double[] f = new double[m];
for (int i = 0; i < m; ++i) {
- f[i] = x1 * FastMath.exp(x2 / (5.0 * (i + 1) + 45.0 + x3)) - y[i];
+ f[i] = x1 * AccurateMath.exp(x2 / (5.0 * (i + 1) + 45.0 + x3)) - y[i];
}
return f;
}
@@ -1099,9 +1099,9 @@ public class MinpackTest {
for (int i = 0; i < m; ++i) {
double tmp = (i + 1) / 10.0;
jacobian[i] = new double[] {
- -tmp * FastMath.exp(-tmp * x1),
- tmp * FastMath.exp(-tmp * x2),
- FastMath.exp(-i - 1) - FastMath.exp(-tmp)
+ -tmp * AccurateMath.exp(-tmp * x1),
+ tmp * AccurateMath.exp(-tmp * x2),
+ AccurateMath.exp(-i - 1) - AccurateMath.exp(-tmp)
};
}
return jacobian;
@@ -1115,8 +1115,8 @@ public class MinpackTest {
double[] f = new double[m];
for (int i = 0; i < m; ++i) {
double tmp = (i + 1) / 10.0;
- f[i] = FastMath.exp(-tmp * x1) - FastMath.exp(-tmp * x2)
- + (FastMath.exp(-i - 1) - FastMath.exp(-tmp)) * x3;
+ f[i] = AccurateMath.exp(-tmp * x1) - AccurateMath.exp(-tmp * x2)
+ + (AccurateMath.exp(-i - 1) - AccurateMath.exp(-tmp)) * x3;
}
return f;
}
@@ -1139,7 +1139,7 @@ public class MinpackTest {
double[][] jacobian = new double[m][];
for (int i = 0; i < m; ++i) {
double t = i + 1;
- jacobian[i] = new double[] { -t * FastMath.exp(t * x1), -t * FastMath.exp(t * x2) };
+ jacobian[i] = new double[] { -t * AccurateMath.exp(t * x1), -t * AccurateMath.exp(t * x2) };
}
return jacobian;
}
@@ -1151,7 +1151,7 @@ public class MinpackTest {
double[] f = new double[m];
for (int i = 0; i < m; ++i) {
double temp = i + 1;
- f[i] = 2 + 2 * temp - FastMath.exp(temp * x1) - FastMath.exp(temp * x2);
+ f[i] = 2 + 2 * temp - AccurateMath.exp(temp * x1) - AccurateMath.exp(temp * x2);
}
return f;
}
@@ -1177,9 +1177,9 @@ public class MinpackTest {
double[][] jacobian = new double[m][];
for (int i = 0; i < m; ++i) {
double temp = (i + 1) / 5.0;
- double ti = FastMath.sin(temp);
- double tmp1 = x1 + temp * x2 - FastMath.exp(temp);
- double tmp2 = x3 + ti * x4 - FastMath.cos(temp);
+ double ti = AccurateMath.sin(temp);
+ double tmp1 = x1 + temp * x2 - AccurateMath.exp(temp);
+ double tmp2 = x3 + ti * x4 - AccurateMath.cos(temp);
jacobian[i] = new double[] {
2 * tmp1, 2 * temp * tmp1, 2 * tmp2, 2 * ti * tmp2
};
@@ -1196,8 +1196,8 @@ public class MinpackTest {
double[] f = new double[m];
for (int i = 0; i < m; ++i) {
double temp = (i + 1) / 5.0;
- double tmp1 = x1 + temp * x2 - FastMath.exp(temp);
- double tmp2 = x3 + FastMath.sin(temp) * x4 - FastMath.cos(temp);
+ double tmp1 = x1 + temp * x2 - AccurateMath.exp(temp);
+ double tmp2 = x3 + AccurateMath.sin(temp) * x4 - AccurateMath.cos(temp);
f[i] = tmp1 * tmp1 + tmp2 * tmp2;
}
return f;
@@ -1360,8 +1360,8 @@ public class MinpackTest {
double[][] jacobian = new double[m][];
for (int i = 0; i < m; ++i) {
double temp = 10.0 * i;
- double tmp1 = FastMath.exp(-temp * x4);
- double tmp2 = FastMath.exp(-temp * x5);
+ double tmp1 = AccurateMath.exp(-temp * x4);
+ double tmp2 = AccurateMath.exp(-temp * x5);
jacobian[i] = new double[] {
-1, -tmp1, -tmp2, temp * x2 * tmp1, temp * x3 * tmp2
};
@@ -1379,8 +1379,8 @@ public class MinpackTest {
double[] f = new double[m];
for (int i = 0; i < m; ++i) {
double temp = 10.0 * i;
- double tmp1 = FastMath.exp(-temp * x4);
- double tmp2 = FastMath.exp(-temp * x5);
+ double tmp1 = AccurateMath.exp(-temp * x4);
+ double tmp2 = AccurateMath.exp(-temp * x5);
f[i] = y[i] - (x1 + x2 * tmp1 + x3 * tmp2);
}
return f;
@@ -1419,10 +1419,10 @@ public class MinpackTest {
double[][] jacobian = new double[m][];
for (int i = 0; i < m; ++i) {
double temp = i / 10.0;
- double tmp1 = FastMath.exp(-x05 * temp);
- double tmp2 = FastMath.exp(-x06 * (temp - x09) * (temp - x09));
- double tmp3 = FastMath.exp(-x07 * (temp - x10) * (temp - x10));
- double tmp4 = FastMath.exp(-x08 * (temp - x11) * (temp - x11));
+ double tmp1 = AccurateMath.exp(-x05 * temp);
+ double tmp2 = AccurateMath.exp(-x06 * (temp - x09) * (temp - x09));
+ double tmp3 = AccurateMath.exp(-x07 * (temp - x10) * (temp - x10));
+ double tmp4 = AccurateMath.exp(-x08 * (temp - x11) * (temp - x11));
jacobian[i] = new double[] {
-tmp1,
-tmp2,
@@ -1456,10 +1456,10 @@ public class MinpackTest {
double[] f = new double[m];
for (int i = 0; i < m; ++i) {
double temp = i / 10.0;
- double tmp1 = FastMath.exp(-x05 * temp);
- double tmp2 = FastMath.exp(-x06 * (temp - x09) * (temp - x09));
- double tmp3 = FastMath.exp(-x07 * (temp - x10) * (temp - x10));
- double tmp4 = FastMath.exp(-x08 * (temp - x11) * (temp - x11));
+ double tmp1 = AccurateMath.exp(-x05 * temp);
+ double tmp2 = AccurateMath.exp(-x06 * (temp - x09) * (temp - x09));
+ double tmp3 = AccurateMath.exp(-x07 * (temp - x10) * (temp - x10));
+ double tmp4 = AccurateMath.exp(-x08 * (temp - x11) * (temp - x11));
f[i] = y[i] - (x01 * tmp1 + x02 * tmp2 + x03 * tmp3 + x04 * tmp4);
}
return f;
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/fitting/leastsquares/RandomCirclePointGenerator.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/fitting/leastsquares/RandomCirclePointGenerator.java
index 6fc80c965..11ea8e983 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/fitting/leastsquares/RandomCirclePointGenerator.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/fitting/leastsquares/RandomCirclePointGenerator.java
@@ -22,7 +22,7 @@ import org.apache.commons.statistics.distribution.ContinuousDistribution;
import org.apache.commons.statistics.distribution.UniformContinuousDistribution;
import org.apache.commons.rng.UniformRandomProvider;
import org.apache.commons.rng.simple.RandomSource;
-import org.apache.commons.math4.legacy.util.FastMath;
+import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
import org.apache.commons.numbers.angle.PlaneAngleRadians;
/**
@@ -79,8 +79,8 @@ public class RandomCirclePointGenerator {
*/
private Vector2D create() {
final double t = tP.sample();
- final double pX = cX.sample() + radius * FastMath.cos(t);
- final double pY = cY.sample() + radius * FastMath.sin(t);
+ final double pX = cX.sample() + radius * AccurateMath.cos(t);
+ final double pY = cY.sample() + radius * AccurateMath.sin(t);
return Vector2D.of(pX, pY);
}
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/fitting/leastsquares/StatisticalReferenceDatasetFactory.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/fitting/leastsquares/StatisticalReferenceDatasetFactory.java
index 05883139d..9388b8ca7 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/fitting/leastsquares/StatisticalReferenceDatasetFactory.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/fitting/leastsquares/StatisticalReferenceDatasetFactory.java
@@ -21,7 +21,7 @@ import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
-import org.apache.commons.math4.legacy.util.FastMath;
+import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
/**
* A factory to create instances of {@link StatisticalReferenceDataset} from
@@ -130,8 +130,8 @@ public class StatisticalReferenceDatasetFactory {
@Override
public double getModelValue(final double x, final double[] a) {
- return a[0] + a[1] * FastMath.exp(-a[3] * x) + a[2] *
- FastMath.exp(-a[4] * x);
+ return a[0] + a[1] * AccurateMath.exp(-a[3] * x) + a[2] *
+ AccurateMath.exp(-a[4] * x);
}
@Override
@@ -139,8 +139,8 @@ public class StatisticalReferenceDatasetFactory {
final double[] a) {
final double[] dy = new double[5];
dy[0] = 1.0;
- dy[1] = FastMath.exp(-x * a[3]);
- dy[2] = FastMath.exp(-x * a[4]);
+ dy[1] = AccurateMath.exp(-x * a[3]);
+ dy[2] = AccurateMath.exp(-x * a[4]);
dy[3] = -x * a[1] * dy[1];
dy[4] = -x * a[2] * dy[2];
return dy;
@@ -163,18 +163,18 @@ public class StatisticalReferenceDatasetFactory {
@Override
public double getModelValue(final double x, final double[] a) {
System.out.println(a[0]+", "+a[1]+", "+a[2]+", "+a[3]+", "+a[4]+", "+a[5]);
- return a[0] * FastMath.exp(-a[3] * x) +
- a[1] * FastMath.exp(-a[4] * x) +
- a[2] * FastMath.exp(-a[5] * x);
+ return a[0] * AccurateMath.exp(-a[3] * x) +
+ a[1] * AccurateMath.exp(-a[4] * x) +
+ a[2] * AccurateMath.exp(-a[5] * x);
}
@Override
public double[] getModelDerivatives(final double x,
final double[] a) {
final double[] dy = new double[6];
- dy[0] = FastMath.exp(-x * a[3]);
- dy[1] = FastMath.exp(-x * a[4]);
- dy[2] = FastMath.exp(-x * a[5]);
+ dy[0] = AccurateMath.exp(-x * a[3]);
+ dy[1] = AccurateMath.exp(-x * a[4]);
+ dy[2] = AccurateMath.exp(-x * a[5]);
dy[3] = -x * a[0] * dy[0];
dy[4] = -x * a[1] * dy[1];
dy[5] = -x * a[2] * dy[2];
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/genetics/FixedElapsedTimeTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/genetics/FixedElapsedTimeTest.java
index 30003c23c..635c45ce8 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/genetics/FixedElapsedTimeTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/genetics/FixedElapsedTimeTest.java
@@ -19,7 +19,7 @@ package org.apache.commons.math4.legacy.genetics;
import java.util.Iterator;
import java.util.concurrent.TimeUnit;
-import org.apache.commons.math4.legacy.util.FastMath;
+import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
import org.junit.Assert;
import org.junit.Test;
@@ -73,7 +73,7 @@ public class FixedElapsedTimeTest {
final long end = System.nanoTime();
final long elapsedTime = end - start;
- final long diff = FastMath.abs(elapsedTime - TimeUnit.SECONDS.toNanos(duration));
+ final long diff = AccurateMath.abs(elapsedTime - TimeUnit.SECONDS.toNanos(duration));
Assert.assertTrue(diff < TimeUnit.MILLISECONDS.toNanos(100));
}
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/genetics/GeneticAlgorithmTestPermutations.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/genetics/GeneticAlgorithmTestPermutations.java
index 6a864958c..2c10b919a 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/genetics/GeneticAlgorithmTestPermutations.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/genetics/GeneticAlgorithmTestPermutations.java
@@ -20,7 +20,7 @@ package org.apache.commons.math4.legacy.genetics;
import java.util.ArrayList;
import java.util.List;
-import org.apache.commons.math4.legacy.util.FastMath;
+import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
import org.junit.Assert;
import org.junit.Test;
@@ -117,7 +117,7 @@ public class GeneticAlgorithmTestPermutations {
int value = decoded.get(i);
if (value != i) {
// bad position found
- res += FastMath.abs(value - i);
+ res += AccurateMath.abs(value - i);
}
}
// the most fitted chromosome is the one with minimal error
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/linear/Array2DRowRealMatrixTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/linear/Array2DRowRealMatrixTest.java
index f9c13cb9d..d1072087e 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/linear/Array2DRowRealMatrixTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/linear/Array2DRowRealMatrixTest.java
@@ -26,7 +26,7 @@ import org.apache.commons.math4.legacy.exception.NoDataException;
import org.apache.commons.math4.legacy.exception.NullArgumentException;
import org.apache.commons.math4.legacy.exception.NumberIsTooSmallException;
import org.apache.commons.math4.legacy.exception.OutOfRangeException;
-import org.apache.commons.math4.legacy.util.FastMath;
+import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
/**
* Test cases for the {@link Array2DRowRealMatrix} class.
@@ -163,8 +163,8 @@ public final class Array2DRowRealMatrixTest {
public void testFrobeniusNorm() {
Array2DRowRealMatrix m = new Array2DRowRealMatrix(testData);
Array2DRowRealMatrix m2 = new Array2DRowRealMatrix(testData2);
- Assert.assertEquals("testData Frobenius norm", FastMath.sqrt(117.0), m.getFrobeniusNorm(), entryTolerance);
- Assert.assertEquals("testData2 Frobenius norm", FastMath.sqrt(52.0), m2.getFrobeniusNorm(), entryTolerance);
+ Assert.assertEquals("testData Frobenius norm", AccurateMath.sqrt(117.0), m.getFrobeniusNorm(), entryTolerance);
+ Assert.assertEquals("testData2 Frobenius norm", AccurateMath.sqrt(52.0), m2.getFrobeniusNorm(), entryTolerance);
}
/** test m-n = m + -n */
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/linear/ArrayFieldVectorTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/linear/ArrayFieldVectorTest.java
index 4d6319973..9f916d555 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/linear/ArrayFieldVectorTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/linear/ArrayFieldVectorTest.java
@@ -20,13 +20,13 @@ import java.io.Serializable;
import java.lang.reflect.Array;
import java.util.Arrays;
-import org.apache.commons.math4.legacy.Field;
-import org.apache.commons.math4.legacy.FieldElement;
+import org.apache.commons.math4.legacy.core.Field;
+import org.apache.commons.math4.legacy.core.FieldElement;
import org.apache.commons.math4.legacy.TestUtils;
import org.apache.commons.math4.legacy.exception.MathIllegalArgumentException;
import org.apache.commons.math4.legacy.exception.NumberIsTooSmallException;
import org.apache.commons.math4.legacy.exception.OutOfRangeException;
-import org.apache.commons.math4.legacy.dfp.Dfp;
+import org.apache.commons.math4.legacy.core.dfp.Dfp;
import org.junit.Assert;
import org.junit.Test;
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/linear/BiDiagonalTransformerTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/linear/BiDiagonalTransformerTest.java
index f0f18de98..3068f1aba 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/linear/BiDiagonalTransformerTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/linear/BiDiagonalTransformerTest.java
@@ -17,7 +17,7 @@
package org.apache.commons.math4.legacy.linear;
-import org.apache.commons.math4.legacy.util.FastMath;
+import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
import org.junit.Assert;
import org.junit.Test;
@@ -124,9 +124,9 @@ public class BiDiagonalTransformerTest {
{ 2.0, 3.0, 4.0 },
{ 3.0, 5.0, 7.0 }
}));
- final double s3 = FastMath.sqrt(3.0);
- final double s14 = FastMath.sqrt(14.0);
- final double s1553 = FastMath.sqrt(1553.0);
+ final double s3 = AccurateMath.sqrt(3.0);
+ final double s14 = AccurateMath.sqrt(14.0);
+ final double s1553 = AccurateMath.sqrt(1553.0);
RealMatrix uRef = MatrixUtils.createRealMatrix(new double[][] {
{ -1.0 / s14, 5.0 / (s3 * s14), 1.0 / s3 },
{ -2.0 / s14, -4.0 / (s3 * s14), 1.0 / s3 },
@@ -162,7 +162,7 @@ public class BiDiagonalTransformerTest {
public void testMatricesValues() {
BiDiagonalTransformer transformer =
new BiDiagonalTransformer(MatrixUtils.createRealMatrix(testSquare));
- final double s17 = FastMath.sqrt(17.0);
+ final double s17 = AccurateMath.sqrt(17.0);
RealMatrix uRef = MatrixUtils.createRealMatrix(new double[][] {
{ -8 / (5 * s17), 19 / (5 * s17) },
{ -19 / (5 * s17), -8 / (5 * s17) }
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/linear/BigRealTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/linear/BigRealTest.java
index 2b3e00a60..4fdf844df 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/linear/BigRealTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/linear/BigRealTest.java
@@ -23,7 +23,7 @@ import java.math.MathContext;
import org.apache.commons.math4.legacy.TestUtils;
import org.apache.commons.math4.legacy.exception.MathArithmeticException;
import org.apache.commons.math4.legacy.linear.BigReal;
-import org.apache.commons.math4.legacy.util.FastMath;
+import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
import org.junit.Assert;
import org.junit.Test;
@@ -126,13 +126,13 @@ public class BigRealTest {
@Test
public void testReciprocal() {
BigReal a = new BigReal("1.2345678");
- double eps = FastMath.pow(10., -a.getScale());
+ double eps = AccurateMath.pow(10., -a.getScale());
BigReal one = new BigReal("1.0000000");
BigReal b = a.reciprocal();
BigReal r = one.subtract(a.multiply(b));
- Assert.assertTrue(FastMath.abs(r.doubleValue()) <= eps);
+ Assert.assertTrue(AccurateMath.abs(r.doubleValue()) <= eps);
r = one.subtract(b.multiply(a));
- Assert.assertTrue(FastMath.abs(r.doubleValue()) <= eps);
+ Assert.assertTrue(AccurateMath.abs(r.doubleValue()) <= eps);
}
@Test(expected = MathArithmeticException.class)
@@ -182,7 +182,7 @@ public class BigRealTest {
public void testSerial() {
BigReal[] Reals = {
new BigReal(3.0), BigReal.ONE, BigReal.ZERO, new BigReal(17),
- new BigReal(FastMath.PI), new BigReal(-2.5)
+ new BigReal(AccurateMath.PI), new BigReal(-2.5)
};
for (BigReal Real : Reals) {
Assert.assertEquals(Real, TestUtils.serializeAndRecover(Real));
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/linear/BlockFieldMatrixTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/linear/BlockFieldMatrixTest.java
index 49ad0b007..c51f17911 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/linear/BlockFieldMatrixTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/linear/BlockFieldMatrixTest.java
@@ -28,7 +28,7 @@ import org.apache.commons.math4.legacy.exception.NotStrictlyPositiveException;
import org.apache.commons.math4.legacy.exception.NullArgumentException;
import org.apache.commons.math4.legacy.exception.NumberIsTooSmallException;
import org.apache.commons.math4.legacy.exception.OutOfRangeException;
-import org.apache.commons.math4.legacy.dfp.Dfp;
+import org.apache.commons.math4.legacy.core.dfp.Dfp;
/**
* Test cases for the {@link BlockFieldMatrix} class.
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/linear/BlockRealMatrixTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/linear/BlockRealMatrixTest.java
index bb3714ed9..40a1d9932 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/linear/BlockRealMatrixTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/linear/BlockRealMatrixTest.java
@@ -27,7 +27,7 @@ import org.apache.commons.math4.legacy.exception.NoDataException;
import org.apache.commons.math4.legacy.exception.NullArgumentException;
import org.apache.commons.math4.legacy.exception.NumberIsTooSmallException;
import org.apache.commons.math4.legacy.exception.OutOfRangeException;
-import org.apache.commons.math4.legacy.util.FastMath;
+import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
/**
* Test cases for the {@link BlockRealMatrix} class.
@@ -164,8 +164,8 @@ public final class BlockRealMatrixTest {
public void testFrobeniusNorm() {
BlockRealMatrix m = new BlockRealMatrix(testData);
BlockRealMatrix m2 = new BlockRealMatrix(testData2);
- Assert.assertEquals("testData Frobenius norm", FastMath.sqrt(117.0), m.getFrobeniusNorm(), entryTolerance);
- Assert.assertEquals("testData2 Frobenius norm", FastMath.sqrt(52.0), m2.getFrobeniusNorm(), entryTolerance);
+ Assert.assertEquals("testData Frobenius norm", AccurateMath.sqrt(117.0), m.getFrobeniusNorm(), entryTolerance);
+ Assert.assertEquals("testData2 Frobenius norm", AccurateMath.sqrt(52.0), m2.getFrobeniusNorm(), entryTolerance);
}
/** test m-n = m + -n */
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/linear/ConjugateGradientTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/linear/ConjugateGradientTest.java
index 8e730c3bd..5be086ea4 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/linear/ConjugateGradientTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/linear/ConjugateGradientTest.java
@@ -21,7 +21,7 @@ import java.util.Arrays;
import org.apache.commons.math4.legacy.exception.DimensionMismatchException;
import org.apache.commons.math4.legacy.exception.MathUnsupportedOperationException;
import org.apache.commons.math4.legacy.exception.MaxCountExceededException;
-import org.apache.commons.math4.legacy.util.FastMath;
+import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
import org.junit.Assert;
import org.junit.Test;
@@ -89,7 +89,7 @@ public class ConjugateGradientTest {
for (int i = 0; i < n; i++) {
final double actual = x.getEntry(i);
final double expected = ainv.getEntry(i, j);
- final double delta = 1E-10 * FastMath.abs(expected);
+ final double delta = 1E-10 * AccurateMath.abs(expected);
final String msg = String.format("entry[%d][%d]", i, j);
Assert.assertEquals(msg, expected, actual, delta);
}
@@ -115,7 +115,7 @@ public class ConjugateGradientTest {
for (int i = 0; i < n; i++) {
final double actual = x.getEntry(i);
final double expected = ainv.getEntry(i, j);
- final double delta = 1E-10 * FastMath.abs(expected);
+ final double delta = 1E-10 * AccurateMath.abs(expected);
final String msg = String.format("entry[%d][%d)", i, j);
Assert.assertEquals(msg, expected, actual, delta);
}
@@ -141,7 +141,7 @@ public class ConjugateGradientTest {
for (int i = 0; i < n; i++) {
final double actual = x.getEntry(i);
final double expected = ainv.getEntry(i, j);
- final double delta = 1E-10 * FastMath.abs(expected);
+ final double delta = 1E-10 * AccurateMath.abs(expected);
final String msg = String.format("entry[%d][%d]", i, j);
Assert.assertEquals(msg, expected, actual, delta);
Assert.assertEquals(msg, x0.getEntry(i), 1., Math.ulp(1.));
@@ -206,7 +206,7 @@ public class ConjugateGradientTest {
for (int i = 0; i < n; i++) {
final double actual = b.getEntry(i) - y.getEntry(i);
final double expected = r.getEntry(i);
- final double delta = 1E-6 * FastMath.abs(expected);
+ final double delta = 1E-6 * AccurateMath.abs(expected);
final String msg = String
.format("column %d, residual %d", i, j);
Assert.assertEquals(msg, expected, actual, delta);
@@ -322,7 +322,7 @@ public class ConjugateGradientTest {
for (int i = 0; i < n; i++) {
final double actual = x.getEntry(i);
final double expected = ainv.getEntry(i, j);
- final double delta = 1E-6 * FastMath.abs(expected);
+ final double delta = 1E-6 * AccurateMath.abs(expected);
final String msg = String.format("coefficient (%d, %d)", i, j);
Assert.assertEquals(msg, expected, actual, delta);
}
@@ -382,7 +382,7 @@ public class ConjugateGradientTest {
for (int i = 0; i < n; i++) {
final double actual = b.getEntry(i) - y.getEntry(i);
final double expected = r.getEntry(i);
- final double delta = 1E-6 * FastMath.abs(expected);
+ final double delta = 1E-6 * AccurateMath.abs(expected);
final String msg = String.format("column %d, residual %d", i, j);
Assert.assertEquals(msg, expected, actual, delta);
}
@@ -431,7 +431,7 @@ public class ConjugateGradientTest {
msg = String.format("row %d, column %d", i, j);
final double expected = x.getEntry(i);
final double actual = px.getEntry(i);
- final double delta = 1E-6 * FastMath.abs(expected);
+ final double delta = 1E-6 * AccurateMath.abs(expected);
Assert.assertEquals(msg, expected, actual, delta);
}
}
@@ -534,7 +534,7 @@ public class ConjugateGradientTest {
final double rnorm = r.getNorm();
Assert.assertEquals("iteration performed (residual)",
rnorm, evt.getNormOfResidual(),
- FastMath.max(1E-5 * rnorm, 1E-10));
+ AccurateMath.max(1E-5 * rnorm, 1E-10));
}
@Override
@@ -585,7 +585,7 @@ public class ConjugateGradientTest {
final double rnorm = r.getNorm();
Assert.assertEquals("iteration performed (residual)",
rnorm, evt.getNormOfResidual(),
- FastMath.max(1E-5 * rnorm, 1E-10));
+ AccurateMath.max(1E-5 * rnorm, 1E-10));
}
@Override
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/linear/Dfp25.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/linear/Dfp25.java
index 4a10d1663..edadb23f6 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/linear/Dfp25.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/linear/Dfp25.java
@@ -16,11 +16,11 @@
*/
package org.apache.commons.math4.legacy.linear;
-import org.apache.commons.math4.legacy.dfp.Dfp;
-import org.apache.commons.math4.legacy.dfp.DfpField;
+import org.apache.commons.math4.legacy.core.dfp.Dfp;
+import org.apache.commons.math4.legacy.core.dfp.DfpField;
/**
- * Dummy class for testing {@link org.apache.commons.math4.legacy.Field} functionalities.
+ * Dummy class for testing {@link org.apache.commons.math4.legacy.core.Field} functionalities.
*/
public class Dfp25 {
private static final DfpField FIELD = new DfpField(25);
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/linear/EigenDecompositionTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/linear/EigenDecompositionTest.java
index 4afff31ae..20ca060f7 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/linear/EigenDecompositionTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/linear/EigenDecompositionTest.java
@@ -23,8 +23,8 @@ import java.util.Random;
import org.apache.commons.statistics.distribution.ContinuousDistribution;
import org.apache.commons.statistics.distribution.NormalDistribution;
import org.apache.commons.math4.legacy.exception.MathUnsupportedOperationException;
-import org.apache.commons.math4.legacy.util.FastMath;
-import org.apache.commons.math4.legacy.util.MathArrays;
+import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
+import org.apache.commons.math4.legacy.core.MathArrays;
import org.apache.commons.numbers.core.Precision;
import org.apache.commons.rng.simple.RandomSource;
import org.junit.After;
@@ -514,7 +514,7 @@ public class EigenDecompositionTest {
double diffNorm = x.subtract(y).getNorm();
Assert.assertTrue("The norm of (X-Y) is too large: " + diffNorm + ", matrix=" + m.toString(),
- x.subtract(y).getNorm() < 1000 * Precision.EPSILON * FastMath.max(x.getNorm(), y.getNorm()));
+ x.subtract(y).getNorm() < 1000 * Precision.EPSILON * AccurateMath.max(x.getNorm(), y.getNorm()));
RealMatrix invV = new LUDecomposition(v).getSolver().getInverse();
double norm = v.multiply(d).multiply(invV).subtract(m).getNorm();
@@ -618,11 +618,11 @@ public class EigenDecompositionTest {
EigenDecomposition ed;
ed = new EigenDecomposition(indefinite);
checkEigenValues((new double[] {2, 1, -1}), ed, 1E-12);
- double isqrt3 = 1/FastMath.sqrt(3.0);
+ double isqrt3 = 1/AccurateMath.sqrt(3.0);
checkEigenVector((new double[] {isqrt3,isqrt3,-isqrt3}), ed, 1E-12);
- double isqrt2 = 1/FastMath.sqrt(2.0);
+ double isqrt2 = 1/AccurateMath.sqrt(2.0);
checkEigenVector((new double[] {0.0,-isqrt2,-isqrt2}), ed, 1E-12);
- double isqrt6 = 1/FastMath.sqrt(6.0);
+ double isqrt6 = 1/AccurateMath.sqrt(6.0);
checkEigenVector((new double[] {2*isqrt6,-isqrt6,isqrt6}), ed, 1E-12);
}
@@ -671,7 +671,7 @@ public class EigenDecompositionTest {
boolean found = false;
int i = 0;
while (!found && i < searchArray.length) {
- if (FastMath.abs(value - searchArray[i]) < tolerance) {
+ if (AccurateMath.abs(value - searchArray[i]) < tolerance) {
found = true;
}
i++;
@@ -704,11 +704,11 @@ public class EigenDecompositionTest {
while (matching && j < searchMatrix.getRowDimension()) {
double colEntry = searchMatrix.getEntry(j, i);
// Use the first entry where both are non-zero as scalar
- if (FastMath.abs(multiplier - 1.0) <= FastMath.ulp(1.0) && FastMath.abs(colEntry) > 1E-14
- && FastMath.abs(column[j]) > 1e-14) {
+ if (AccurateMath.abs(multiplier - 1.0) <= AccurateMath.ulp(1.0) && AccurateMath.abs(colEntry) > 1E-14
+ && AccurateMath.abs(column[j]) > 1e-14) {
multiplier = colEntry / column[j];
}
- if (FastMath.abs(column[j] * multiplier - colEntry) > tolerance) {
+ if (AccurateMath.abs(column[j] * multiplier - colEntry) > tolerance) {
matching = false;
}
j++;
@@ -771,7 +771,7 @@ public class EigenDecompositionTest {
for (final double dataIJ : dataI) {
norm2 += dataIJ * dataIJ;
}
- final double inv = 1.0 / FastMath.sqrt(norm2);
+ final double inv = 1.0 / AccurateMath.sqrt(norm2);
for (int j = 0; j < size; ++j) {
dataI[j] *= inv;
}
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/linear/FieldLUDecompositionTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/linear/FieldLUDecompositionTest.java
index 2808dfc2a..1c1174add 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/linear/FieldLUDecompositionTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/linear/FieldLUDecompositionTest.java
@@ -20,7 +20,7 @@ package org.apache.commons.math4.legacy.linear;
import org.junit.Test;
import org.junit.Assert;
import org.apache.commons.math4.legacy.TestUtils;
-import org.apache.commons.math4.legacy.dfp.Dfp;
+import org.apache.commons.math4.legacy.core.dfp.Dfp;
public class FieldLUDecompositionTest {
private Dfp[][] testData = {
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/linear/FieldLUSolverTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/linear/FieldLUSolverTest.java
index 431ad09b8..30145a3fe 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/linear/FieldLUSolverTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/linear/FieldLUSolverTest.java
@@ -18,7 +18,7 @@
package org.apache.commons.math4.legacy.linear;
import org.apache.commons.math4.legacy.exception.MathIllegalArgumentException;
-import org.apache.commons.math4.legacy.dfp.Dfp;
+import org.apache.commons.math4.legacy.core.dfp.Dfp;
import org.junit.Assert;
import org.junit.Test;
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/linear/FieldMatrixImplTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/linear/FieldMatrixImplTest.java
index 56d241f97..1af3e5e52 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/linear/FieldMatrixImplTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/linear/FieldMatrixImplTest.java
@@ -27,7 +27,7 @@ import org.apache.commons.math4.legacy.exception.NotStrictlyPositiveException;
import org.apache.commons.math4.legacy.exception.NullArgumentException;
import org.apache.commons.math4.legacy.exception.NumberIsTooSmallException;
import org.apache.commons.math4.legacy.exception.OutOfRangeException;
-import org.apache.commons.math4.legacy.dfp.Dfp;
+import org.apache.commons.math4.legacy.core.dfp.Dfp;
/**
* Test cases for the {@link Array2DRowFieldMatrix} class.
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/linear/MatrixUtilsTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/linear/MatrixUtilsTest.java
index 901b4c8b2..4019ece07 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/linear/MatrixUtilsTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/linear/MatrixUtilsTest.java
@@ -23,7 +23,7 @@ import org.apache.commons.math4.legacy.exception.MathIllegalArgumentException;
import org.apache.commons.math4.legacy.exception.NotStrictlyPositiveException;
import org.apache.commons.math4.legacy.exception.NullArgumentException;
import org.apache.commons.math4.legacy.exception.OutOfRangeException;
-import org.apache.commons.math4.legacy.dfp.Dfp;
+import org.apache.commons.math4.legacy.core.dfp.Dfp;
import org.junit.Assert;
import org.junit.Test;
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/linear/OpenIntToFieldTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/linear/OpenIntToFieldTest.java
index 0974c07a7..3a749e49a 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/linear/OpenIntToFieldTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/linear/OpenIntToFieldTest.java
@@ -25,9 +25,9 @@ import java.util.Random;
import java.util.Set;
import java.util.Map.Entry;
-import org.apache.commons.math4.legacy.Field;
-import org.apache.commons.math4.legacy.dfp.Dfp;
-import org.apache.commons.math4.legacy.dfp.DfpField;
+import org.apache.commons.math4.legacy.core.Field;
+import org.apache.commons.math4.legacy.core.dfp.Dfp;
+import org.apache.commons.math4.legacy.core.dfp.DfpField;
import org.apache.commons.math4.legacy.linear.Dfp25;
import org.apache.commons.math4.legacy.linear.OpenIntToFieldHashMap;
import org.junit.Assert;
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/linear/RealVectorAbstractTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/linear/RealVectorAbstractTest.java
index 56e709378..0b70ca3e9 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/linear/RealVectorAbstractTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/linear/RealVectorAbstractTest.java
@@ -53,7 +53,7 @@ import org.apache.commons.math4.legacy.exception.MathUnsupportedOperationExcepti
import org.apache.commons.math4.legacy.exception.NotPositiveException;
import org.apache.commons.math4.legacy.exception.NumberIsTooSmallException;
import org.apache.commons.math4.legacy.exception.OutOfRangeException;
-import org.apache.commons.math4.legacy.util.FastMath;
+import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
import org.junit.Assert;
import org.junit.Test;
@@ -612,7 +612,7 @@ public abstract class RealVectorAbstractTest {
final double delta = data2[i] - data1[i];
expected += delta * delta;
}
- expected = FastMath.sqrt(expected);
+ expected = AccurateMath.sqrt(expected);
Assert.assertEquals("", expected, actual, 0d);
}
@@ -641,7 +641,7 @@ public abstract class RealVectorAbstractTest {
for (int i = 0; i < data.length; i++) {
expected += data[i] * data[i];
}
- expected = FastMath.sqrt(expected);
+ expected = AccurateMath.sqrt(expected);
Assert.assertEquals("", expected, actual, 0d);
}
@@ -660,7 +660,7 @@ public abstract class RealVectorAbstractTest {
double expected = 0d;
for (int i = 0; i < data1.length; i++) {
final double delta = data2[i] - data1[i];
- expected += FastMath.abs(delta);
+ expected += AccurateMath.abs(delta);
}
Assert.assertEquals("", expected, actual, 0d);
}
@@ -688,7 +688,7 @@ public abstract class RealVectorAbstractTest {
final double actual = v.getL1Norm();
double expected = 0d;
for (int i = 0; i < data.length; i++) {
- expected += FastMath.abs(data[i]);
+ expected += AccurateMath.abs(data[i]);
}
Assert.assertEquals("", expected, actual, 0d);
@@ -709,7 +709,7 @@ public abstract class RealVectorAbstractTest {
double expected = 0d;
for (int i = 0; i < data1.length; i++) {
final double delta = data2[i] - data1[i];
- expected = FastMath.max(expected, FastMath.abs(delta));
+ expected = AccurateMath.max(expected, AccurateMath.abs(delta));
}
Assert.assertEquals("", expected, actual, 0d);
}
@@ -737,7 +737,7 @@ public abstract class RealVectorAbstractTest {
final double actual = v.getLInfNorm();
double expected = 0d;
for (int i = 0; i < data.length; i++) {
- expected = FastMath.max(expected, FastMath.abs(data[i]));
+ expected = AccurateMath.max(expected, AccurateMath.abs(data[i]));
}
Assert.assertEquals("", expected, actual, 0d);
@@ -850,10 +850,10 @@ public abstract class RealVectorAbstractTest {
final boolean inPlace) {
final double[] data = new double[values.length + 6];
System.arraycopy(values, 0, data, 0, values.length);
- data[values.length + 0] = 0.5 * FastMath.PI;
- data[values.length + 1] = -0.5 * FastMath.PI;
- data[values.length + 2] = FastMath.E;
- data[values.length + 3] = -FastMath.E;
+ data[values.length + 0] = 0.5 * AccurateMath.PI;
+ data[values.length + 1] = -0.5 * AccurateMath.PI;
+ data[values.length + 2] = AccurateMath.E;
+ data[values.length + 3] = -AccurateMath.E;
data[values.length + 4] = 1.0;
data[values.length + 5] = -1.0;
final double[] expected = new double[data.length];
@@ -1018,7 +1018,7 @@ public abstract class RealVectorAbstractTest {
for (int i = 0; i < data.length; i++) {
norm += data[i] * data[i];
}
- norm = FastMath.sqrt(norm);
+ norm = AccurateMath.sqrt(norm);
final double[] expected = new double[data.length];
for (int i = 0; i < expected.length; i++) {
expected[i] = data[i] / norm;
@@ -1287,8 +1287,8 @@ public abstract class RealVectorAbstractTest {
norm2 += data2[i] * data2[i];
dotProduct += data1[i] * data2[i];
}
- norm1 = FastMath.sqrt(norm1);
- norm2 = FastMath.sqrt(norm2);
+ norm1 = AccurateMath.sqrt(norm1);
+ norm2 = AccurateMath.sqrt(norm2);
final double expected = dotProduct / (norm1 * norm2);
final RealVector v1 = create(data1);
final RealVector v2;
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/linear/SparseFieldMatrixTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/linear/SparseFieldMatrixTest.java
index 3076f6f8d..99621b39a 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/linear/SparseFieldMatrixTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/linear/SparseFieldMatrixTest.java
@@ -18,13 +18,13 @@ package org.apache.commons.math4.legacy.linear;
import org.junit.Test;
import org.junit.Assert;
-import org.apache.commons.math4.legacy.Field;
+import org.apache.commons.math4.legacy.core.Field;
import org.apache.commons.math4.legacy.exception.MathIllegalArgumentException;
import org.apache.commons.math4.legacy.exception.NoDataException;
import org.apache.commons.math4.legacy.exception.NullArgumentException;
import org.apache.commons.math4.legacy.exception.NumberIsTooSmallException;
import org.apache.commons.math4.legacy.exception.OutOfRangeException;
-import org.apache.commons.math4.legacy.dfp.Dfp;
+import org.apache.commons.math4.legacy.core.dfp.Dfp;
/**
* Test cases for the {@link SparseFieldMatrix} class.
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/linear/SparseFieldVectorTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/linear/SparseFieldVectorTest.java
index 831deb4e5..7ebe535ec 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/linear/SparseFieldVectorTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/linear/SparseFieldVectorTest.java
@@ -22,8 +22,8 @@ import java.util.Arrays;
import org.apache.commons.math4.legacy.exception.MathIllegalArgumentException;
import org.apache.commons.math4.legacy.exception.NumberIsTooSmallException;
import org.apache.commons.math4.legacy.exception.OutOfRangeException;
-import org.apache.commons.math4.legacy.dfp.Dfp;
-import org.apache.commons.math4.legacy.dfp.DfpField;
+import org.apache.commons.math4.legacy.core.dfp.Dfp;
+import org.apache.commons.math4.legacy.core.dfp.DfpField;
import org.junit.Assert;
import org.junit.Test;
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/linear/SymmLQTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/linear/SymmLQTest.java
index ed8805de5..4a657291c 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/linear/SymmLQTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/linear/SymmLQTest.java
@@ -19,7 +19,7 @@ package org.apache.commons.math4.legacy.linear;
import java.util.Arrays;
import org.apache.commons.math4.legacy.exception.DimensionMismatchException;
-import org.apache.commons.math4.legacy.util.FastMath;
+import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
import org.junit.Assert;
import org.junit.Test;
@@ -53,7 +53,7 @@ public class SymmLQTest {
}
};
final double shiftm = shift;
- final double pertm = FastMath.abs(pertbn);
+ final double pertm = AccurateMath.abs(pertbn);
final RealLinearOperator minv;
if (precon) {
minv = new RealLinearOperator() {
@@ -76,7 +76,7 @@ public class SymmLQTest {
final double[] y = new double[n];
for (int i = 0; i < n; i++) {
double d = (i + 1) * 1.1 / n;
- d = FastMath.abs(d - shiftm);
+ d = AccurateMath.abs(d - shiftm);
if (i % 10 == 0) {
d += pertm;
}
@@ -255,7 +255,7 @@ public class SymmLQTest {
for (int i = 0; i < n; i++) {
final double actual = x.getEntry(i);
final double expected = ainv.getEntry(i, j);
- final double delta = 1E-6 * FastMath.abs(expected);
+ final double delta = 1E-6 * AccurateMath.abs(expected);
final String msg = String.format("entry[%d][%d]", i, j);
Assert.assertEquals(msg, expected, actual, delta);
}
@@ -281,7 +281,7 @@ public class SymmLQTest {
for (int i = 0; i < n; i++) {
final double actual = x.getEntry(i);
final double expected = ainv.getEntry(i, j);
- final double delta = 1E-6 * FastMath.abs(expected);
+ final double delta = 1E-6 * AccurateMath.abs(expected);
final String msg = String.format("entry[%d][%d)", i, j);
Assert.assertEquals(msg, expected, actual, delta);
}
@@ -307,7 +307,7 @@ public class SymmLQTest {
for (int i = 0; i < n; i++) {
final double actual = x.getEntry(i);
final double expected = ainv.getEntry(i, j);
- final double delta = 1E-6 * FastMath.abs(expected);
+ final double delta = 1E-6 * AccurateMath.abs(expected);
final String msg = String.format("entry[%d][%d]", i, j);
Assert.assertEquals(msg, expected, actual, delta);
Assert.assertEquals(msg, x0.getEntry(i), 1., Math.ulp(1.));
@@ -419,7 +419,7 @@ public class SymmLQTest {
for (int i = 0; i < n; i++) {
final double actual = x.getEntry(i);
final double expected = ainv.getEntry(i, j);
- final double delta = 1E-6 * FastMath.abs(expected);
+ final double delta = 1E-6 * AccurateMath.abs(expected);
final String msg = String.format("coefficient (%d, %d)", i, j);
Assert.assertEquals(msg, expected, actual, delta);
}
@@ -465,7 +465,7 @@ public class SymmLQTest {
msg = String.format("row %d, column %d", i, j);
final double expected = x.getEntry(i);
final double actual = px.getEntry(i);
- final double delta = 5E-5 * FastMath.abs(expected);
+ final double delta = 5E-5 * AccurateMath.abs(expected);
Assert.assertEquals(msg, expected, actual, delta);
}
}
@@ -610,7 +610,7 @@ public class SymmLQTest {
final double rnorm = r.getNorm();
Assert.assertEquals("iteration performed (residual)",
rnorm, evt.getNormOfResidual(),
- FastMath.max(1E-5 * rnorm, 1E-10));
+ AccurateMath.max(1E-5 * rnorm, 1E-10));
}
@Override
@@ -662,7 +662,7 @@ public class SymmLQTest {
final double rnorm = p.operate(r).getNorm();
Assert.assertEquals("iteration performed (residual)",
rnorm, evt.getNormOfResidual(),
- FastMath.max(1E-5 * rnorm, 1E-10));
+ AccurateMath.max(1E-5 * rnorm, 1E-10));
}
@Override
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/linear/TriDiagonalTransformerTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/linear/TriDiagonalTransformerTest.java
index fcc032552..e8b6f5db3 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/linear/TriDiagonalTransformerTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/linear/TriDiagonalTransformerTest.java
@@ -19,7 +19,7 @@ package org.apache.commons.math4.legacy.linear;
import java.util.Arrays;
-import org.apache.commons.math4.legacy.util.FastMath;
+import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
import org.junit.Test;
import org.junit.Assert;
@@ -132,7 +132,7 @@ public class TriDiagonalTransformerTest {
{ 0.0, -0.2581988897471611, 0.6364346693566009, -0.027289660803112598, -0.7263191580755246 }
},
new double[] { 1, 4.4, 1.433099579242636, -0.89537362758743, 2.062274048344794 },
- new double[] { -FastMath.sqrt(15), -3.0832882879592476, 0.6082710842351517, 1.1786086405912128 });
+ new double[] { -AccurateMath.sqrt(15), -3.0832882879592476, 0.6082710842351517, 1.1786086405912128 });
}
@Test
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/linear/UnmodifiableRealVectorAbstractTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/linear/UnmodifiableRealVectorAbstractTest.java
index 6e39e4a1b..b789c47b4 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/linear/UnmodifiableRealVectorAbstractTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/linear/UnmodifiableRealVectorAbstractTest.java
@@ -27,7 +27,7 @@ import org.apache.commons.math4.legacy.analysis.UnivariateFunction;
import org.apache.commons.math4.legacy.analysis.function.Sin;
import org.apache.commons.math4.legacy.exception.MathUnsupportedOperationException;
import org.apache.commons.math4.legacy.linear.RealVector.Entry;
-import org.apache.commons.math4.legacy.util.FastMath;
+import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
import org.junit.Assert;
import org.junit.Test;
@@ -85,12 +85,12 @@ public abstract class UnmodifiableRealVectorAbstractTest {
public static boolean equals(final double x, final double y) {
if (x == y) {
return true;
- } else if (FastMath.abs(x) <= EPS) {
- return FastMath.abs(y) <= EPS;
- } else if (FastMath.abs(y) <= EPS) {
- return FastMath.abs(x) <= EPS;
+ } else if (AccurateMath.abs(x) <= EPS) {
+ return AccurateMath.abs(y) <= EPS;
+ } else if (AccurateMath.abs(y) <= EPS) {
+ return AccurateMath.abs(x) <= EPS;
} else {
- return FastMath.abs(x - y) <= EPS * FastMath.min(FastMath.abs(x), FastMath.abs(y));
+ return AccurateMath.abs(x - y) <= EPS * AccurateMath.min(AccurateMath.abs(x), AccurateMath.abs(y));
}
}
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ml/distance/EuclideanDistanceTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ml/distance/EuclideanDistanceTest.java
index 021668c75..820a5e786 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ml/distance/EuclideanDistanceTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ml/distance/EuclideanDistanceTest.java
@@ -18,7 +18,7 @@ package org.apache.commons.math4.legacy.ml.distance;
import org.junit.Assert;
import org.junit.Test;
-import org.apache.commons.math4.legacy.util.FastMath;
+import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
/**
* Tests for {@link EuclideanDistance} class.
@@ -36,7 +36,7 @@ public class EuclideanDistanceTest {
public void test() {
final double[] a = { 1, -2, 3, 4 };
final double[] b = { -5, -6, 7, 8 };
- final double expected = FastMath.sqrt(84);
+ final double expected = AccurateMath.sqrt(84);
Assert.assertEquals(expected, distance.compute(a, b), 0d);
Assert.assertEquals(expected, distance.compute(b, a), 0d);
}
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/ContinuousOutputFieldModelTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/ContinuousOutputFieldModelTest.java
index 0166b6d0e..59e37c640 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/ContinuousOutputFieldModelTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/ContinuousOutputFieldModelTest.java
@@ -19,8 +19,8 @@ package org.apache.commons.math4.legacy.ode;
import java.util.Random;
-import org.apache.commons.math4.legacy.Field;
-import org.apache.commons.math4.legacy.RealFieldElement;
+import org.apache.commons.math4.legacy.core.Field;
+import org.apache.commons.math4.legacy.core.RealFieldElement;
import org.apache.commons.math4.legacy.exception.DimensionMismatchException;
import org.apache.commons.math4.legacy.exception.MathIllegalArgumentException;
import org.apache.commons.math4.legacy.ode.nonstiff.DormandPrince54FieldIntegrator;
@@ -28,8 +28,8 @@ import org.apache.commons.math4.legacy.ode.nonstiff.DormandPrince853FieldIntegra
import org.apache.commons.math4.legacy.ode.sampling.DummyFieldStepInterpolator;
import org.apache.commons.math4.legacy.ode.sampling.FieldStepInterpolator;
import org.apache.commons.math4.legacy.ode.nonstiff.Decimal64Field;
-import org.apache.commons.math4.legacy.util.FastMath;
-import org.apache.commons.math4.legacy.util.MathArrays;
+import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
+import org.apache.commons.math4.legacy.core.MathArrays;
import org.junit.Assert;
import org.junit.Test;
@@ -123,7 +123,7 @@ public class ContinuousOutputFieldModelTest {
FirstOrderFieldIntegrator integ1 =
new DormandPrince853FieldIntegrator<>(field, 0, 1.0, 1.0e-8, 1.0e-8);
integ1.addStepHandler(cm1);
- T t0 = field.getZero().add(FastMath.PI);
+ T t0 = field.getZero().add(AccurateMath.PI);
T[] y0 = MathArrays.buildArray(field, 2);
y0[0] = field.getOne().negate();
y0[1] = field.getZero();
@@ -136,12 +136,12 @@ public class ContinuousOutputFieldModelTest {
FirstOrderFieldIntegrator integ2 =
new DormandPrince853FieldIntegrator<>(field, 0, 0.1, 1.0e-12, 1.0e-12);
integ2.addStepHandler(cm2);
- t0 = field.getZero().add(2.0 * FastMath.PI);
+ t0 = field.getZero().add(2.0 * AccurateMath.PI);
y0[0] = field.getOne();
y0[1] = field.getZero();
integ2.integrate(new FieldExpandableODE<>(problem),
new FieldODEState<>(t0, y0),
- field.getZero().add(FastMath.PI));
+ field.getZero().add(AccurateMath.PI));
// merge the two half circles
ContinuousOutputFieldModel cm = new ContinuousOutputFieldModel<>();
@@ -150,12 +150,12 @@ public class ContinuousOutputFieldModelTest {
cm.append(cm1);
// check circle
- Assert.assertEquals(2.0 * FastMath.PI, cm.getInitialTime().getReal(), 1.0e-12);
+ Assert.assertEquals(2.0 * AccurateMath.PI, cm.getInitialTime().getReal(), 1.0e-12);
Assert.assertEquals(0, cm.getFinalTime().getReal(), 1.0e-12);
- for (double t = 0; t < 2.0 * FastMath.PI; t += 0.1) {
+ for (double t = 0; t < 2.0 * AccurateMath.PI; t += 0.1) {
FieldODEStateAndDerivative interpolated = cm.getInterpolatedState(field.getZero().add(t));
- Assert.assertEquals(FastMath.cos(t), interpolated.getState()[0].getReal(), 1.0e-7);
- Assert.assertEquals(FastMath.sin(t), interpolated.getState()[1].getReal(), 1.0e-7);
+ Assert.assertEquals(AccurateMath.cos(t), interpolated.getState()[0].getReal(), 1.0e-7);
+ Assert.assertEquals(AccurateMath.sin(t), interpolated.getState()[1].getReal(), 1.0e-7);
}
}
@@ -222,7 +222,7 @@ public class ContinuousOutputFieldModelTest {
}
public void checkValue(double value, double reference) {
- Assert.assertTrue(FastMath.abs(value - reference) < 1.0e-10);
+ Assert.assertTrue(AccurateMath.abs(value - reference) < 1.0e-10);
}
}
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/ContinuousOutputModelTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/ContinuousOutputModelTest.java
index 692f1f64f..fc9203e2a 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/ContinuousOutputModelTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/ContinuousOutputModelTest.java
@@ -28,7 +28,7 @@ import org.apache.commons.math4.legacy.ode.nonstiff.DormandPrince54Integrator;
import org.apache.commons.math4.legacy.ode.nonstiff.DormandPrince853Integrator;
import org.apache.commons.math4.legacy.ode.sampling.DummyStepInterpolator;
import org.apache.commons.math4.legacy.ode.sampling.StepInterpolator;
-import org.apache.commons.math4.legacy.util.FastMath;
+import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
@@ -77,11 +77,11 @@ public class ContinuousOutputModelTest {
double dx = interpolatedY[0] - theoreticalY[0];
double dy = interpolatedY[1] - theoreticalY[1];
double error = dx * dx + dy * dy;
- maxError = FastMath.max(maxError, error);
+ maxError = AccurateMath.max(maxError, error);
double dxDot = interpolatedYDot[0] - theoreticalYDot[0];
double dyDot = interpolatedYDot[1] - theoreticalYDot[1];
double errorDot = dxDot * dxDot + dyDot * dyDot;
- maxErrorDot = FastMath.max(maxErrorDot, errorDot);
+ maxErrorDot = AccurateMath.max(maxErrorDot, errorDot);
}
Assert.assertEquals(0.0, maxError, 1.0e-9);
@@ -111,7 +111,7 @@ public class ContinuousOutputModelTest {
FirstOrderIntegrator integ1 =
new DormandPrince853Integrator(0, 1.0, 1.0e-8, 1.0e-8);
integ1.addStepHandler(cm1);
- integ1.integrate(problem, FastMath.PI, new double[] { -1.0, 0.0 },
+ integ1.integrate(problem, AccurateMath.PI, new double[] { -1.0, 0.0 },
0, new double[2]);
// integrate backward from 2π to π
@@ -119,8 +119,8 @@ public class ContinuousOutputModelTest {
FirstOrderIntegrator integ2 =
new DormandPrince853Integrator(0, 0.1, 1.0e-12, 1.0e-12);
integ2.addStepHandler(cm2);
- integ2.integrate(problem, 2.0 * FastMath.PI, new double[] { 1.0, 0.0 },
- FastMath.PI, new double[2]);
+ integ2.integrate(problem, 2.0 * AccurateMath.PI, new double[] { 1.0, 0.0 },
+ AccurateMath.PI, new double[2]);
// merge the two half circles
ContinuousOutputModel cm = new ContinuousOutputModel();
@@ -129,14 +129,14 @@ public class ContinuousOutputModelTest {
cm.append(cm1);
// check circle
- Assert.assertEquals(2.0 * FastMath.PI, cm.getInitialTime(), 1.0e-12);
+ Assert.assertEquals(2.0 * AccurateMath.PI, cm.getInitialTime(), 1.0e-12);
Assert.assertEquals(0, cm.getFinalTime(), 1.0e-12);
Assert.assertEquals(cm.getFinalTime(), cm.getInterpolatedTime(), 1.0e-12);
- for (double t = 0; t < 2.0 * FastMath.PI; t += 0.1) {
+ for (double t = 0; t < 2.0 * AccurateMath.PI; t += 0.1) {
cm.setInterpolatedTime(t);
double[] y = cm.getInterpolatedState();
- Assert.assertEquals(FastMath.cos(t), y[0], 1.0e-7);
- Assert.assertEquals(FastMath.sin(t), y[1], 1.0e-7);
+ Assert.assertEquals(AccurateMath.cos(t), y[0], 1.0e-7);
+ Assert.assertEquals(AccurateMath.sin(t), y[1], 1.0e-7);
}
}
@@ -183,7 +183,7 @@ public class ContinuousOutputModelTest {
}
public void checkValue(double value, double reference) {
- Assert.assertTrue(FastMath.abs(value - reference) < 1.0e-10);
+ Assert.assertTrue(AccurateMath.abs(value - reference) < 1.0e-10);
}
@Before
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/FieldExpandableODETest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/FieldExpandableODETest.java
index 1d37c3687..018e6e4b9 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/FieldExpandableODETest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/FieldExpandableODETest.java
@@ -18,12 +18,12 @@
package org.apache.commons.math4.legacy.ode;
-import org.apache.commons.math4.legacy.Field;
-import org.apache.commons.math4.legacy.RealFieldElement;
+import org.apache.commons.math4.legacy.core.Field;
+import org.apache.commons.math4.legacy.core.RealFieldElement;
import org.apache.commons.math4.legacy.exception.DimensionMismatchException;
import org.apache.commons.math4.legacy.exception.MathIllegalArgumentException;
import org.apache.commons.math4.legacy.ode.nonstiff.Decimal64Field;
-import org.apache.commons.math4.legacy.util.MathArrays;
+import org.apache.commons.math4.legacy.core.MathArrays;
import org.junit.Assert;
import org.junit.Test;
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/FirstOrderConverterTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/FirstOrderConverterTest.java
index 2c49a0d49..78fb999df 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/FirstOrderConverterTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/FirstOrderConverterTest.java
@@ -22,7 +22,7 @@ import org.apache.commons.math4.legacy.exception.MaxCountExceededException;
import org.apache.commons.math4.legacy.exception.NoBracketingException;
import org.apache.commons.math4.legacy.exception.NumberIsTooSmallException;
import org.apache.commons.math4.legacy.ode.nonstiff.ClassicalRungeKuttaIntegrator;
-import org.apache.commons.math4.legacy.util.FastMath;
+import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
import org.junit.Assert;
import org.junit.Test;
@@ -45,11 +45,11 @@ public class FirstOrderConverterTest {
double previousError = Double.NaN;
for (int i = 0; i < 10; ++i) {
- double step = FastMath.pow(2.0, -(i + 1));
+ double step = AccurateMath.pow(2.0, -(i + 1));
double error = integrateWithSpecifiedStep(4.0, 0.0, 1.0, step)
- - FastMath.sin(4.0);
+ - AccurateMath.sin(4.0);
if (i > 0) {
- Assert.assertTrue(FastMath.abs(error) < FastMath.abs(previousError));
+ Assert.assertTrue(AccurateMath.abs(error) < AccurateMath.abs(previousError));
}
previousError = error;
@@ -60,16 +60,16 @@ public class FirstOrderConverterTest {
public void testSmallStep()
throws DimensionMismatchException, NumberIsTooSmallException, MaxCountExceededException, NoBracketingException {
double error = integrateWithSpecifiedStep(4.0, 0.0, 1.0, 1.0e-4)
- - FastMath.sin(4.0);
- Assert.assertTrue(FastMath.abs(error) < 1.0e-10);
+ - AccurateMath.sin(4.0);
+ Assert.assertTrue(AccurateMath.abs(error) < 1.0e-10);
}
@Test
public void testBigStep()
throws DimensionMismatchException, NumberIsTooSmallException, MaxCountExceededException, NoBracketingException {
double error = integrateWithSpecifiedStep(4.0, 0.0, 1.0, 0.5)
- - FastMath.sin(4.0);
- Assert.assertTrue(FastMath.abs(error) > 0.1);
+ - AccurateMath.sin(4.0);
+ Assert.assertTrue(AccurateMath.abs(error) > 0.1);
}
private static class Equations
@@ -103,8 +103,8 @@ public class FirstOrderConverterTest {
double t0, double t,
double step) throws DimensionMismatchException, NumberIsTooSmallException, MaxCountExceededException, NoBracketingException {
double[] y0 = new double[2];
- y0[0] = FastMath.sin(omega * t0);
- y0[1] = omega * FastMath.cos(omega * t0);
+ y0[0] = AccurateMath.sin(omega * t0);
+ y0[1] = omega * AccurateMath.cos(omega * t0);
ClassicalRungeKuttaIntegrator i = new ClassicalRungeKuttaIntegrator(step);
double[] y = new double[2];
i.integrate(new FirstOrderConverter(new Equations(1, omega)), t0, y0, t, y);
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/JacobianMatricesTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/JacobianMatricesTest.java
index 4bc36c645..ab660c4bc 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/JacobianMatricesTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/JacobianMatricesTest.java
@@ -24,7 +24,7 @@ import org.apache.commons.math4.legacy.exception.NumberIsTooSmallException;
import org.apache.commons.math4.legacy.ode.JacobianMatrices.MismatchedEquations;
import org.apache.commons.math4.legacy.ode.nonstiff.DormandPrince54Integrator;
import org.apache.commons.math4.legacy.stat.descriptive.SummaryStatistics;
-import org.apache.commons.math4.legacy.util.FastMath;
+import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
import org.junit.Assert;
import org.junit.Test;
@@ -215,7 +215,7 @@ public class JacobianMatricesTest {
integ.setMaxEvaluations(5000);
- double t = 18 * FastMath.PI;
+ double t = 18 * AccurateMath.PI;
integ.integrate(efode, t);
y = efode.getPrimaryState();
for (int i = 0; i < y.length; ++i) {
@@ -279,7 +279,7 @@ public class JacobianMatricesTest {
integ.setMaxEvaluations(50000);
- double t = 18 * FastMath.PI;
+ double t = 18 * AccurateMath.PI;
integ.integrate(efode, t);
y = efode.getPrimaryState();
for (int i = 0; i < y.length; ++i) {
@@ -473,8 +473,8 @@ public class JacobianMatricesTest {
}
public double[] exactY(double t) {
- double cos = FastMath.cos(omega * t);
- double sin = FastMath.sin(omega * t);
+ double cos = AccurateMath.cos(omega * t);
+ double sin = AccurateMath.sin(omega * t);
double dx0 = y0[0] - cx;
double dy0 = y0[1] - cy;
return new double[] {
@@ -484,8 +484,8 @@ public class JacobianMatricesTest {
}
public double[][] exactDyDy0(double t) {
- double cos = FastMath.cos(omega * t);
- double sin = FastMath.sin(omega * t);
+ double cos = AccurateMath.cos(omega * t);
+ double sin = AccurateMath.sin(omega * t);
return new double[][] {
{ cos, -sin },
{ sin, cos }
@@ -493,20 +493,20 @@ public class JacobianMatricesTest {
}
public double[] exactDyDcx(double t) {
- double cos = FastMath.cos(omega * t);
- double sin = FastMath.sin(omega * t);
+ double cos = AccurateMath.cos(omega * t);
+ double sin = AccurateMath.sin(omega * t);
return new double[] {1 - cos, -sin};
}
public double[] exactDyDcy(double t) {
- double cos = FastMath.cos(omega * t);
- double sin = FastMath.sin(omega * t);
+ double cos = AccurateMath.cos(omega * t);
+ double sin = AccurateMath.sin(omega * t);
return new double[] {sin, 1 - cos};
}
public double[] exactDyDom(double t) {
- double cos = FastMath.cos(omega * t);
- double sin = FastMath.sin(omega * t);
+ double cos = AccurateMath.cos(omega * t);
+ double sin = AccurateMath.sin(omega * t);
double dx0 = y0[0] - cx;
double dy0 = y0[1] - cy;
return new double[] { -t * (sin * dx0 + cos * dy0) , t * (cos * dx0 - sin * dy0) };
@@ -575,8 +575,8 @@ public class JacobianMatricesTest {
}
public double[] exactY(double t) {
- double cos = FastMath.cos(omega * t);
- double sin = FastMath.sin(omega * t);
+ double cos = AccurateMath.cos(omega * t);
+ double sin = AccurateMath.sin(omega * t);
double dx0 = y0[0] - cx;
double dy0 = y0[1] - cy;
return new double[] {
@@ -586,8 +586,8 @@ public class JacobianMatricesTest {
}
public double[][] exactDyDy0(double t) {
- double cos = FastMath.cos(omega * t);
- double sin = FastMath.sin(omega * t);
+ double cos = AccurateMath.cos(omega * t);
+ double sin = AccurateMath.sin(omega * t);
return new double[][] {
{ cos, -sin },
{ sin, cos }
@@ -595,20 +595,20 @@ public class JacobianMatricesTest {
}
public double[] exactDyDcx(double t) {
- double cos = FastMath.cos(omega * t);
- double sin = FastMath.sin(omega * t);
+ double cos = AccurateMath.cos(omega * t);
+ double sin = AccurateMath.sin(omega * t);
return new double[] {1 - cos, -sin};
}
public double[] exactDyDcy(double t) {
- double cos = FastMath.cos(omega * t);
- double sin = FastMath.sin(omega * t);
+ double cos = AccurateMath.cos(omega * t);
+ double sin = AccurateMath.sin(omega * t);
return new double[] {sin, 1 - cos};
}
public double[] exactDyDom(double t) {
- double cos = FastMath.cos(omega * t);
- double sin = FastMath.sin(omega * t);
+ double cos = AccurateMath.cos(omega * t);
+ double sin = AccurateMath.sin(omega * t);
double dx0 = y0[0] - cx;
double dy0 = y0[1] - cy;
return new double[] { -t * (sin * dx0 + cos * dy0) , t * (cos * dx0 - sin * dy0) };
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/TestFieldProblem1.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/TestFieldProblem1.java
index ee8d7bd44..221c08878 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/TestFieldProblem1.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/TestFieldProblem1.java
@@ -17,9 +17,9 @@
package org.apache.commons.math4.legacy.ode;
-import org.apache.commons.math4.legacy.Field;
-import org.apache.commons.math4.legacy.RealFieldElement;
-import org.apache.commons.math4.legacy.util.MathArrays;
+import org.apache.commons.math4.legacy.core.Field;
+import org.apache.commons.math4.legacy.core.RealFieldElement;
+import org.apache.commons.math4.legacy.core.MathArrays;
/**
* This class is used in the junit tests for the ODE integrators.
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/TestFieldProblem2.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/TestFieldProblem2.java
index aa844c5ad..f9082969f 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/TestFieldProblem2.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/TestFieldProblem2.java
@@ -17,9 +17,9 @@
package org.apache.commons.math4.legacy.ode;
-import org.apache.commons.math4.legacy.Field;
-import org.apache.commons.math4.legacy.RealFieldElement;
-import org.apache.commons.math4.legacy.util.MathArrays;
+import org.apache.commons.math4.legacy.core.Field;
+import org.apache.commons.math4.legacy.core.RealFieldElement;
+import org.apache.commons.math4.legacy.core.MathArrays;
/**
* This class is used in the junit tests for the ODE integrators.
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/TestFieldProblem3.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/TestFieldProblem3.java
index be7ee267e..27e5bad78 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/TestFieldProblem3.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/TestFieldProblem3.java
@@ -17,9 +17,9 @@
package org.apache.commons.math4.legacy.ode;
-import org.apache.commons.math4.legacy.Field;
-import org.apache.commons.math4.legacy.RealFieldElement;
-import org.apache.commons.math4.legacy.util.MathArrays;
+import org.apache.commons.math4.legacy.core.Field;
+import org.apache.commons.math4.legacy.core.RealFieldElement;
+import org.apache.commons.math4.legacy.core.MathArrays;
/**
* This class is used in the junit tests for the ODE integrators.
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/TestFieldProblem4.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/TestFieldProblem4.java
index 9215c6925..6b8c3ab7e 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/TestFieldProblem4.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/TestFieldProblem4.java
@@ -19,12 +19,12 @@ package org.apache.commons.math4.legacy.ode;
import java.lang.reflect.Array;
-import org.apache.commons.math4.legacy.Field;
-import org.apache.commons.math4.legacy.RealFieldElement;
+import org.apache.commons.math4.legacy.core.Field;
+import org.apache.commons.math4.legacy.core.RealFieldElement;
import org.apache.commons.math4.legacy.ode.events.Action;
import org.apache.commons.math4.legacy.ode.events.FieldEventHandler;
-import org.apache.commons.math4.legacy.util.FastMath;
-import org.apache.commons.math4.legacy.util.MathArrays;
+import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
+import org.apache.commons.math4.legacy.core.MathArrays;
/**
* This class is used in the junit tests for the ODE integrators.
@@ -79,10 +79,10 @@ public class TestFieldProblem4>
@Override
public T[] getTheoreticalEventsTimes() {
T[] array = MathArrays.buildArray(getField(), 5);
- array[0] = a.negate().add(1 * FastMath.PI);
- array[1] = a.negate().add(2 * FastMath.PI);
- array[2] = a.negate().add(3 * FastMath.PI);
- array[3] = a.negate().add(4 * FastMath.PI);
+ array[0] = a.negate().add(1 * AccurateMath.PI);
+ array[1] = a.negate().add(2 * AccurateMath.PI);
+ array[2] = a.negate().add(3 * AccurateMath.PI);
+ array[3] = a.negate().add(4 * AccurateMath.PI);
array[4] = convert(120.0);
return array;
}
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/TestFieldProblem5.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/TestFieldProblem5.java
index c4a95ea5f..af15c561c 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/TestFieldProblem5.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/TestFieldProblem5.java
@@ -17,8 +17,8 @@
package org.apache.commons.math4.legacy.ode;
-import org.apache.commons.math4.legacy.Field;
-import org.apache.commons.math4.legacy.RealFieldElement;
+import org.apache.commons.math4.legacy.core.Field;
+import org.apache.commons.math4.legacy.core.RealFieldElement;
/**
* This class is used in the junit tests for the ODE integrators.
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/TestFieldProblem6.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/TestFieldProblem6.java
index c581332fc..643ca94e9 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/TestFieldProblem6.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/TestFieldProblem6.java
@@ -17,9 +17,9 @@
package org.apache.commons.math4.legacy.ode;
-import org.apache.commons.math4.legacy.Field;
-import org.apache.commons.math4.legacy.RealFieldElement;
-import org.apache.commons.math4.legacy.util.MathArrays;
+import org.apache.commons.math4.legacy.core.Field;
+import org.apache.commons.math4.legacy.core.RealFieldElement;
+import org.apache.commons.math4.legacy.core.MathArrays;
/**
* This class is used in the junit tests for the ODE integrators.
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/TestFieldProblemAbstract.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/TestFieldProblemAbstract.java
index 5a0058d83..557115fa3 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/TestFieldProblemAbstract.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/TestFieldProblemAbstract.java
@@ -19,10 +19,10 @@ package org.apache.commons.math4.legacy.ode;
import java.lang.reflect.Array;
-import org.apache.commons.math4.legacy.Field;
-import org.apache.commons.math4.legacy.RealFieldElement;
+import org.apache.commons.math4.legacy.core.Field;
+import org.apache.commons.math4.legacy.core.RealFieldElement;
import org.apache.commons.math4.legacy.ode.events.FieldEventHandler;
-import org.apache.commons.math4.legacy.util.MathArrays;
+import org.apache.commons.math4.legacy.core.MathArrays;
/**
* This class is used as the base class of the problems that are
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/TestFieldProblemHandler.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/TestFieldProblemHandler.java
index dc192d91b..a4b42b32e 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/TestFieldProblemHandler.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/TestFieldProblemHandler.java
@@ -17,7 +17,7 @@
package org.apache.commons.math4.legacy.ode;
-import org.apache.commons.math4.legacy.RealFieldElement;
+import org.apache.commons.math4.legacy.core.RealFieldElement;
import org.apache.commons.math4.legacy.exception.MaxCountExceededException;
import org.apache.commons.math4.legacy.ode.sampling.FieldStepHandler;
import org.apache.commons.math4.legacy.ode.sampling.FieldStepInterpolator;
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/TestProblem1.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/TestProblem1.java
index 2e759a53b..3735d6136 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/TestProblem1.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/TestProblem1.java
@@ -17,7 +17,7 @@
package org.apache.commons.math4.legacy.ode;
-import org.apache.commons.math4.legacy.util.FastMath;
+import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
/**
* This class is used in the junit tests for the ODE integrators.
@@ -64,7 +64,7 @@ public class TestProblem1
@Override
public double[] computeTheoreticalState(double t) {
- double c = FastMath.exp (getInitialTime() - t);
+ double c = AccurateMath.exp (getInitialTime() - t);
for (int i = 0; i < getDimension(); ++i) {
y[i] = c * getInitialState()[i];
}
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/TestProblem2.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/TestProblem2.java
index fc7aa7aed..ad82ae778 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/TestProblem2.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/TestProblem2.java
@@ -17,7 +17,7 @@
package org.apache.commons.math4.legacy.ode;
-import org.apache.commons.math4.legacy.util.FastMath;
+import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
/**
* This class is used in the junit tests for the ODE integrators.
@@ -66,7 +66,7 @@ public class TestProblem2
@Override
public double[] computeTheoreticalState(double t) {
double t2 = t * t;
- double c = t2 + 2 * (FastMath.exp (-0.5 * t2) - 1);
+ double c = t2 + 2 * (AccurateMath.exp (-0.5 * t2) - 1);
for (int i = 0; i < getDimension(); ++i) {
y[i] = c;
}
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/TestProblem3.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/TestProblem3.java
index 73d0f294b..d49c44c85 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/TestProblem3.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/TestProblem3.java
@@ -17,7 +17,7 @@
package org.apache.commons.math4.legacy.ode;
-import org.apache.commons.math4.legacy.util.FastMath;
+import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
/**
* This class is used in the junit tests for the ODE integrators.
@@ -52,7 +52,7 @@ public class TestProblem3
public TestProblem3(double e) {
super();
this.e = e;
- double[] y0 = { 1 - e, 0, 0, FastMath.sqrt((1+e)/(1-e)) };
+ double[] y0 = { 1 - e, 0, 0, AccurateMath.sqrt((1+e)/(1-e)) };
setInitialConditions(0.0, y0);
setFinalConditions(20.0);
double[] errorScale = { 1.0, 1.0, 1.0, 1.0 };
@@ -72,7 +72,7 @@ public class TestProblem3
// current radius
double r2 = y[0] * y[0] + y[1] * y[1];
- double invR3 = 1 / (r2 * FastMath.sqrt(r2));
+ double invR3 = 1 / (r2 * AccurateMath.sqrt(r2));
// compute the derivatives
yDot[0] = y[2];
@@ -89,23 +89,23 @@ public class TestProblem3
double E = t;
double d = 0;
double corr = 999.0;
- for (int i = 0; (i < 50) && (FastMath.abs(corr) > 1.0e-12); ++i) {
- double f2 = e * FastMath.sin(E);
+ for (int i = 0; (i < 50) && (AccurateMath.abs(corr) > 1.0e-12); ++i) {
+ double f2 = e * AccurateMath.sin(E);
double f0 = d - f2;
- double f1 = 1 - e * FastMath.cos(E);
+ double f1 = 1 - e * AccurateMath.cos(E);
double f12 = f1 + f1;
corr = f0 * f12 / (f1 * f12 - f0 * f2);
d -= corr;
E = t + d;
}
- double cosE = FastMath.cos(E);
- double sinE = FastMath.sin(E);
+ double cosE = AccurateMath.cos(E);
+ double sinE = AccurateMath.sin(E);
y[0] = cosE - e;
- y[1] = FastMath.sqrt(1 - e * e) * sinE;
+ y[1] = AccurateMath.sqrt(1 - e * e) * sinE;
y[2] = -sinE / (1 - e * cosE);
- y[3] = FastMath.sqrt(1 - e * e) * cosE / (1 - e * cosE);
+ y[3] = AccurateMath.sqrt(1 - e * e) * cosE / (1 - e * cosE);
return y;
}
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/TestProblem4.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/TestProblem4.java
index cde38f053..411ce10df 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/TestProblem4.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/TestProblem4.java
@@ -18,7 +18,7 @@
package org.apache.commons.math4.legacy.ode;
import org.apache.commons.math4.legacy.ode.events.EventHandler;
-import org.apache.commons.math4.legacy.util.FastMath;
+import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
/**
* This class is used in the junit tests for the ODE integrators.
@@ -48,7 +48,7 @@ public class TestProblem4
public TestProblem4() {
super();
a = 1.2;
- double[] y0 = { FastMath.sin(a), FastMath.cos(a) };
+ double[] y0 = { AccurateMath.sin(a), AccurateMath.cos(a) };
setInitialConditions(0.0, y0);
setFinalConditions(15);
double[] errorScale = { 1.0, 0.0 };
@@ -68,10 +68,10 @@ public class TestProblem4
@Override
public double[] getTheoreticalEventsTimes() {
return new double[] {
- 1 * FastMath.PI - a,
- 2 * FastMath.PI - a,
- 3 * FastMath.PI - a,
- 4 * FastMath.PI - a,
+ 1 * AccurateMath.PI - a,
+ 2 * AccurateMath.PI - a,
+ 3 * AccurateMath.PI - a,
+ 4 * AccurateMath.PI - a,
12.0
};
}
@@ -84,9 +84,9 @@ public class TestProblem4
@Override
public double[] computeTheoreticalState(double t) {
- double sin = FastMath.sin(t + a);
- double cos = FastMath.cos(t + a);
- y[0] = FastMath.abs(sin);
+ double sin = AccurateMath.sin(t + a);
+ double cos = AccurateMath.cos(t + a);
+ y[0] = AccurateMath.abs(sin);
y[1] = (sin >= 0) ? cos : -cos;
return y;
}
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/TestProblemHandler.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/TestProblemHandler.java
index 1b5eceae2..9d1b6e0eb 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/TestProblemHandler.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/TestProblemHandler.java
@@ -20,7 +20,7 @@ package org.apache.commons.math4.legacy.ode;
import org.apache.commons.math4.legacy.exception.MaxCountExceededException;
import org.apache.commons.math4.legacy.ode.sampling.StepHandler;
import org.apache.commons.math4.legacy.ode.sampling.StepInterpolator;
-import org.apache.commons.math4.legacy.util.FastMath;
+import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
/**
* This class is used to handle steps for the test problems
@@ -74,17 +74,17 @@ public void init(double t0, double[] y0, double t) {
public void handleStep(StepInterpolator interpolator, boolean isLast) throws MaxCountExceededException {
double start = integrator.getCurrentStepStart();
- if (FastMath.abs((start - problem.getInitialTime()) / integrator.getCurrentSignedStepsize()) > 0.001) {
+ if (AccurateMath.abs((start - problem.getInitialTime()) / integrator.getCurrentSignedStepsize()) > 0.001) {
// multistep integrators do not handle the first steps themselves
// so we have to make sure the integrator we look at has really started its work
if (!Double.isNaN(expectedStepStart)) {
// the step should either start at the end of the integrator step
// or at an event if the step is split into several substeps
- double stepError = FastMath.max(maxTimeError, FastMath.abs(start - expectedStepStart));
+ double stepError = AccurateMath.max(maxTimeError, AccurateMath.abs(start - expectedStepStart));
for (double eventTime : problem.getTheoreticalEventsTimes()) {
- stepError = FastMath.min(stepError, FastMath.abs(start - eventTime));
+ stepError = AccurateMath.min(stepError, AccurateMath.abs(start - eventTime));
}
- maxTimeError = FastMath.max(maxTimeError, stepError);
+ maxTimeError = AccurateMath.max(maxTimeError, stepError);
}
expectedStepStart = start + integrator.getCurrentSignedStepsize();
}
@@ -99,8 +99,8 @@ public void handleStep(StepInterpolator interpolator, boolean isLast) throws Max
double[] interpolatedY = interpolator.getInterpolatedState();
double[] theoreticalY = problem.computeTheoreticalState(cT);
for (int i = 0; i < interpolatedY.length; ++i) {
- double error = FastMath.abs(interpolatedY[i] - theoreticalY[i]);
- lastError = FastMath.max(error, lastError);
+ double error = AccurateMath.abs(interpolatedY[i] - theoreticalY[i]);
+ lastError = AccurateMath.max(error, lastError);
}
lastTime = cT;
}
@@ -114,8 +114,8 @@ public void handleStep(StepInterpolator interpolator, boolean isLast) throws Max
// update the errors
for (int i = 0; i < interpolatedY.length; ++i) {
- double error = errorScale[i] * FastMath.abs(interpolatedY[i] - theoreticalY[i]);
- maxValueError = FastMath.max(error, maxValueError);
+ double error = errorScale[i] * AccurateMath.abs(interpolatedY[i] - theoreticalY[i]);
+ maxValueError = AccurateMath.max(error, maxValueError);
}
}
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/events/EventFilterTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/events/EventFilterTest.java
index 75188aee4..6ebe90b1a 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/events/EventFilterTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/events/EventFilterTest.java
@@ -26,7 +26,7 @@ import org.apache.commons.math4.legacy.ode.FirstOrderIntegrator;
import org.apache.commons.math4.legacy.ode.nonstiff.DormandPrince853Integrator;
import org.apache.commons.rng.UniformRandomProvider;
import org.apache.commons.rng.simple.RandomSource;
-import org.apache.commons.math4.legacy.util.FastMath;
+import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
import org.junit.Assert;
import org.junit.Test;
@@ -37,15 +37,15 @@ public class EventFilterTest {
// start point: g > 0
testHistory(FilterType.TRIGGER_ONLY_INCREASING_EVENTS,
- 0.5 * FastMath.PI, 30.5 * FastMath.PI, FastMath.PI, -1);
+ 0.5 * AccurateMath.PI, 30.5 * AccurateMath.PI, AccurateMath.PI, -1);
// start point: g = 0
testHistory(FilterType.TRIGGER_ONLY_INCREASING_EVENTS,
- 0, 30.5 * FastMath.PI, FastMath.PI, -1);
+ 0, 30.5 * AccurateMath.PI, AccurateMath.PI, -1);
// start point: g < 0
testHistory(FilterType.TRIGGER_ONLY_INCREASING_EVENTS,
- 1.5 * FastMath.PI, 30.5 * FastMath.PI, FastMath.PI, +1);
+ 1.5 * AccurateMath.PI, 30.5 * AccurateMath.PI, AccurateMath.PI, +1);
}
@@ -54,15 +54,15 @@ public class EventFilterTest {
// start point: g > 0
testHistory(FilterType.TRIGGER_ONLY_INCREASING_EVENTS,
- 0.5 * FastMath.PI, -30.5 * FastMath.PI, FastMath.PI, -1);
+ 0.5 * AccurateMath.PI, -30.5 * AccurateMath.PI, AccurateMath.PI, -1);
// start point: g = 0
testHistory(FilterType.TRIGGER_ONLY_INCREASING_EVENTS,
- 0, -30.5 * FastMath.PI, FastMath.PI, +1);
+ 0, -30.5 * AccurateMath.PI, AccurateMath.PI, +1);
// start point: g < 0
testHistory(FilterType.TRIGGER_ONLY_INCREASING_EVENTS,
- 1.5 * FastMath.PI, -30.5 * FastMath.PI, FastMath.PI, -1);
+ 1.5 * AccurateMath.PI, -30.5 * AccurateMath.PI, AccurateMath.PI, -1);
}
@@ -71,15 +71,15 @@ public class EventFilterTest {
// start point: g > 0
testHistory(FilterType.TRIGGER_ONLY_DECREASING_EVENTS,
- 0.5 * FastMath.PI, 30.5 * FastMath.PI, 0, +1);
+ 0.5 * AccurateMath.PI, 30.5 * AccurateMath.PI, 0, +1);
// start point: g = 0
testHistory(FilterType.TRIGGER_ONLY_DECREASING_EVENTS,
- 0, 30.5 * FastMath.PI, 0, +1);
+ 0, 30.5 * AccurateMath.PI, 0, +1);
// start point: g < 0
testHistory(FilterType.TRIGGER_ONLY_DECREASING_EVENTS,
- 1.5 * FastMath.PI, 30.5 * FastMath.PI, 0, +1);
+ 1.5 * AccurateMath.PI, 30.5 * AccurateMath.PI, 0, +1);
}
@@ -88,15 +88,15 @@ public class EventFilterTest {
// start point: g > 0
testHistory(FilterType.TRIGGER_ONLY_DECREASING_EVENTS,
- 0.5 * FastMath.PI, -30.5 * FastMath.PI, 0, -1);
+ 0.5 * AccurateMath.PI, -30.5 * AccurateMath.PI, 0, -1);
// start point: g = 0
testHistory(FilterType.TRIGGER_ONLY_DECREASING_EVENTS,
- 0, -30.5 * FastMath.PI, 0, -1);
+ 0, -30.5 * AccurateMath.PI, 0, -1);
// start point: g < 0
testHistory(FilterType.TRIGGER_ONLY_DECREASING_EVENTS,
- 1.5 * FastMath.PI, -30.5 * FastMath.PI, 0, +1);
+ 1.5 * AccurateMath.PI, -30.5 * AccurateMath.PI, 0, +1);
}
@@ -107,23 +107,23 @@ public class EventFilterTest {
eventFilter.init(t0, new double[] {1.0, 0.0}, t1);
// first pass to set up switches history for a long period
- double h = FastMath.copySign(0.05, t1 - t0);
- double n = (int) FastMath.floor((t1 - t0) / h);
+ double h = AccurateMath.copySign(0.05, t1 - t0);
+ double n = (int) AccurateMath.floor((t1 - t0) / h);
for (int i = 0; i < n; ++i) {
double t = t0 + i * h;
- eventFilter.g(t, new double[] { FastMath.sin(t), FastMath.cos(t) });
+ eventFilter.g(t, new double[] { AccurateMath.sin(t), AccurateMath.cos(t) });
}
// verify old events are preserved, even if randomly accessed
UniformRandomProvider rng = RandomSource.create(RandomSource.TWO_CMRES, 0xb0e7401265af8cd3l);
for (int i = 0; i < 5000; i++) {
double t = t0 + (t1 - t0) * rng.nextDouble();
- double g = eventFilter.g(t, new double[] { FastMath.sin(t), FastMath.cos(t) });
- int turn = (int) FastMath.floor((t - refSwitch) / (2 * FastMath.PI));
+ double g = eventFilter.g(t, new double[] { AccurateMath.sin(t), AccurateMath.cos(t) });
+ int turn = (int) AccurateMath.floor((t - refSwitch) / (2 * AccurateMath.PI));
if (turn % 2 == 0) {
- Assert.assertEquals( signEven * FastMath.sin(t), g, 1.0e-10);
+ Assert.assertEquals( signEven * AccurateMath.sin(t), g, 1.0e-10);
} else {
- Assert.assertEquals(-signEven * FastMath.sin(t), g, 1.0e-10);
+ Assert.assertEquals(-signEven * AccurateMath.sin(t), g, 1.0e-10);
}
}
@@ -144,8 +144,8 @@ public class EventFilterTest {
FilterType.TRIGGER_ONLY_INCREASING_EVENTS),
0.1, e, 100,
new BracketingNthOrderBrentSolver(1.0e-7, 5));
- double t0 = 0.5 * FastMath.PI;
- double tEnd = 5.5 * FastMath.PI;
+ double t0 = 0.5 * AccurateMath.PI;
+ double tEnd = 5.5 * AccurateMath.PI;
double[] y = { 0.0, 1.0 };
Assert.assertEquals(tEnd,
integrator.integrate(new SineCosine(), t0, y, tEnd, y),
@@ -171,8 +171,8 @@ public class EventFilterTest {
FilterType.TRIGGER_ONLY_DECREASING_EVENTS),
0.1, e, 1000,
new BracketingNthOrderBrentSolver(1.0e-7, 5));
- double t0 = 0.5 * FastMath.PI;
- double tEnd = 5.5 * FastMath.PI;
+ double t0 = 0.5 * AccurateMath.PI;
+ double tEnd = 5.5 * AccurateMath.PI;
double[] y = { 0.0, 1.0 };
Assert.assertEquals(tEnd,
integrator.integrate(new SineCosine(), t0, y, tEnd, y),
@@ -203,8 +203,8 @@ public class EventFilterTest {
FilterType.TRIGGER_ONLY_DECREASING_EVENTS),
0.1, e, 1000,
new BracketingNthOrderBrentSolver(1.0e-7, 5));
- double t0 = 0.5 * FastMath.PI;
- double tEnd = 5.5 * FastMath.PI;
+ double t0 = 0.5 * AccurateMath.PI;
+ double tEnd = 5.5 * AccurateMath.PI;
double[] y = { 0.0, 1.0 };
Assert.assertEquals(tEnd,
integrator.integrate(new SineCosine(), t0, y, tEnd, y),
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/nonstiff/AbstractEmbeddedRungeKuttaFieldIntegratorTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/nonstiff/AbstractEmbeddedRungeKuttaFieldIntegratorTest.java
index 77b80b75a..e73589538 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/nonstiff/AbstractEmbeddedRungeKuttaFieldIntegratorTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/nonstiff/AbstractEmbeddedRungeKuttaFieldIntegratorTest.java
@@ -18,8 +18,8 @@
package org.apache.commons.math4.legacy.ode.nonstiff;
-import org.apache.commons.math4.legacy.Field;
-import org.apache.commons.math4.legacy.RealFieldElement;
+import org.apache.commons.math4.legacy.core.Field;
+import org.apache.commons.math4.legacy.core.RealFieldElement;
import org.apache.commons.math4.legacy.analysis.differentiation.DerivativeStructure;
import org.apache.commons.math4.legacy.exception.DimensionMismatchException;
import org.apache.commons.math4.legacy.exception.MaxCountExceededException;
@@ -39,8 +39,8 @@ import org.apache.commons.math4.legacy.ode.events.Action;
import org.apache.commons.math4.legacy.ode.events.FieldEventHandler;
import org.apache.commons.math4.legacy.ode.sampling.FieldStepHandler;
import org.apache.commons.math4.legacy.ode.sampling.FieldStepInterpolator;
-import org.apache.commons.math4.legacy.util.FastMath;
-import org.apache.commons.math4.legacy.util.MathArrays;
+import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
+import org.apache.commons.math4.legacy.core.MathArrays;
import org.junit.Assert;
import org.junit.Test;
@@ -122,7 +122,7 @@ public abstract class AbstractEmbeddedRungeKuttaFieldIntegratorTest {
if (regularArray[i] == 0) {
Assert.assertTrue(0.0 == fieldArray[i].getReal());
} else {
- Assert.assertEquals(regularArray[i], fieldArray[i].getReal(), FastMath.ulp(regularArray[i]));
+ Assert.assertEquals(regularArray[i], fieldArray[i].getReal(), AccurateMath.ulp(regularArray[i]));
}
}
}
@@ -212,7 +212,7 @@ public abstract class AbstractEmbeddedRungeKuttaFieldIntegratorTest {
TestFieldProblem1 pb = new TestFieldProblem1<>(field);
double minStep = 0;
double maxStep = pb.getFinalTime().subtract(pb.getInitialState().getTime()).getReal();
- double scalAbsoluteTolerance = FastMath.pow(10.0, i);
+ double scalAbsoluteTolerance = AccurateMath.pow(10.0, i);
double scalRelativeTolerance = 0.01 * scalAbsoluteTolerance;
FirstOrderFieldIntegrator integ = createIntegrator(field, minStep, maxStep,
@@ -577,7 +577,7 @@ public abstract class AbstractEmbeddedRungeKuttaFieldIntegratorTest {
public double[] theoreticalY(final double t) {
final double theta = omega.getReal() * t + alpha.getReal();
return new double[] {
- r.getReal() * FastMath.sin(theta), r.getReal() * FastMath.cos(theta)
+ r.getReal() * AccurateMath.sin(theta), r.getReal() * AccurateMath.cos(theta)
};
}
@@ -585,8 +585,8 @@ public abstract class AbstractEmbeddedRungeKuttaFieldIntegratorTest {
// intermediate angle and state
final double theta = omega.getReal() * t + alpha.getReal();
- final double sin = FastMath.sin(theta);
- final double cos = FastMath.cos(theta);
+ final double sin = AccurateMath.sin(theta);
+ final double cos = AccurateMath.cos(theta);
final double y0 = r.getReal() * sin;
final double y1 = r.getReal() * cos;
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/nonstiff/AbstractRungeKuttaFieldIntegratorTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/nonstiff/AbstractRungeKuttaFieldIntegratorTest.java
index c98edc0df..f2a408aa8 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/nonstiff/AbstractRungeKuttaFieldIntegratorTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/nonstiff/AbstractRungeKuttaFieldIntegratorTest.java
@@ -20,8 +20,8 @@ package org.apache.commons.math4.legacy.ode.nonstiff;
import java.lang.reflect.Array;
-import org.apache.commons.math4.legacy.Field;
-import org.apache.commons.math4.legacy.RealFieldElement;
+import org.apache.commons.math4.legacy.core.Field;
+import org.apache.commons.math4.legacy.core.RealFieldElement;
import org.apache.commons.math4.legacy.analysis.differentiation.DerivativeStructure;
import org.apache.commons.math4.legacy.exception.DimensionMismatchException;
import org.apache.commons.math4.legacy.exception.MaxCountExceededException;
@@ -44,8 +44,8 @@ import org.apache.commons.math4.legacy.ode.events.FieldEventHandler;
import org.apache.commons.math4.legacy.ode.sampling.FieldStepHandler;
import org.apache.commons.math4.legacy.ode.sampling.FieldStepInterpolator;
import org.apache.commons.math4.legacy.ode.sampling.StepInterpolatorTestUtils;
-import org.apache.commons.math4.legacy.util.FastMath;
-import org.apache.commons.math4.legacy.util.MathArrays;
+import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
+import org.apache.commons.math4.legacy.core.MathArrays;
import org.junit.Assert;
import org.junit.Test;
@@ -108,7 +108,7 @@ public abstract class AbstractRungeKuttaFieldIntegratorTest {
if (regularArray[i] == 0) {
Assert.assertTrue(0.0 == fieldArray[i].getReal());
} else {
- Assert.assertEquals(regularArray[i], fieldArray[i].getReal(), FastMath.ulp(regularArray[i]));
+ Assert.assertEquals(regularArray[i], fieldArray[i].getReal(), AccurateMath.ulp(regularArray[i]));
}
}
}
@@ -250,7 +250,7 @@ public abstract class AbstractRungeKuttaFieldIntegratorTest {
T previousTimeError = null;
for (int i = 4; i < 10; ++i) {
- T step = pb.getFinalTime().subtract(pb.getInitialState().getTime()).multiply(FastMath.pow(2.0, -i));
+ T step = pb.getFinalTime().subtract(pb.getInitialState().getTime()).multiply(AccurateMath.pow(2.0, -i));
RungeKuttaFieldIntegrator integ = createIntegrator(field, step);
TestFieldProblemHandler handler = new TestFieldProblemHandler<>(pb, integ);
@@ -497,8 +497,8 @@ public abstract class AbstractRungeKuttaFieldIntegratorTest {
@Override
public T[] computeDerivatives(T t, T[] y) {
- Assert.assertTrue(t.getReal() >= FastMath.nextAfter(t0.getReal(), Double.NEGATIVE_INFINITY));
- Assert.assertTrue(t.getReal() <= FastMath.nextAfter(t.getReal(), Double.POSITIVE_INFINITY));
+ Assert.assertTrue(t.getReal() >= AccurateMath.nextAfter(t0.getReal(), Double.NEGATIVE_INFINITY));
+ Assert.assertTrue(t.getReal() <= AccurateMath.nextAfter(t.getReal(), Double.POSITIVE_INFINITY));
T[] yDot = MathArrays.buildArray(field, 1);
yDot[0] = y[0].multiply(-100.0);
return yDot;
@@ -643,7 +643,7 @@ public abstract class AbstractRungeKuttaFieldIntegratorTest {
public double[] theoreticalY(final double t) {
final double theta = omega.getReal() * t + alpha.getReal();
return new double[] {
- r.getReal() * FastMath.sin(theta), r.getReal() * FastMath.cos(theta)
+ r.getReal() * AccurateMath.sin(theta), r.getReal() * AccurateMath.cos(theta)
};
}
@@ -651,8 +651,8 @@ public abstract class AbstractRungeKuttaFieldIntegratorTest {
// intermediate angle and state
final double theta = omega.getReal() * t + alpha.getReal();
- final double sin = FastMath.sin(theta);
- final double cos = FastMath.cos(theta);
+ final double sin = AccurateMath.sin(theta);
+ final double cos = AccurateMath.cos(theta);
final double y0 = r.getReal() * sin;
final double y1 = r.getReal() * cos;
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/nonstiff/AdamsBashforthFieldIntegratorTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/nonstiff/AdamsBashforthFieldIntegratorTest.java
index 9a542beab..bfe126ae9 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/nonstiff/AdamsBashforthFieldIntegratorTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/nonstiff/AdamsBashforthFieldIntegratorTest.java
@@ -18,8 +18,8 @@
package org.apache.commons.math4.legacy.ode.nonstiff;
-import org.apache.commons.math4.legacy.Field;
-import org.apache.commons.math4.legacy.RealFieldElement;
+import org.apache.commons.math4.legacy.core.Field;
+import org.apache.commons.math4.legacy.core.RealFieldElement;
import org.apache.commons.math4.legacy.exception.MathIllegalStateException;
import org.apache.commons.math4.legacy.exception.MaxCountExceededException;
import org.apache.commons.math4.legacy.exception.NumberIsTooSmallException;
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/nonstiff/AdamsBashforthIntegratorTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/nonstiff/AdamsBashforthIntegratorTest.java
index 86fbec8ff..a9b268812 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/nonstiff/AdamsBashforthIntegratorTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/nonstiff/AdamsBashforthIntegratorTest.java
@@ -37,7 +37,7 @@ import org.apache.commons.math4.legacy.ode.TestProblemAbstract;
import org.apache.commons.math4.legacy.ode.TestProblemHandler;
import org.apache.commons.math4.legacy.ode.sampling.StepHandler;
import org.apache.commons.math4.legacy.ode.sampling.StepInterpolator;
-import org.apache.commons.math4.legacy.util.FastMath;
+import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
import org.junit.Assert;
import org.junit.Test;
@@ -81,7 +81,7 @@ public class AdamsBashforthIntegratorTest {
TestProblem1 pb = new TestProblem1();
double minStep = 0;
double maxStep = pb.getFinalTime() - pb.getInitialTime();
- double scalAbsoluteTolerance = FastMath.pow(10.0, i);
+ double scalAbsoluteTolerance = AccurateMath.pow(10.0, i);
double scalRelativeTolerance = 0.01 * scalAbsoluteTolerance;
FirstOrderIntegrator integ = new AdamsBashforthIntegrator(4, minStep, maxStep,
@@ -128,7 +128,7 @@ public class AdamsBashforthIntegratorTest {
public void backward() throws DimensionMismatchException, NumberIsTooSmallException, MaxCountExceededException, NoBracketingException {
TestProblem5 pb = new TestProblem5();
- double range = FastMath.abs(pb.getFinalTime() - pb.getInitialTime());
+ double range = AccurateMath.abs(pb.getFinalTime() - pb.getInitialTime());
AdamsBashforthIntegrator integ = new AdamsBashforthIntegrator(4, 0, range, 1.0e-12, 1.0e-12);
integ.setStarterIntegrator(new PerfectStarter(pb, (integ.getNSteps() + 5) / 2));
@@ -146,7 +146,7 @@ public class AdamsBashforthIntegratorTest {
@Test
public void polynomial() throws DimensionMismatchException, NumberIsTooSmallException, MaxCountExceededException, NoBracketingException {
TestProblem6 pb = new TestProblem6();
- double range = FastMath.abs(pb.getFinalTime() - pb.getInitialTime());
+ double range = AccurateMath.abs(pb.getFinalTime() - pb.getInitialTime());
for (int nSteps = 2; nSteps < 8; ++nSteps) {
AdamsBashforthIntegrator integ =
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/nonstiff/AdamsFieldIntegratorAbstractTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/nonstiff/AdamsFieldIntegratorAbstractTest.java
index f0a3cd3cb..6e43d280e 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/nonstiff/AdamsFieldIntegratorAbstractTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/nonstiff/AdamsFieldIntegratorAbstractTest.java
@@ -18,8 +18,8 @@
package org.apache.commons.math4.legacy.ode.nonstiff;
-import org.apache.commons.math4.legacy.Field;
-import org.apache.commons.math4.legacy.RealFieldElement;
+import org.apache.commons.math4.legacy.core.Field;
+import org.apache.commons.math4.legacy.core.RealFieldElement;
import org.apache.commons.math4.legacy.exception.MathIllegalStateException;
import org.apache.commons.math4.legacy.exception.MaxCountExceededException;
import org.apache.commons.math4.legacy.exception.NumberIsTooSmallException;
@@ -36,7 +36,7 @@ import org.apache.commons.math4.legacy.ode.TestFieldProblemAbstract;
import org.apache.commons.math4.legacy.ode.TestFieldProblemHandler;
import org.apache.commons.math4.legacy.ode.sampling.FieldStepHandler;
import org.apache.commons.math4.legacy.ode.sampling.FieldStepInterpolator;
-import org.apache.commons.math4.legacy.util.FastMath;
+import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
import org.junit.Assert;
import org.junit.Test;
@@ -81,7 +81,7 @@ public abstract class AdamsFieldIntegratorAbstractTest {
TestFieldProblem1 pb = new TestFieldProblem1<>(field);
double minStep = 0;
double maxStep = pb.getFinalTime().subtract(pb.getInitialState().getTime()).getReal();
- double scalAbsoluteTolerance = FastMath.pow(10.0, i);
+ double scalAbsoluteTolerance = AccurateMath.pow(10.0, i);
double scalRelativeTolerance = 0.01 * scalAbsoluteTolerance;
FirstOrderFieldIntegrator integ = createIntegrator(field, 4, minStep, maxStep,
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/nonstiff/AdamsMoultonFieldIntegratorTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/nonstiff/AdamsMoultonFieldIntegratorTest.java
index 13c851541..c8b8918a7 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/nonstiff/AdamsMoultonFieldIntegratorTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/nonstiff/AdamsMoultonFieldIntegratorTest.java
@@ -18,8 +18,8 @@
package org.apache.commons.math4.legacy.ode.nonstiff;
-import org.apache.commons.math4.legacy.Field;
-import org.apache.commons.math4.legacy.RealFieldElement;
+import org.apache.commons.math4.legacy.core.Field;
+import org.apache.commons.math4.legacy.core.RealFieldElement;
import org.apache.commons.math4.legacy.exception.MathIllegalStateException;
import org.apache.commons.math4.legacy.exception.MaxCountExceededException;
import org.apache.commons.math4.legacy.exception.NumberIsTooSmallException;
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/nonstiff/AdamsMoultonIntegratorTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/nonstiff/AdamsMoultonIntegratorTest.java
index e0c94f3be..8d7e59cb9 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/nonstiff/AdamsMoultonIntegratorTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/nonstiff/AdamsMoultonIntegratorTest.java
@@ -35,7 +35,7 @@ import org.apache.commons.math4.legacy.ode.TestProblemAbstract;
import org.apache.commons.math4.legacy.ode.TestProblemHandler;
import org.apache.commons.math4.legacy.ode.sampling.StepHandler;
import org.apache.commons.math4.legacy.ode.sampling.StepInterpolator;
-import org.apache.commons.math4.legacy.util.FastMath;
+import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
import org.junit.Assert;
import org.junit.Test;
@@ -85,7 +85,7 @@ public class AdamsMoultonIntegratorTest {
TestProblem1 pb = new TestProblem1();
double minStep = 0;
double maxStep = pb.getFinalTime() - pb.getInitialTime();
- double scalAbsoluteTolerance = FastMath.pow(10.0, i);
+ double scalAbsoluteTolerance = AccurateMath.pow(10.0, i);
double scalRelativeTolerance = 0.01 * scalAbsoluteTolerance;
FirstOrderIntegrator integ = new AdamsMoultonIntegrator(4, minStep, maxStep,
@@ -137,7 +137,7 @@ public class AdamsMoultonIntegratorTest {
MaxCountExceededException, NoBracketingException {
TestProblem5 pb = new TestProblem5();
- double range = FastMath.abs(pb.getFinalTime() - pb.getInitialTime());
+ double range = AccurateMath.abs(pb.getFinalTime() - pb.getInitialTime());
FirstOrderIntegrator integ = new AdamsMoultonIntegrator(4, 0, range, 1.0e-12, 1.0e-12);
TestProblemHandler handler = new TestProblemHandler(pb, integ);
@@ -156,7 +156,7 @@ public class AdamsMoultonIntegratorTest {
throws DimensionMismatchException, NumberIsTooSmallException,
MaxCountExceededException, NoBracketingException {
TestProblem6 pb = new TestProblem6();
- double range = FastMath.abs(pb.getFinalTime() - pb.getInitialTime());
+ double range = AccurateMath.abs(pb.getFinalTime() - pb.getInitialTime());
for (int nSteps = 2; nSteps < 8; ++nSteps) {
AdamsMoultonIntegrator integ =
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/nonstiff/ClassicalRungKuttaFieldStepInterpolatorTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/nonstiff/ClassicalRungKuttaFieldStepInterpolatorTest.java
index 0c2279a44..c317b1b68 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/nonstiff/ClassicalRungKuttaFieldStepInterpolatorTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/nonstiff/ClassicalRungKuttaFieldStepInterpolatorTest.java
@@ -18,8 +18,8 @@
package org.apache.commons.math4.legacy.ode.nonstiff;
-import org.apache.commons.math4.legacy.Field;
-import org.apache.commons.math4.legacy.RealFieldElement;
+import org.apache.commons.math4.legacy.core.Field;
+import org.apache.commons.math4.legacy.core.RealFieldElement;
import org.apache.commons.math4.legacy.ode.FieldEquationsMapper;
import org.apache.commons.math4.legacy.ode.FieldODEStateAndDerivative;
import org.junit.Test;
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/nonstiff/ClassicalRungeKuttaFieldIntegratorTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/nonstiff/ClassicalRungeKuttaFieldIntegratorTest.java
index c698a44f1..4958fb51f 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/nonstiff/ClassicalRungeKuttaFieldIntegratorTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/nonstiff/ClassicalRungeKuttaFieldIntegratorTest.java
@@ -18,8 +18,8 @@
package org.apache.commons.math4.legacy.ode.nonstiff;
-import org.apache.commons.math4.legacy.Field;
-import org.apache.commons.math4.legacy.RealFieldElement;
+import org.apache.commons.math4.legacy.core.Field;
+import org.apache.commons.math4.legacy.core.RealFieldElement;
public class ClassicalRungeKuttaFieldIntegratorTest extends RungeKuttaFieldIntegratorAbstractTest {
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/nonstiff/ClassicalRungeKuttaIntegratorTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/nonstiff/ClassicalRungeKuttaIntegratorTest.java
index 0c5efb26b..bf547f91c 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/nonstiff/ClassicalRungeKuttaIntegratorTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/nonstiff/ClassicalRungeKuttaIntegratorTest.java
@@ -35,7 +35,7 @@ import org.apache.commons.math4.legacy.ode.TestProblemHandler;
import org.apache.commons.math4.legacy.ode.events.EventHandler;
import org.apache.commons.math4.legacy.ode.sampling.StepHandler;
import org.apache.commons.math4.legacy.ode.sampling.StepInterpolator;
-import org.apache.commons.math4.legacy.util.FastMath;
+import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
import org.junit.Assert;
import org.junit.Test;
@@ -74,7 +74,7 @@ public class ClassicalRungeKuttaIntegratorTest {
double finalT = integrator.integrate(ode, t0, y0, tEvent, y);
Assert.assertEquals(tEvent, finalT, 5.0e-6);
for (int i = 0; i < y.length; ++i) {
- Assert.assertEquals(y0[i] * FastMath.exp(k[i] * (finalT - t0)), y[i], 1.0e-9);
+ Assert.assertEquals(y0[i] * AccurateMath.exp(k[i] * (finalT - t0)), y[i], 1.0e-9);
}
integrator.addEventHandler(new EventHandler() {
@@ -101,7 +101,7 @@ public class ClassicalRungeKuttaIntegratorTest {
finalT = integrator.integrate(ode, t0, y0, tEvent + 120, y);
Assert.assertEquals(tEvent + 120, finalT, 5.0e-6);
for (int i = 0; i < y.length; ++i) {
- Assert.assertEquals(y0[i] * FastMath.exp(k[i] * (finalT - t0)), y[i], 1.0e-9);
+ Assert.assertEquals(y0[i] * AccurateMath.exp(k[i] * (finalT - t0)), y[i], 1.0e-9);
}
}
@@ -150,7 +150,7 @@ public class ClassicalRungeKuttaIntegratorTest {
double previousTimeError = Double.NaN;
for (int i = 4; i < 10; ++i) {
- double step = (pb.getFinalTime() - pb.getInitialTime()) * FastMath.pow(2.0, -i);
+ double step = (pb.getFinalTime() - pb.getInitialTime()) * AccurateMath.pow(2.0, -i);
FirstOrderIntegrator integ = new ClassicalRungeKuttaIntegrator(step);
TestProblemHandler handler = new TestProblemHandler(pb, integ);
@@ -169,13 +169,13 @@ public class ClassicalRungeKuttaIntegratorTest {
double error = handler.getMaximalValueError();
if (i > 4) {
- Assert.assertTrue(error < 1.01 * FastMath.abs(previousValueError));
+ Assert.assertTrue(error < 1.01 * AccurateMath.abs(previousValueError));
}
previousValueError = error;
double timeError = handler.getMaximalTimeError();
if (i > 4) {
- Assert.assertTrue(timeError <= FastMath.abs(previousTimeError));
+ Assert.assertTrue(timeError <= AccurateMath.abs(previousTimeError));
}
previousTimeError = timeError;
@@ -233,7 +233,7 @@ public class ClassicalRungeKuttaIntegratorTest {
MaxCountExceededException, NoBracketingException {
TestProblem5 pb = new TestProblem5();
- double step = FastMath.abs(pb.getFinalTime() - pb.getInitialTime()) * 0.001;
+ double step = AccurateMath.abs(pb.getFinalTime() - pb.getInitialTime()) * 0.001;
FirstOrderIntegrator integ = new ClassicalRungeKuttaIntegrator(step);
TestProblemHandler handler = new TestProblemHandler(pb, integ);
@@ -340,8 +340,8 @@ public class ClassicalRungeKuttaIntegratorTest {
@Override
public void computeDerivatives(double t, double[] y, double[] yDot) {
- Assert.assertTrue(t >= FastMath.nextAfter(start, Double.NEGATIVE_INFINITY));
- Assert.assertTrue(t <= FastMath.nextAfter(end, Double.POSITIVE_INFINITY));
+ Assert.assertTrue(t >= AccurateMath.nextAfter(start, Double.NEGATIVE_INFINITY));
+ Assert.assertTrue(t <= AccurateMath.nextAfter(end, Double.POSITIVE_INFINITY));
yDot[0] = -100.0 * y[0];
}
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/nonstiff/Decimal64.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/nonstiff/Decimal64.java
index 11f2328b8..1e5af3f3b 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/nonstiff/Decimal64.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/nonstiff/Decimal64.java
@@ -16,10 +16,10 @@
*/
package org.apache.commons.math4.legacy.ode.nonstiff;
-import org.apache.commons.math4.legacy.util.FastMath;
+import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
import org.apache.commons.numbers.arrays.LinearCombination;
-import org.apache.commons.math4.legacy.Field;
-import org.apache.commons.math4.legacy.RealFieldElement;
+import org.apache.commons.math4.legacy.core.Field;
+import org.apache.commons.math4.legacy.core.RealFieldElement;
import org.apache.commons.math4.legacy.exception.DimensionMismatchException;
/**
@@ -358,7 +358,7 @@ public class Decimal64 extends Number
*/
@Override
public Decimal64 remainder(final double a) {
- return new Decimal64(FastMath.IEEEremainder(value, a));
+ return new Decimal64(AccurateMath.IEEEremainder(value, a));
}
/** {@inheritDoc}
@@ -366,7 +366,7 @@ public class Decimal64 extends Number
*/
@Override
public Decimal64 remainder(final Decimal64 a) {
- return new Decimal64(FastMath.IEEEremainder(value, a.value));
+ return new Decimal64(AccurateMath.IEEEremainder(value, a.value));
}
/** {@inheritDoc}
@@ -374,7 +374,7 @@ public class Decimal64 extends Number
*/
@Override
public Decimal64 abs() {
- return new Decimal64(FastMath.abs(value));
+ return new Decimal64(AccurateMath.abs(value));
}
/** {@inheritDoc}
@@ -382,7 +382,7 @@ public class Decimal64 extends Number
*/
@Override
public Decimal64 ceil() {
- return new Decimal64(FastMath.ceil(value));
+ return new Decimal64(AccurateMath.ceil(value));
}
/** {@inheritDoc}
@@ -390,7 +390,7 @@ public class Decimal64 extends Number
*/
@Override
public Decimal64 floor() {
- return new Decimal64(FastMath.floor(value));
+ return new Decimal64(AccurateMath.floor(value));
}
/** {@inheritDoc}
@@ -398,7 +398,7 @@ public class Decimal64 extends Number
*/
@Override
public Decimal64 rint() {
- return new Decimal64(FastMath.rint(value));
+ return new Decimal64(AccurateMath.rint(value));
}
/** {@inheritDoc}
@@ -406,7 +406,7 @@ public class Decimal64 extends Number
*/
@Override
public long round() {
- return FastMath.round(value);
+ return AccurateMath.round(value);
}
/** {@inheritDoc}
@@ -414,7 +414,7 @@ public class Decimal64 extends Number
*/
@Override
public Decimal64 signum() {
- return new Decimal64(FastMath.signum(value));
+ return new Decimal64(AccurateMath.signum(value));
}
/** {@inheritDoc}
@@ -422,7 +422,7 @@ public class Decimal64 extends Number
*/
@Override
public Decimal64 copySign(final Decimal64 sign) {
- return new Decimal64(FastMath.copySign(value, sign.value));
+ return new Decimal64(AccurateMath.copySign(value, sign.value));
}
/** {@inheritDoc}
@@ -430,7 +430,7 @@ public class Decimal64 extends Number
*/
@Override
public Decimal64 copySign(final double sign) {
- return new Decimal64(FastMath.copySign(value, sign));
+ return new Decimal64(AccurateMath.copySign(value, sign));
}
/** {@inheritDoc}
@@ -438,7 +438,7 @@ public class Decimal64 extends Number
*/
@Override
public Decimal64 scalb(final int n) {
- return new Decimal64(FastMath.scalb(value, n));
+ return new Decimal64(AccurateMath.scalb(value, n));
}
/** {@inheritDoc}
@@ -446,7 +446,7 @@ public class Decimal64 extends Number
*/
@Override
public Decimal64 hypot(final Decimal64 y) {
- return new Decimal64(FastMath.hypot(value, y.value));
+ return new Decimal64(AccurateMath.hypot(value, y.value));
}
/** {@inheritDoc}
@@ -454,7 +454,7 @@ public class Decimal64 extends Number
*/
@Override
public Decimal64 sqrt() {
- return new Decimal64(FastMath.sqrt(value));
+ return new Decimal64(AccurateMath.sqrt(value));
}
/** {@inheritDoc}
@@ -462,7 +462,7 @@ public class Decimal64 extends Number
*/
@Override
public Decimal64 cbrt() {
- return new Decimal64(FastMath.cbrt(value));
+ return new Decimal64(AccurateMath.cbrt(value));
}
/** {@inheritDoc}
@@ -471,9 +471,9 @@ public class Decimal64 extends Number
@Override
public Decimal64 rootN(final int n) {
if (value < 0) {
- return new Decimal64(-FastMath.pow(-value, 1.0 / n));
+ return new Decimal64(-AccurateMath.pow(-value, 1.0 / n));
} else {
- return new Decimal64(FastMath.pow(value, 1.0 / n));
+ return new Decimal64(AccurateMath.pow(value, 1.0 / n));
}
}
@@ -482,7 +482,7 @@ public class Decimal64 extends Number
*/
@Override
public Decimal64 pow(final double p) {
- return new Decimal64(FastMath.pow(value, p));
+ return new Decimal64(AccurateMath.pow(value, p));
}
/** {@inheritDoc}
@@ -490,7 +490,7 @@ public class Decimal64 extends Number
*/
@Override
public Decimal64 pow(final int n) {
- return new Decimal64(FastMath.pow(value, n));
+ return new Decimal64(AccurateMath.pow(value, n));
}
/** {@inheritDoc}
@@ -498,7 +498,7 @@ public class Decimal64 extends Number
*/
@Override
public Decimal64 pow(final Decimal64 e) {
- return new Decimal64(FastMath.pow(value, e.value));
+ return new Decimal64(AccurateMath.pow(value, e.value));
}
/** {@inheritDoc}
@@ -506,7 +506,7 @@ public class Decimal64 extends Number
*/
@Override
public Decimal64 exp() {
- return new Decimal64(FastMath.exp(value));
+ return new Decimal64(AccurateMath.exp(value));
}
/** {@inheritDoc}
@@ -514,7 +514,7 @@ public class Decimal64 extends Number
*/
@Override
public Decimal64 expm1() {
- return new Decimal64(FastMath.expm1(value));
+ return new Decimal64(AccurateMath.expm1(value));
}
/** {@inheritDoc}
@@ -522,7 +522,7 @@ public class Decimal64 extends Number
*/
@Override
public Decimal64 log() {
- return new Decimal64(FastMath.log(value));
+ return new Decimal64(AccurateMath.log(value));
}
/** {@inheritDoc}
@@ -530,7 +530,7 @@ public class Decimal64 extends Number
*/
@Override
public Decimal64 log1p() {
- return new Decimal64(FastMath.log1p(value));
+ return new Decimal64(AccurateMath.log1p(value));
}
/** Base 10 logarithm.
@@ -539,7 +539,7 @@ public class Decimal64 extends Number
*/
@Override
public Decimal64 log10() {
- return new Decimal64(FastMath.log10(value));
+ return new Decimal64(AccurateMath.log10(value));
}
/** {@inheritDoc}
@@ -547,7 +547,7 @@ public class Decimal64 extends Number
*/
@Override
public Decimal64 cos() {
- return new Decimal64(FastMath.cos(value));
+ return new Decimal64(AccurateMath.cos(value));
}
/** {@inheritDoc}
@@ -555,7 +555,7 @@ public class Decimal64 extends Number
*/
@Override
public Decimal64 sin() {
- return new Decimal64(FastMath.sin(value));
+ return new Decimal64(AccurateMath.sin(value));
}
/** {@inheritDoc}
@@ -563,7 +563,7 @@ public class Decimal64 extends Number
*/
@Override
public Decimal64 tan() {
- return new Decimal64(FastMath.tan(value));
+ return new Decimal64(AccurateMath.tan(value));
}
/** {@inheritDoc}
@@ -571,7 +571,7 @@ public class Decimal64 extends Number
*/
@Override
public Decimal64 acos() {
- return new Decimal64(FastMath.acos(value));
+ return new Decimal64(AccurateMath.acos(value));
}
/** {@inheritDoc}
@@ -579,7 +579,7 @@ public class Decimal64 extends Number
*/
@Override
public Decimal64 asin() {
- return new Decimal64(FastMath.asin(value));
+ return new Decimal64(AccurateMath.asin(value));
}
/** {@inheritDoc}
@@ -587,7 +587,7 @@ public class Decimal64 extends Number
*/
@Override
public Decimal64 atan() {
- return new Decimal64(FastMath.atan(value));
+ return new Decimal64(AccurateMath.atan(value));
}
/** {@inheritDoc}
@@ -595,7 +595,7 @@ public class Decimal64 extends Number
*/
@Override
public Decimal64 atan2(final Decimal64 x) {
- return new Decimal64(FastMath.atan2(value, x.value));
+ return new Decimal64(AccurateMath.atan2(value, x.value));
}
/** {@inheritDoc}
@@ -603,7 +603,7 @@ public class Decimal64 extends Number
*/
@Override
public Decimal64 cosh() {
- return new Decimal64(FastMath.cosh(value));
+ return new Decimal64(AccurateMath.cosh(value));
}
/** {@inheritDoc}
@@ -611,7 +611,7 @@ public class Decimal64 extends Number
*/
@Override
public Decimal64 sinh() {
- return new Decimal64(FastMath.sinh(value));
+ return new Decimal64(AccurateMath.sinh(value));
}
/** {@inheritDoc}
@@ -619,7 +619,7 @@ public class Decimal64 extends Number
*/
@Override
public Decimal64 tanh() {
- return new Decimal64(FastMath.tanh(value));
+ return new Decimal64(AccurateMath.tanh(value));
}
/** {@inheritDoc}
@@ -627,7 +627,7 @@ public class Decimal64 extends Number
*/
@Override
public Decimal64 acosh() {
- return new Decimal64(FastMath.acosh(value));
+ return new Decimal64(AccurateMath.acosh(value));
}
/** {@inheritDoc}
@@ -635,7 +635,7 @@ public class Decimal64 extends Number
*/
@Override
public Decimal64 asinh() {
- return new Decimal64(FastMath.asinh(value));
+ return new Decimal64(AccurateMath.asinh(value));
}
/** {@inheritDoc}
@@ -643,7 +643,7 @@ public class Decimal64 extends Number
*/
@Override
public Decimal64 atanh() {
- return new Decimal64(FastMath.atanh(value));
+ return new Decimal64(AccurateMath.atanh(value));
}
/** {@inheritDoc}
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/nonstiff/Decimal64Field.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/nonstiff/Decimal64Field.java
index 18cf38402..b83b5357c 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/nonstiff/Decimal64Field.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/nonstiff/Decimal64Field.java
@@ -16,8 +16,8 @@
*/
package org.apache.commons.math4.legacy.ode.nonstiff;
-import org.apache.commons.math4.legacy.Field;
-import org.apache.commons.math4.legacy.FieldElement;
+import org.apache.commons.math4.legacy.core.Field;
+import org.apache.commons.math4.legacy.core.FieldElement;
/**
* The field of double precision floating-point numbers.
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/nonstiff/Decimal64Test.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/nonstiff/Decimal64Test.java
index acb130461..4d9920121 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/nonstiff/Decimal64Test.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/nonstiff/Decimal64Test.java
@@ -16,7 +16,7 @@
*/
package org.apache.commons.math4.legacy.ode.nonstiff;
-import org.apache.commons.math4.legacy.ExtendedFieldElementAbstractTest;
+import org.apache.commons.math4.legacy.field.ExtendedFieldElementAbstractTest;
import org.apache.commons.math4.legacy.ode.nonstiff.Decimal64;
import org.junit.Assert;
import org.junit.Test;
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/nonstiff/DormandPrince54FieldIntegratorTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/nonstiff/DormandPrince54FieldIntegratorTest.java
index 70f646f91..89dc025eb 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/nonstiff/DormandPrince54FieldIntegratorTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/nonstiff/DormandPrince54FieldIntegratorTest.java
@@ -18,8 +18,8 @@
package org.apache.commons.math4.legacy.ode.nonstiff;
-import org.apache.commons.math4.legacy.Field;
-import org.apache.commons.math4.legacy.RealFieldElement;
+import org.apache.commons.math4.legacy.core.Field;
+import org.apache.commons.math4.legacy.core.RealFieldElement;
public class DormandPrince54FieldIntegratorTest extends EmbeddedRungeKuttaFieldIntegratorAbstractTest {
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/nonstiff/DormandPrince54FieldStepInterpolatorTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/nonstiff/DormandPrince54FieldStepInterpolatorTest.java
index a8bce6fc4..1c2d01432 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/nonstiff/DormandPrince54FieldStepInterpolatorTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/nonstiff/DormandPrince54FieldStepInterpolatorTest.java
@@ -18,8 +18,8 @@
package org.apache.commons.math4.legacy.ode.nonstiff;
-import org.apache.commons.math4.legacy.Field;
-import org.apache.commons.math4.legacy.RealFieldElement;
+import org.apache.commons.math4.legacy.core.Field;
+import org.apache.commons.math4.legacy.core.RealFieldElement;
import org.apache.commons.math4.legacy.ode.FieldEquationsMapper;
import org.apache.commons.math4.legacy.ode.FieldODEStateAndDerivative;
import org.junit.Test;
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/nonstiff/DormandPrince54IntegratorTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/nonstiff/DormandPrince54IntegratorTest.java
index 87d3be35d..fe39a6511 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/nonstiff/DormandPrince54IntegratorTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/nonstiff/DormandPrince54IntegratorTest.java
@@ -31,7 +31,7 @@ import org.apache.commons.math4.legacy.ode.TestProblemHandler;
import org.apache.commons.math4.legacy.ode.events.EventHandler;
import org.apache.commons.math4.legacy.ode.sampling.StepHandler;
import org.apache.commons.math4.legacy.ode.sampling.StepInterpolator;
-import org.apache.commons.math4.legacy.util.FastMath;
+import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
import org.junit.Assert;
import org.junit.Test;
@@ -80,7 +80,7 @@ public class DormandPrince54IntegratorTest {
TestProblemAbstract pb = new TestProblem5();
double minStep = 1.25;
- double maxStep = FastMath.abs(pb.getFinalTime() - pb.getInitialTime());
+ double maxStep = AccurateMath.abs(pb.getFinalTime() - pb.getInitialTime());
double scalAbsoluteTolerance = 6.0e-4;
double scalRelativeTolerance = 6.0e-4;
@@ -141,7 +141,7 @@ public class DormandPrince54IntegratorTest {
if (isLast) {
lastSeen = true;
double h = interpolator.getCurrentTime() - interpolator.getPreviousTime();
- Assert.assertTrue(FastMath.abs(h) < minStep);
+ Assert.assertTrue(AccurateMath.abs(h) < minStep);
}
}
@@ -164,7 +164,7 @@ public class DormandPrince54IntegratorTest {
TestProblem1 pb = new TestProblem1();
double minStep = 0;
double maxStep = pb.getFinalTime() - pb.getInitialTime();
- double scalAbsoluteTolerance = FastMath.pow(10.0, i);
+ double scalAbsoluteTolerance = AccurateMath.pow(10.0, i);
double scalRelativeTolerance = 0.01 * scalAbsoluteTolerance;
EmbeddedRungeKuttaIntegrator integ =
@@ -332,10 +332,10 @@ public class DormandPrince54IntegratorTest {
public void handleStep(StepInterpolator interpolator,
boolean isLast) {
- double step = FastMath.abs(interpolator.getCurrentTime()
+ double step = AccurateMath.abs(interpolator.getCurrentTime()
- interpolator.getPreviousTime());
if (firstTime) {
- minStep = FastMath.abs(step);
+ minStep = AccurateMath.abs(step);
maxStep = minStep;
firstTime = false;
} else {
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/nonstiff/DormandPrince54StepInterpolatorTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/nonstiff/DormandPrince54StepInterpolatorTest.java
index 05697b048..8b89935f0 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/nonstiff/DormandPrince54StepInterpolatorTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/nonstiff/DormandPrince54StepInterpolatorTest.java
@@ -34,7 +34,7 @@ import org.apache.commons.math4.legacy.ode.TestProblem3;
import org.apache.commons.math4.legacy.ode.sampling.StepHandler;
import org.apache.commons.math4.legacy.ode.sampling.StepInterpolator;
import org.apache.commons.math4.legacy.ode.sampling.StepInterpolatorTestUtils;
-import org.apache.commons.math4.legacy.util.FastMath;
+import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
import org.junit.Assert;
import org.junit.Test;
@@ -126,13 +126,13 @@ public class DormandPrince54StepInterpolatorTest {
StepInterpolator cloned = interpolator.copy();
double tA = cloned.getPreviousTime();
double tB = cloned.getCurrentTime();
- double halfStep = FastMath.abs(tB - tA) / 2;
+ double halfStep = AccurateMath.abs(tB - tA) / 2;
Assert.assertEquals(interpolator.getPreviousTime(), tA, 1.0e-12);
Assert.assertEquals(interpolator.getCurrentTime(), tB, 1.0e-12);
for (int i = 0; i < 10; ++i) {
double t = (i * tB + (9 - i) * tA) / 9;
interpolator.setInterpolatedTime(t);
- Assert.assertTrue(FastMath.abs(cloned.getInterpolatedTime() - t) > (halfStep / 10));
+ Assert.assertTrue(AccurateMath.abs(cloned.getInterpolatedTime() - t) > (halfStep / 10));
cloned.setInterpolatedTime(t);
Assert.assertEquals(t, cloned.getInterpolatedTime(), 1.0e-12);
double[] referenceState = interpolator.getInterpolatedState();
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/nonstiff/DormandPrince853FieldIntegratorTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/nonstiff/DormandPrince853FieldIntegratorTest.java
index cc35c4a43..cdffeb050 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/nonstiff/DormandPrince853FieldIntegratorTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/nonstiff/DormandPrince853FieldIntegratorTest.java
@@ -18,8 +18,8 @@
package org.apache.commons.math4.legacy.ode.nonstiff;
-import org.apache.commons.math4.legacy.Field;
-import org.apache.commons.math4.legacy.RealFieldElement;
+import org.apache.commons.math4.legacy.core.Field;
+import org.apache.commons.math4.legacy.core.RealFieldElement;
public class DormandPrince853FieldIntegratorTest extends EmbeddedRungeKuttaFieldIntegratorAbstractTest {
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/nonstiff/DormandPrince853FieldStepInterpolatorTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/nonstiff/DormandPrince853FieldStepInterpolatorTest.java
index f4c9c5356..89fddcc52 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/nonstiff/DormandPrince853FieldStepInterpolatorTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/nonstiff/DormandPrince853FieldStepInterpolatorTest.java
@@ -18,8 +18,8 @@
package org.apache.commons.math4.legacy.ode.nonstiff;
-import org.apache.commons.math4.legacy.Field;
-import org.apache.commons.math4.legacy.RealFieldElement;
+import org.apache.commons.math4.legacy.core.Field;
+import org.apache.commons.math4.legacy.core.RealFieldElement;
import org.apache.commons.math4.legacy.ode.FieldEquationsMapper;
import org.apache.commons.math4.legacy.ode.FieldODEStateAndDerivative;
import org.junit.Test;
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/nonstiff/DormandPrince853IntegratorTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/nonstiff/DormandPrince853IntegratorTest.java
index a50eb8625..18e782209 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/nonstiff/DormandPrince853IntegratorTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/nonstiff/DormandPrince853IntegratorTest.java
@@ -31,7 +31,7 @@ import org.apache.commons.math4.legacy.ode.TestProblemHandler;
import org.apache.commons.math4.legacy.ode.events.EventHandler;
import org.apache.commons.math4.legacy.ode.sampling.StepHandler;
import org.apache.commons.math4.legacy.ode.sampling.StepInterpolator;
-import org.apache.commons.math4.legacy.util.FastMath;
+import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
import org.junit.Assert;
import org.junit.Test;
@@ -73,7 +73,7 @@ public class DormandPrince853IntegratorTest {
double finalT = integrator.integrate(ode, t0, y0, tEvent, y);
Assert.assertEquals(tEvent, finalT, 5.0e-6);
for (int i = 0; i < y.length; ++i) {
- Assert.assertEquals(y0[i] * FastMath.exp(k[i] * (finalT - t0)), y[i], 1.0e-9);
+ Assert.assertEquals(y0[i] * AccurateMath.exp(k[i] * (finalT - t0)), y[i], 1.0e-9);
}
integrator.setInitialStepSize(60.0);
@@ -101,7 +101,7 @@ public class DormandPrince853IntegratorTest {
finalT = integrator.integrate(ode, t0, y0, tEvent + 120, y);
Assert.assertEquals(tEvent + 120, finalT, 5.0e-6);
for (int i = 0; i < y.length; ++i) {
- Assert.assertEquals(y0[i] * FastMath.exp(k[i] * (finalT - t0)), y[i], 1.0e-9);
+ Assert.assertEquals(y0[i] * AccurateMath.exp(k[i] * (finalT - t0)), y[i], 1.0e-9);
}
}
@@ -168,7 +168,7 @@ public class DormandPrince853IntegratorTest {
TestProblem1 pb = new TestProblem1();
double minStep = 0;
double maxStep = pb.getFinalTime() - pb.getInitialTime();
- double scalAbsoluteTolerance = FastMath.pow(10.0, i);
+ double scalAbsoluteTolerance = AccurateMath.pow(10.0, i);
double scalRelativeTolerance = 0.01 * scalAbsoluteTolerance;
integ.setStepSizeControl(minStep, maxStep, scalAbsoluteTolerance, scalRelativeTolerance);
@@ -211,8 +211,8 @@ public class DormandPrince853IntegratorTest {
@Override
public void computeDerivatives(double t, double[] y, double[] yDot) {
- Assert.assertTrue(t >= FastMath.nextAfter(start, Double.NEGATIVE_INFINITY));
- Assert.assertTrue(t <= FastMath.nextAfter(end, Double.POSITIVE_INFINITY));
+ Assert.assertTrue(t >= AccurateMath.nextAfter(start, Double.NEGATIVE_INFINITY));
+ Assert.assertTrue(t <= AccurateMath.nextAfter(end, Double.POSITIVE_INFINITY));
yDot[0] = -100.0 * y[0];
}
@@ -369,7 +369,7 @@ public class DormandPrince853IntegratorTest {
integ.addEventHandler(cosChecker, 0.01, 1.0e-7, 100);
integ.addStepHandler(cosChecker);
double t0 = 0.5;
- double[] y0 = new double[] { FastMath.sin(t0), FastMath.cos(t0) };
+ double[] y0 = new double[] { AccurateMath.sin(t0), AccurateMath.cos(t0) };
double t = 10.0;
double[] y = new double[2];
integ.integrate(sincos, t0, y0, t, y);
@@ -471,10 +471,10 @@ public class DormandPrince853IntegratorTest {
public void handleStep(StepInterpolator interpolator,
boolean isLast) {
- double step = FastMath.abs(interpolator.getCurrentTime()
+ double step = AccurateMath.abs(interpolator.getCurrentTime()
- interpolator.getPreviousTime());
if (firstTime) {
- minStep = FastMath.abs(step);
+ minStep = AccurateMath.abs(step);
maxStep = minStep;
firstTime = false;
} else {
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/nonstiff/DormandPrince853StepInterpolatorTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/nonstiff/DormandPrince853StepInterpolatorTest.java
index 222ba9568..a4ac7dbb5 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/nonstiff/DormandPrince853StepInterpolatorTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/nonstiff/DormandPrince853StepInterpolatorTest.java
@@ -34,7 +34,7 @@ import org.apache.commons.math4.legacy.ode.TestProblem3;
import org.apache.commons.math4.legacy.ode.sampling.StepHandler;
import org.apache.commons.math4.legacy.ode.sampling.StepInterpolator;
import org.apache.commons.math4.legacy.ode.sampling.StepInterpolatorTestUtils;
-import org.apache.commons.math4.legacy.util.FastMath;
+import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
import org.junit.Assert;
import org.junit.Test;
@@ -126,13 +126,13 @@ public class DormandPrince853StepInterpolatorTest {
StepInterpolator cloned = interpolator.copy();
double tA = cloned.getPreviousTime();
double tB = cloned.getCurrentTime();
- double halfStep = FastMath.abs(tB - tA) / 2;
+ double halfStep = AccurateMath.abs(tB - tA) / 2;
Assert.assertEquals(interpolator.getPreviousTime(), tA, 1.0e-12);
Assert.assertEquals(interpolator.getCurrentTime(), tB, 1.0e-12);
for (int i = 0; i < 10; ++i) {
double t = (i * tB + (9 - i) * tA) / 9;
interpolator.setInterpolatedTime(t);
- Assert.assertTrue(FastMath.abs(cloned.getInterpolatedTime() - t) > (halfStep / 10));
+ Assert.assertTrue(AccurateMath.abs(cloned.getInterpolatedTime() - t) > (halfStep / 10));
cloned.setInterpolatedTime(t);
Assert.assertEquals(t, cloned.getInterpolatedTime(), 1.0e-12);
double[] referenceState = interpolator.getInterpolatedState();
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/nonstiff/EmbeddedRungeKuttaFieldIntegratorAbstractTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/nonstiff/EmbeddedRungeKuttaFieldIntegratorAbstractTest.java
index c86f6d7d5..573ea0c34 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/nonstiff/EmbeddedRungeKuttaFieldIntegratorAbstractTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/nonstiff/EmbeddedRungeKuttaFieldIntegratorAbstractTest.java
@@ -18,8 +18,8 @@
package org.apache.commons.math4.legacy.ode.nonstiff;
-import org.apache.commons.math4.legacy.Field;
-import org.apache.commons.math4.legacy.RealFieldElement;
+import org.apache.commons.math4.legacy.core.Field;
+import org.apache.commons.math4.legacy.core.RealFieldElement;
import org.apache.commons.math4.legacy.analysis.differentiation.DerivativeStructure;
import org.apache.commons.math4.legacy.exception.DimensionMismatchException;
import org.apache.commons.math4.legacy.exception.MaxCountExceededException;
@@ -39,8 +39,8 @@ import org.apache.commons.math4.legacy.ode.events.Action;
import org.apache.commons.math4.legacy.ode.events.FieldEventHandler;
import org.apache.commons.math4.legacy.ode.sampling.FieldStepHandler;
import org.apache.commons.math4.legacy.ode.sampling.FieldStepInterpolator;
-import org.apache.commons.math4.legacy.util.FastMath;
-import org.apache.commons.math4.legacy.util.MathArrays;
+import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
+import org.apache.commons.math4.legacy.core.MathArrays;
import org.junit.Assert;
import org.junit.Test;
@@ -122,7 +122,7 @@ public abstract class EmbeddedRungeKuttaFieldIntegratorAbstractTest {
if (regularArray[i] == 0) {
Assert.assertTrue(0.0 == fieldArray[i].getReal());
} else {
- Assert.assertEquals(regularArray[i], fieldArray[i].getReal(), FastMath.ulp(regularArray[i]));
+ Assert.assertEquals(regularArray[i], fieldArray[i].getReal(), AccurateMath.ulp(regularArray[i]));
}
}
}
@@ -212,7 +212,7 @@ public abstract class EmbeddedRungeKuttaFieldIntegratorAbstractTest {
TestFieldProblem1 pb = new TestFieldProblem1<>(field);
double minStep = 0;
double maxStep = pb.getFinalTime().subtract(pb.getInitialState().getTime()).getReal();
- double scalAbsoluteTolerance = FastMath.pow(10.0, i);
+ double scalAbsoluteTolerance = AccurateMath.pow(10.0, i);
double scalRelativeTolerance = 0.01 * scalAbsoluteTolerance;
FirstOrderFieldIntegrator integ = createIntegrator(field, minStep, maxStep,
@@ -577,7 +577,7 @@ public abstract class EmbeddedRungeKuttaFieldIntegratorAbstractTest {
public double[] theoreticalY(final double t) {
final double theta = omega.getReal() * t + alpha.getReal();
return new double[] {
- r.getReal() * FastMath.sin(theta), r.getReal() * FastMath.cos(theta)
+ r.getReal() * AccurateMath.sin(theta), r.getReal() * AccurateMath.cos(theta)
};
}
@@ -585,8 +585,8 @@ public abstract class EmbeddedRungeKuttaFieldIntegratorAbstractTest {
// intermediate angle and state
final double theta = omega.getReal() * t + alpha.getReal();
- final double sin = FastMath.sin(theta);
- final double cos = FastMath.cos(theta);
+ final double sin = AccurateMath.sin(theta);
+ final double cos = AccurateMath.cos(theta);
final double y0 = r.getReal() * sin;
final double y1 = r.getReal() * cos;
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/nonstiff/EulerFieldIntegratorTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/nonstiff/EulerFieldIntegratorTest.java
index 35f378bfe..6ec8e33be 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/nonstiff/EulerFieldIntegratorTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/nonstiff/EulerFieldIntegratorTest.java
@@ -18,8 +18,8 @@
package org.apache.commons.math4.legacy.ode.nonstiff;
-import org.apache.commons.math4.legacy.Field;
-import org.apache.commons.math4.legacy.RealFieldElement;
+import org.apache.commons.math4.legacy.core.Field;
+import org.apache.commons.math4.legacy.core.RealFieldElement;
public class EulerFieldIntegratorTest extends RungeKuttaFieldIntegratorAbstractTest {
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/nonstiff/EulerFieldStepInterpolatorTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/nonstiff/EulerFieldStepInterpolatorTest.java
index d63bd6e6e..1a137310c 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/nonstiff/EulerFieldStepInterpolatorTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/nonstiff/EulerFieldStepInterpolatorTest.java
@@ -18,8 +18,8 @@
package org.apache.commons.math4.legacy.ode.nonstiff;
-import org.apache.commons.math4.legacy.Field;
-import org.apache.commons.math4.legacy.RealFieldElement;
+import org.apache.commons.math4.legacy.core.Field;
+import org.apache.commons.math4.legacy.core.RealFieldElement;
import org.apache.commons.math4.legacy.ode.FieldEquationsMapper;
import org.apache.commons.math4.legacy.ode.FieldODEStateAndDerivative;
import org.junit.Test;
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/nonstiff/EulerIntegratorTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/nonstiff/EulerIntegratorTest.java
index 3de69f3c4..264e3e6c1 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/nonstiff/EulerIntegratorTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/nonstiff/EulerIntegratorTest.java
@@ -35,7 +35,7 @@ import org.apache.commons.math4.legacy.ode.TestProblemHandler;
import org.apache.commons.math4.legacy.ode.events.EventHandler;
import org.apache.commons.math4.legacy.ode.sampling.StepHandler;
import org.apache.commons.math4.legacy.ode.sampling.StepInterpolator;
-import org.apache.commons.math4.legacy.util.FastMath;
+import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
import org.junit.Assert;
import org.junit.Test;
@@ -66,7 +66,7 @@ public class EulerIntegratorTest {
double previousTimeError = Double.NaN;
for (int i = 4; i < 8; ++i) {
- double step = (pb.getFinalTime() - pb.getInitialTime()) * FastMath.pow(2.0, -i);
+ double step = (pb.getFinalTime() - pb.getInitialTime()) * AccurateMath.pow(2.0, -i);
FirstOrderIntegrator integ = new EulerIntegrator(step);
TestProblemHandler handler = new TestProblemHandler(pb, integ);
@@ -84,13 +84,13 @@ public class EulerIntegratorTest {
double valueError = handler.getMaximalValueError();
if (i > 4) {
- Assert.assertTrue(valueError < FastMath.abs(previousValueError));
+ Assert.assertTrue(valueError < AccurateMath.abs(previousValueError));
}
previousValueError = valueError;
double timeError = handler.getMaximalTimeError();
if (i > 4) {
- Assert.assertTrue(timeError <= FastMath.abs(previousTimeError));
+ Assert.assertTrue(timeError <= AccurateMath.abs(previousTimeError));
}
previousTimeError = timeError;
@@ -149,7 +149,7 @@ public class EulerIntegratorTest {
MaxCountExceededException, NoBracketingException {
TestProblem5 pb = new TestProblem5();
- double step = FastMath.abs(pb.getFinalTime() - pb.getInitialTime()) * 0.001;
+ double step = AccurateMath.abs(pb.getFinalTime() - pb.getInitialTime()) * 0.001;
FirstOrderIntegrator integ = new EulerIntegrator(step);
TestProblemHandler handler = new TestProblemHandler(pb, integ);
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/nonstiff/EulerStepInterpolatorTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/nonstiff/EulerStepInterpolatorTest.java
index 387964d80..1986a5339 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/nonstiff/EulerStepInterpolatorTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/nonstiff/EulerStepInterpolatorTest.java
@@ -35,7 +35,7 @@ import org.apache.commons.math4.legacy.ode.TestProblem1;
import org.apache.commons.math4.legacy.ode.TestProblem3;
import org.apache.commons.math4.legacy.ode.sampling.StepHandler;
import org.apache.commons.math4.legacy.ode.sampling.StepInterpolatorTestUtils;
-import org.apache.commons.math4.legacy.util.FastMath;
+import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
import org.junit.Assert;
import org.junit.Test;
@@ -56,7 +56,7 @@ public class EulerStepInterpolatorTest {
double[] result = interpolator.getInterpolatedState();
for (int i = 0; i < result.length; ++i) {
- Assert.assertTrue(FastMath.abs(result[i] - y[i]) < 1.0e-10);
+ Assert.assertTrue(AccurateMath.abs(result[i] - y[i]) < 1.0e-10);
}
}
@@ -88,13 +88,13 @@ public class EulerStepInterpolatorTest {
interpolator.setInterpolatedTime(interpolator.getPreviousTime());
double[] result = interpolator.getInterpolatedState();
for (int i = 0; i < result.length; ++i) {
- Assert.assertTrue(FastMath.abs(result[i] - y0[i]) < 1.0e-10);
+ Assert.assertTrue(AccurateMath.abs(result[i] - y0[i]) < 1.0e-10);
}
interpolator.setInterpolatedTime(interpolator.getCurrentTime());
result = interpolator.getInterpolatedState();
for (int i = 0; i < result.length; ++i) {
- Assert.assertTrue(FastMath.abs(result[i] - y[i]) < 1.0e-10);
+ Assert.assertTrue(AccurateMath.abs(result[i] - y[i]) < 1.0e-10);
}
}
@@ -117,15 +117,15 @@ public class EulerStepInterpolatorTest {
interpolator.setInterpolatedTime(0.1);
double[] result = interpolator.getInterpolatedState();
- Assert.assertTrue(FastMath.abs(result[0] - 0.1) < 1.0e-10);
- Assert.assertTrue(FastMath.abs(result[1] - 1.2) < 1.0e-10);
- Assert.assertTrue(FastMath.abs(result[2] + 2.2) < 1.0e-10);
+ Assert.assertTrue(AccurateMath.abs(result[0] - 0.1) < 1.0e-10);
+ Assert.assertTrue(AccurateMath.abs(result[1] - 1.2) < 1.0e-10);
+ Assert.assertTrue(AccurateMath.abs(result[2] + 2.2) < 1.0e-10);
interpolator.setInterpolatedTime(0.5);
result = interpolator.getInterpolatedState();
- Assert.assertTrue(FastMath.abs(result[0] - 0.5) < 1.0e-10);
- Assert.assertTrue(FastMath.abs(result[1] - 2.0) < 1.0e-10);
- Assert.assertTrue(FastMath.abs(result[2] + 3.0) < 1.0e-10);
+ Assert.assertTrue(AccurateMath.abs(result[0] - 0.5) < 1.0e-10);
+ Assert.assertTrue(AccurateMath.abs(result[1] - 2.0) < 1.0e-10);
+ Assert.assertTrue(AccurateMath.abs(result[2] + 3.0) < 1.0e-10);
}
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/nonstiff/GillFieldIntegratorTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/nonstiff/GillFieldIntegratorTest.java
index 61799d41e..80cd3b6a2 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/nonstiff/GillFieldIntegratorTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/nonstiff/GillFieldIntegratorTest.java
@@ -18,8 +18,8 @@
package org.apache.commons.math4.legacy.ode.nonstiff;
-import org.apache.commons.math4.legacy.Field;
-import org.apache.commons.math4.legacy.RealFieldElement;
+import org.apache.commons.math4.legacy.core.Field;
+import org.apache.commons.math4.legacy.core.RealFieldElement;
public class GillFieldIntegratorTest extends RungeKuttaFieldIntegratorAbstractTest {
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/nonstiff/GillFieldStepInterpolatorTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/nonstiff/GillFieldStepInterpolatorTest.java
index 839cb0ca7..44e0401d5 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/nonstiff/GillFieldStepInterpolatorTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/nonstiff/GillFieldStepInterpolatorTest.java
@@ -18,8 +18,8 @@
package org.apache.commons.math4.legacy.ode.nonstiff;
-import org.apache.commons.math4.legacy.Field;
-import org.apache.commons.math4.legacy.RealFieldElement;
+import org.apache.commons.math4.legacy.core.Field;
+import org.apache.commons.math4.legacy.core.RealFieldElement;
import org.apache.commons.math4.legacy.ode.FieldEquationsMapper;
import org.apache.commons.math4.legacy.ode.FieldODEStateAndDerivative;
import org.junit.Test;
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/nonstiff/GillIntegratorTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/nonstiff/GillIntegratorTest.java
index 6061e5c17..f344406e7 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/nonstiff/GillIntegratorTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/nonstiff/GillIntegratorTest.java
@@ -35,7 +35,7 @@ import org.apache.commons.math4.legacy.ode.TestProblemHandler;
import org.apache.commons.math4.legacy.ode.events.EventHandler;
import org.apache.commons.math4.legacy.ode.sampling.StepHandler;
import org.apache.commons.math4.legacy.ode.sampling.StepInterpolator;
-import org.apache.commons.math4.legacy.util.FastMath;
+import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
import org.junit.Assert;
import org.junit.Test;
@@ -66,7 +66,7 @@ public class GillIntegratorTest {
double previousTimeError = Double.NaN;
for (int i = 5; i < 10; ++i) {
- double step = (pb.getFinalTime() - pb.getInitialTime()) * FastMath.pow(2.0, -i);
+ double step = (pb.getFinalTime() - pb.getInitialTime()) * AccurateMath.pow(2.0, -i);
FirstOrderIntegrator integ = new GillIntegrator(step);
TestProblemHandler handler = new TestProblemHandler(pb, integ);
@@ -84,13 +84,13 @@ public class GillIntegratorTest {
double valueError = handler.getMaximalValueError();
if (i > 5) {
- Assert.assertTrue(valueError < 1.01 * FastMath.abs(previousValueError));
+ Assert.assertTrue(valueError < 1.01 * AccurateMath.abs(previousValueError));
}
previousValueError = valueError;
double timeError = handler.getMaximalTimeError();
if (i > 5) {
- Assert.assertTrue(timeError <= FastMath.abs(previousTimeError));
+ Assert.assertTrue(timeError <= AccurateMath.abs(previousTimeError));
}
previousTimeError = timeError;
@@ -147,7 +147,7 @@ public class GillIntegratorTest {
MaxCountExceededException, NoBracketingException {
TestProblem5 pb = new TestProblem5();
- double step = FastMath.abs(pb.getFinalTime() - pb.getInitialTime()) * 0.001;
+ double step = AccurateMath.abs(pb.getFinalTime() - pb.getInitialTime()) * 0.001;
FirstOrderIntegrator integ = new GillIntegrator(step);
TestProblemHandler handler = new TestProblemHandler(pb, integ);
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/nonstiff/GraggBulirschStoerIntegratorTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/nonstiff/GraggBulirschStoerIntegratorTest.java
index eda9c1908..d6ad9c6ce 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/nonstiff/GraggBulirschStoerIntegratorTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/nonstiff/GraggBulirschStoerIntegratorTest.java
@@ -32,7 +32,7 @@ import org.apache.commons.math4.legacy.ode.TestProblemHandler;
import org.apache.commons.math4.legacy.ode.events.EventHandler;
import org.apache.commons.math4.legacy.ode.sampling.StepHandler;
import org.apache.commons.math4.legacy.ode.sampling.StepInterpolator;
-import org.apache.commons.math4.legacy.util.FastMath;
+import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
import org.junit.Assert;
import org.junit.Test;
@@ -69,8 +69,8 @@ public class GraggBulirschStoerIntegratorTest {
MaxCountExceededException, NoBracketingException {
TestProblem5 pb = new TestProblem5();
- double minStep = 0.1 * FastMath.abs(pb.getFinalTime() - pb.getInitialTime());
- double maxStep = FastMath.abs(pb.getFinalTime() - pb.getInitialTime());
+ double minStep = 0.1 * AccurateMath.abs(pb.getFinalTime() - pb.getInitialTime());
+ double maxStep = AccurateMath.abs(pb.getFinalTime() - pb.getInitialTime());
double[] vecAbsoluteTolerance = { 1.0e-20, 1.0e-21 };
double[] vecRelativeTolerance = { 1.0e-20, 1.0e-21 };
@@ -120,7 +120,7 @@ public class GraggBulirschStoerIntegratorTest {
TestProblem1 pb = new TestProblem1();
double minStep = 0;
double maxStep = pb.getFinalTime() - pb.getInitialTime();
- double absTolerance = FastMath.pow(10.0, i);
+ double absTolerance = AccurateMath.pow(10.0, i);
double relTolerance = absTolerance;
FirstOrderIntegrator integ =
@@ -288,8 +288,8 @@ public class GraggBulirschStoerIntegratorTest {
@Override
public void computeDerivatives(double t, double[] y, double[] yDot) {
- Assert.assertTrue(t >= FastMath.nextAfter(start, Double.NEGATIVE_INFINITY));
- Assert.assertTrue(t <= FastMath.nextAfter(end, Double.POSITIVE_INFINITY));
+ Assert.assertTrue(t >= AccurateMath.nextAfter(start, Double.NEGATIVE_INFINITY));
+ Assert.assertTrue(t <= AccurateMath.nextAfter(end, Double.POSITIVE_INFINITY));
yDot[0] = -100.0 * y[0];
}
@@ -408,10 +408,10 @@ public class GraggBulirschStoerIntegratorTest {
public void handleStep(StepInterpolator interpolator,
boolean isLast) {
- double step = FastMath.abs(interpolator.getCurrentTime()
+ double step = AccurateMath.abs(interpolator.getCurrentTime()
- interpolator.getPreviousTime());
if (firstTime) {
- minStep = FastMath.abs(step);
+ minStep = AccurateMath.abs(step);
maxStep = minStep;
firstTime = false;
} else {
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/nonstiff/GraggBulirschStoerStepInterpolatorTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/nonstiff/GraggBulirschStoerStepInterpolatorTest.java
index 55a29269f..5adca2d24 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/nonstiff/GraggBulirschStoerStepInterpolatorTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/nonstiff/GraggBulirschStoerStepInterpolatorTest.java
@@ -34,7 +34,7 @@ import org.apache.commons.math4.legacy.ode.TestProblem3;
import org.apache.commons.math4.legacy.ode.sampling.StepHandler;
import org.apache.commons.math4.legacy.ode.sampling.StepInterpolator;
import org.apache.commons.math4.legacy.ode.sampling.StepInterpolatorTestUtils;
-import org.apache.commons.math4.legacy.util.FastMath;
+import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
import org.junit.Assert;
import org.junit.Test;
@@ -128,13 +128,13 @@ public class GraggBulirschStoerStepInterpolatorTest {
StepInterpolator cloned = interpolator.copy();
double tA = cloned.getPreviousTime();
double tB = cloned.getCurrentTime();
- double halfStep = FastMath.abs(tB - tA) / 2;
+ double halfStep = AccurateMath.abs(tB - tA) / 2;
Assert.assertEquals(interpolator.getPreviousTime(), tA, 1.0e-12);
Assert.assertEquals(interpolator.getCurrentTime(), tB, 1.0e-12);
for (int i = 0; i < 10; ++i) {
double t = (i * tB + (9 - i) * tA) / 9;
interpolator.setInterpolatedTime(t);
- Assert.assertTrue(FastMath.abs(cloned.getInterpolatedTime() - t) > (halfStep / 10));
+ Assert.assertTrue(AccurateMath.abs(cloned.getInterpolatedTime() - t) > (halfStep / 10));
cloned.setInterpolatedTime(t);
Assert.assertEquals(t, cloned.getInterpolatedTime(), 1.0e-12);
double[] referenceState = interpolator.getInterpolatedState();
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/nonstiff/HighamHall54FieldIntegratorTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/nonstiff/HighamHall54FieldIntegratorTest.java
index a40c1c6a1..2bbc8cf72 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/nonstiff/HighamHall54FieldIntegratorTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/nonstiff/HighamHall54FieldIntegratorTest.java
@@ -18,8 +18,8 @@
package org.apache.commons.math4.legacy.ode.nonstiff;
-import org.apache.commons.math4.legacy.Field;
-import org.apache.commons.math4.legacy.RealFieldElement;
+import org.apache.commons.math4.legacy.core.Field;
+import org.apache.commons.math4.legacy.core.RealFieldElement;
public class HighamHall54FieldIntegratorTest extends EmbeddedRungeKuttaFieldIntegratorAbstractTest {
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/nonstiff/HighamHall54FieldStepInterpolatorTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/nonstiff/HighamHall54FieldStepInterpolatorTest.java
index 989df1704..a4362f5b0 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/nonstiff/HighamHall54FieldStepInterpolatorTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/nonstiff/HighamHall54FieldStepInterpolatorTest.java
@@ -18,8 +18,8 @@
package org.apache.commons.math4.legacy.ode.nonstiff;
-import org.apache.commons.math4.legacy.Field;
-import org.apache.commons.math4.legacy.RealFieldElement;
+import org.apache.commons.math4.legacy.core.Field;
+import org.apache.commons.math4.legacy.core.RealFieldElement;
import org.apache.commons.math4.legacy.ode.FieldEquationsMapper;
import org.apache.commons.math4.legacy.ode.FieldODEStateAndDerivative;
import org.junit.Test;
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/nonstiff/HighamHall54IntegratorTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/nonstiff/HighamHall54IntegratorTest.java
index 6dfb6e524..8be50679e 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/nonstiff/HighamHall54IntegratorTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/nonstiff/HighamHall54IntegratorTest.java
@@ -31,7 +31,7 @@ import org.apache.commons.math4.legacy.ode.TestProblem4;
import org.apache.commons.math4.legacy.ode.TestProblem5;
import org.apache.commons.math4.legacy.ode.TestProblemHandler;
import org.apache.commons.math4.legacy.ode.events.EventHandler;
-import org.apache.commons.math4.legacy.util.FastMath;
+import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
import org.junit.Assert;
import org.junit.Test;
@@ -108,7 +108,7 @@ public class HighamHall54IntegratorTest {
TestProblem1 pb = new TestProblem1();
double minStep = 0;
double maxStep = pb.getFinalTime() - pb.getInitialTime();
- double scalAbsoluteTolerance = FastMath.pow(10.0, i);
+ double scalAbsoluteTolerance = AccurateMath.pow(10.0, i);
double scalRelativeTolerance = 0.01 * scalAbsoluteTolerance;
FirstOrderIntegrator integ = new HighamHall54Integrator(minStep, maxStep,
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/nonstiff/HighamHall54StepInterpolatorTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/nonstiff/HighamHall54StepInterpolatorTest.java
index 0db520afd..b0f832b02 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/nonstiff/HighamHall54StepInterpolatorTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/nonstiff/HighamHall54StepInterpolatorTest.java
@@ -34,7 +34,7 @@ import org.apache.commons.math4.legacy.ode.TestProblem3;
import org.apache.commons.math4.legacy.ode.sampling.StepHandler;
import org.apache.commons.math4.legacy.ode.sampling.StepInterpolator;
import org.apache.commons.math4.legacy.ode.sampling.StepInterpolatorTestUtils;
-import org.apache.commons.math4.legacy.util.FastMath;
+import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
import org.junit.Assert;
import org.junit.Test;
@@ -126,13 +126,13 @@ public class HighamHall54StepInterpolatorTest {
StepInterpolator cloned = interpolator.copy();
double tA = cloned.getPreviousTime();
double tB = cloned.getCurrentTime();
- double halfStep = FastMath.abs(tB - tA) / 2;
+ double halfStep = AccurateMath.abs(tB - tA) / 2;
Assert.assertEquals(interpolator.getPreviousTime(), tA, 1.0e-12);
Assert.assertEquals(interpolator.getCurrentTime(), tB, 1.0e-12);
for (int i = 0; i < 10; ++i) {
double t = (i * tB + (9 - i) * tA) / 9;
interpolator.setInterpolatedTime(t);
- Assert.assertTrue(FastMath.abs(cloned.getInterpolatedTime() - t) > (halfStep / 10));
+ Assert.assertTrue(AccurateMath.abs(cloned.getInterpolatedTime() - t) > (halfStep / 10));
cloned.setInterpolatedTime(t);
Assert.assertEquals(t, cloned.getInterpolatedTime(), 1.0e-12);
double[] referenceState = interpolator.getInterpolatedState();
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/nonstiff/LutherFieldIntegratorTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/nonstiff/LutherFieldIntegratorTest.java
index 34842fc93..86314a53a 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/nonstiff/LutherFieldIntegratorTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/nonstiff/LutherFieldIntegratorTest.java
@@ -18,8 +18,8 @@
package org.apache.commons.math4.legacy.ode.nonstiff;
-import org.apache.commons.math4.legacy.Field;
-import org.apache.commons.math4.legacy.RealFieldElement;
+import org.apache.commons.math4.legacy.core.Field;
+import org.apache.commons.math4.legacy.core.RealFieldElement;
import org.apache.commons.math4.legacy.exception.DimensionMismatchException;
import org.apache.commons.math4.legacy.exception.MaxCountExceededException;
import org.apache.commons.math4.legacy.exception.NoBracketingException;
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/nonstiff/LutherFieldStepInterpolatorTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/nonstiff/LutherFieldStepInterpolatorTest.java
index d368902c7..b7bc245ad 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/nonstiff/LutherFieldStepInterpolatorTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/nonstiff/LutherFieldStepInterpolatorTest.java
@@ -18,8 +18,8 @@
package org.apache.commons.math4.legacy.ode.nonstiff;
-import org.apache.commons.math4.legacy.Field;
-import org.apache.commons.math4.legacy.RealFieldElement;
+import org.apache.commons.math4.legacy.core.Field;
+import org.apache.commons.math4.legacy.core.RealFieldElement;
import org.apache.commons.math4.legacy.ode.FieldEquationsMapper;
import org.apache.commons.math4.legacy.ode.FieldODEStateAndDerivative;
import org.junit.Test;
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/nonstiff/LutherIntegratorTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/nonstiff/LutherIntegratorTest.java
index efa68a22c..1add51861 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/nonstiff/LutherIntegratorTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/nonstiff/LutherIntegratorTest.java
@@ -35,7 +35,7 @@ import org.apache.commons.math4.legacy.ode.TestProblemHandler;
import org.apache.commons.math4.legacy.ode.events.EventHandler;
import org.apache.commons.math4.legacy.ode.sampling.StepHandler;
import org.apache.commons.math4.legacy.ode.sampling.StepInterpolator;
-import org.apache.commons.math4.legacy.util.FastMath;
+import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
import org.junit.Assert;
import org.junit.Test;
@@ -74,7 +74,7 @@ public class LutherIntegratorTest {
double finalT = integrator.integrate(ode, t0, y0, tEvent, y);
Assert.assertEquals(tEvent, finalT, 1.0e-15);
for (int i = 0; i < y.length; ++i) {
- Assert.assertEquals(y0[i] * FastMath.exp(k[i] * (finalT - t0)), y[i], 1.0e-15);
+ Assert.assertEquals(y0[i] * AccurateMath.exp(k[i] * (finalT - t0)), y[i], 1.0e-15);
}
integrator.addEventHandler(new EventHandler() {
@@ -101,7 +101,7 @@ public class LutherIntegratorTest {
finalT = integrator.integrate(ode, t0, y0, tEvent + 120, y);
Assert.assertEquals(tEvent + 120, finalT, 1.0e-15);
for (int i = 0; i < y.length; ++i) {
- Assert.assertEquals(y0[i] * FastMath.exp(k[i] * (finalT - t0)), y[i], 1.0e-15);
+ Assert.assertEquals(y0[i] * AccurateMath.exp(k[i] * (finalT - t0)), y[i], 1.0e-15);
}
}
@@ -150,7 +150,7 @@ public class LutherIntegratorTest {
double previousTimeError = Double.NaN;
for (int i = 4; i < 10; ++i) {
- double step = (pb.getFinalTime() - pb.getInitialTime()) * FastMath.pow(2.0, -i);
+ double step = (pb.getFinalTime() - pb.getInitialTime()) * AccurateMath.pow(2.0, -i);
FirstOrderIntegrator integ = new LutherIntegrator(step);
TestProblemHandler handler = new TestProblemHandler(pb, integ);
@@ -169,13 +169,13 @@ public class LutherIntegratorTest {
double error = handler.getMaximalValueError();
if (i > 4) {
- Assert.assertTrue(error < 1.01 * FastMath.abs(previousValueError));
+ Assert.assertTrue(error < 1.01 * AccurateMath.abs(previousValueError));
}
previousValueError = error;
double timeError = handler.getMaximalTimeError();
if (i > 4) {
- Assert.assertTrue(timeError <= FastMath.abs(previousTimeError));
+ Assert.assertTrue(timeError <= AccurateMath.abs(previousTimeError));
}
previousTimeError = timeError;
@@ -233,7 +233,7 @@ public class LutherIntegratorTest {
MaxCountExceededException, NoBracketingException {
TestProblem5 pb = new TestProblem5();
- double step = FastMath.abs(pb.getFinalTime() - pb.getInitialTime()) * 0.001;
+ double step = AccurateMath.abs(pb.getFinalTime() - pb.getInitialTime()) * 0.001;
FirstOrderIntegrator integ = new LutherIntegrator(step);
TestProblemHandler handler = new TestProblemHandler(pb, integ);
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/nonstiff/MidpointFieldIntegratorTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/nonstiff/MidpointFieldIntegratorTest.java
index 079610f73..0815c3a75 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/nonstiff/MidpointFieldIntegratorTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/nonstiff/MidpointFieldIntegratorTest.java
@@ -18,8 +18,8 @@
package org.apache.commons.math4.legacy.ode.nonstiff;
-import org.apache.commons.math4.legacy.Field;
-import org.apache.commons.math4.legacy.RealFieldElement;
+import org.apache.commons.math4.legacy.core.Field;
+import org.apache.commons.math4.legacy.core.RealFieldElement;
public class MidpointFieldIntegratorTest extends RungeKuttaFieldIntegratorAbstractTest {
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/nonstiff/MidpointFieldStepInterpolatorTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/nonstiff/MidpointFieldStepInterpolatorTest.java
index d89662c74..c8642edae 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/nonstiff/MidpointFieldStepInterpolatorTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/nonstiff/MidpointFieldStepInterpolatorTest.java
@@ -18,8 +18,8 @@
package org.apache.commons.math4.legacy.ode.nonstiff;
-import org.apache.commons.math4.legacy.Field;
-import org.apache.commons.math4.legacy.RealFieldElement;
+import org.apache.commons.math4.legacy.core.Field;
+import org.apache.commons.math4.legacy.core.RealFieldElement;
import org.apache.commons.math4.legacy.ode.FieldEquationsMapper;
import org.apache.commons.math4.legacy.ode.FieldODEStateAndDerivative;
import org.junit.Test;
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/nonstiff/MidpointIntegratorTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/nonstiff/MidpointIntegratorTest.java
index 142c4a9f2..4fd7e9525 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/nonstiff/MidpointIntegratorTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/nonstiff/MidpointIntegratorTest.java
@@ -35,7 +35,7 @@ import org.apache.commons.math4.legacy.ode.TestProblemHandler;
import org.apache.commons.math4.legacy.ode.events.EventHandler;
import org.apache.commons.math4.legacy.ode.sampling.StepHandler;
import org.apache.commons.math4.legacy.ode.sampling.StepInterpolator;
-import org.apache.commons.math4.legacy.util.FastMath;
+import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
import org.junit.Assert;
import org.junit.Test;
@@ -66,7 +66,7 @@ public class MidpointIntegratorTest {
double previousTimeError = Double.NaN;
for (int i = 4; i < 10; ++i) {
- double step = (pb.getFinalTime() - pb.getInitialTime()) * FastMath.pow(2.0, -i);
+ double step = (pb.getFinalTime() - pb.getInitialTime()) * AccurateMath.pow(2.0, -i);
FirstOrderIntegrator integ = new MidpointIntegrator(step);
TestProblemHandler handler = new TestProblemHandler(pb, integ);
integ.addStepHandler(handler);
@@ -84,13 +84,13 @@ public class MidpointIntegratorTest {
double valueError = handler.getMaximalValueError();
if (i > 4) {
- Assert.assertTrue(valueError < FastMath.abs(previousValueError));
+ Assert.assertTrue(valueError < AccurateMath.abs(previousValueError));
}
previousValueError = valueError;
double timeError = handler.getMaximalTimeError();
if (i > 4) {
- Assert.assertTrue(timeError <= FastMath.abs(previousTimeError));
+ Assert.assertTrue(timeError <= AccurateMath.abs(previousTimeError));
}
previousTimeError = timeError;
@@ -149,7 +149,7 @@ public class MidpointIntegratorTest {
MaxCountExceededException, NoBracketingException {
TestProblem5 pb = new TestProblem5();
- double step = FastMath.abs(pb.getFinalTime() - pb.getInitialTime()) * 0.001;
+ double step = AccurateMath.abs(pb.getFinalTime() - pb.getInitialTime()) * 0.001;
FirstOrderIntegrator integ = new MidpointIntegrator(step);
TestProblemHandler handler = new TestProblemHandler(pb, integ);
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/nonstiff/RungeKuttaFieldIntegratorAbstractTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/nonstiff/RungeKuttaFieldIntegratorAbstractTest.java
index b507ee8c1..3529a8b8e 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/nonstiff/RungeKuttaFieldIntegratorAbstractTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/nonstiff/RungeKuttaFieldIntegratorAbstractTest.java
@@ -20,8 +20,8 @@ package org.apache.commons.math4.legacy.ode.nonstiff;
import java.lang.reflect.Array;
-import org.apache.commons.math4.legacy.Field;
-import org.apache.commons.math4.legacy.RealFieldElement;
+import org.apache.commons.math4.legacy.core.Field;
+import org.apache.commons.math4.legacy.core.RealFieldElement;
import org.apache.commons.math4.legacy.analysis.differentiation.DerivativeStructure;
import org.apache.commons.math4.legacy.exception.DimensionMismatchException;
import org.apache.commons.math4.legacy.exception.MaxCountExceededException;
@@ -44,8 +44,8 @@ import org.apache.commons.math4.legacy.ode.events.FieldEventHandler;
import org.apache.commons.math4.legacy.ode.sampling.FieldStepHandler;
import org.apache.commons.math4.legacy.ode.sampling.FieldStepInterpolator;
import org.apache.commons.math4.legacy.ode.sampling.StepInterpolatorTestUtils;
-import org.apache.commons.math4.legacy.util.FastMath;
-import org.apache.commons.math4.legacy.util.MathArrays;
+import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
+import org.apache.commons.math4.legacy.core.MathArrays;
import org.junit.Assert;
import org.junit.Test;
@@ -108,7 +108,7 @@ public abstract class RungeKuttaFieldIntegratorAbstractTest {
if (regularArray[i] == 0) {
Assert.assertTrue(0.0 == fieldArray[i].getReal());
} else {
- Assert.assertEquals(regularArray[i], fieldArray[i].getReal(), FastMath.ulp(regularArray[i]));
+ Assert.assertEquals(regularArray[i], fieldArray[i].getReal(), AccurateMath.ulp(regularArray[i]));
}
}
}
@@ -250,7 +250,7 @@ public abstract class RungeKuttaFieldIntegratorAbstractTest {
T previousTimeError = null;
for (int i = 4; i < 10; ++i) {
- T step = pb.getFinalTime().subtract(pb.getInitialState().getTime()).multiply(FastMath.pow(2.0, -i));
+ T step = pb.getFinalTime().subtract(pb.getInitialState().getTime()).multiply(AccurateMath.pow(2.0, -i));
RungeKuttaFieldIntegrator integ = createIntegrator(field, step);
TestFieldProblemHandler handler = new TestFieldProblemHandler<>(pb, integ);
@@ -497,8 +497,8 @@ public abstract class RungeKuttaFieldIntegratorAbstractTest {
@Override
public T[] computeDerivatives(T t, T[] y) {
- Assert.assertTrue(t.getReal() >= FastMath.nextAfter(t0.getReal(), Double.NEGATIVE_INFINITY));
- Assert.assertTrue(t.getReal() <= FastMath.nextAfter(t.getReal(), Double.POSITIVE_INFINITY));
+ Assert.assertTrue(t.getReal() >= AccurateMath.nextAfter(t0.getReal(), Double.NEGATIVE_INFINITY));
+ Assert.assertTrue(t.getReal() <= AccurateMath.nextAfter(t.getReal(), Double.POSITIVE_INFINITY));
T[] yDot = MathArrays.buildArray(field, 1);
yDot[0] = y[0].multiply(-100.0);
return yDot;
@@ -643,7 +643,7 @@ public abstract class RungeKuttaFieldIntegratorAbstractTest {
public double[] theoreticalY(final double t) {
final double theta = omega.getReal() * t + alpha.getReal();
return new double[] {
- r.getReal() * FastMath.sin(theta), r.getReal() * FastMath.cos(theta)
+ r.getReal() * AccurateMath.sin(theta), r.getReal() * AccurateMath.cos(theta)
};
}
@@ -651,8 +651,8 @@ public abstract class RungeKuttaFieldIntegratorAbstractTest {
// intermediate angle and state
final double theta = omega.getReal() * t + alpha.getReal();
- final double sin = FastMath.sin(theta);
- final double cos = FastMath.cos(theta);
+ final double sin = AccurateMath.sin(theta);
+ final double cos = AccurateMath.cos(theta);
final double y0 = r.getReal() * sin;
final double y1 = r.getReal() * cos;
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/nonstiff/RungeKuttaFieldStepInterpolatorAbstractTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/nonstiff/RungeKuttaFieldStepInterpolatorAbstractTest.java
index bb4252980..8c95605e8 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/nonstiff/RungeKuttaFieldStepInterpolatorAbstractTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/nonstiff/RungeKuttaFieldStepInterpolatorAbstractTest.java
@@ -18,8 +18,8 @@
package org.apache.commons.math4.legacy.ode.nonstiff;
-import org.apache.commons.math4.legacy.Field;
-import org.apache.commons.math4.legacy.RealFieldElement;
+import org.apache.commons.math4.legacy.core.Field;
+import org.apache.commons.math4.legacy.core.RealFieldElement;
import org.apache.commons.math4.legacy.ode.AbstractIntegrator;
import org.apache.commons.math4.legacy.ode.EquationsMapper;
import org.apache.commons.math4.legacy.ode.ExpandableStatefulODE;
@@ -28,8 +28,8 @@ import org.apache.commons.math4.legacy.ode.FieldExpandableODE;
import org.apache.commons.math4.legacy.ode.FirstOrderFieldDifferentialEquations;
import org.apache.commons.math4.legacy.ode.FieldODEStateAndDerivative;
import org.apache.commons.math4.legacy.ode.sampling.AbstractFieldStepInterpolator;
-import org.apache.commons.math4.legacy.util.FastMath;
-import org.apache.commons.math4.legacy.util.MathArrays;
+import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
+import org.apache.commons.math4.legacy.core.MathArrays;
import org.junit.Assert;
import org.junit.Test;
@@ -88,8 +88,8 @@ public abstract class RungeKuttaFieldStepInterpolatorAbstractTest {
add(interpolator.getCurrentState().getTime().multiply(i)).
divide(n);
FieldODEStateAndDerivative state = interpolator.getInterpolatedState(t);
- maxErrorSin = FastMath.max(maxErrorSin, state.getState()[0].subtract(t.sin()).abs().getReal());
- maxErrorCos = FastMath.max(maxErrorCos, state.getState()[1].subtract(t.cos()).abs().getReal());
+ maxErrorSin = AccurateMath.max(maxErrorSin, state.getState()[0].subtract(t.sin()).abs().getReal());
+ maxErrorCos = AccurateMath.max(maxErrorCos, state.getState()[1].subtract(t.cos()).abs().getReal());
}
Assert.assertEquals(0.0, maxErrorSin, epsilonSin);
Assert.assertEquals(0.0, maxErrorCos, epsilonCos);
@@ -127,10 +127,10 @@ public abstract class RungeKuttaFieldStepInterpolatorAbstractTest {
double[] regularY = regularInterpolator.getInterpolatedState();
double[] regularYDot = regularInterpolator.getInterpolatedDerivatives();
- maxErrorSin = FastMath.max(maxErrorSin, fieldY[0].subtract(regularY[0]).abs().getReal());
- maxErrorCos = FastMath.max(maxErrorCos, fieldY[1].subtract(regularY[1]).abs().getReal());
- maxErrorSinDot = FastMath.max(maxErrorSinDot, fieldYDot[0].subtract(regularYDot[0]).abs().getReal());
- maxErrorCosDot = FastMath.max(maxErrorCosDot, fieldYDot[1].subtract(regularYDot[1]).abs().getReal());
+ maxErrorSin = AccurateMath.max(maxErrorSin, fieldY[0].subtract(regularY[0]).abs().getReal());
+ maxErrorCos = AccurateMath.max(maxErrorCos, fieldY[1].subtract(regularY[1]).abs().getReal());
+ maxErrorSinDot = AccurateMath.max(maxErrorSinDot, fieldYDot[0].subtract(regularYDot[0]).abs().getReal());
+ maxErrorCosDot = AccurateMath.max(maxErrorCosDot, fieldYDot[1].subtract(regularYDot[1]).abs().getReal());
}
Assert.assertEquals(0.0, maxErrorSin, epsilonSin);
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/nonstiff/StepFieldProblem.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/nonstiff/StepFieldProblem.java
index 984ffda49..ef7414319 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/nonstiff/StepFieldProblem.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/nonstiff/StepFieldProblem.java
@@ -17,14 +17,14 @@
package org.apache.commons.math4.legacy.ode.nonstiff;
-import org.apache.commons.math4.legacy.Field;
-import org.apache.commons.math4.legacy.RealFieldElement;
+import org.apache.commons.math4.legacy.core.Field;
+import org.apache.commons.math4.legacy.core.RealFieldElement;
import org.apache.commons.math4.legacy.ode.FirstOrderFieldDifferentialEquations;
import org.apache.commons.math4.legacy.ode.FieldODEState;
import org.apache.commons.math4.legacy.ode.FieldODEStateAndDerivative;
import org.apache.commons.math4.legacy.ode.events.Action;
import org.apache.commons.math4.legacy.ode.events.FieldEventHandler;
-import org.apache.commons.math4.legacy.util.MathArrays;
+import org.apache.commons.math4.legacy.core.MathArrays;
public class StepFieldProblem>
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/nonstiff/ThreeEighthesFieldIntegratorTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/nonstiff/ThreeEighthesFieldIntegratorTest.java
index dbba09957..5e28801bf 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/nonstiff/ThreeEighthesFieldIntegratorTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/nonstiff/ThreeEighthesFieldIntegratorTest.java
@@ -18,8 +18,8 @@
package org.apache.commons.math4.legacy.ode.nonstiff;
-import org.apache.commons.math4.legacy.Field;
-import org.apache.commons.math4.legacy.RealFieldElement;
+import org.apache.commons.math4.legacy.core.Field;
+import org.apache.commons.math4.legacy.core.RealFieldElement;
public class ThreeEighthesFieldIntegratorTest extends RungeKuttaFieldIntegratorAbstractTest {
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/nonstiff/ThreeEighthesFieldStepInterpolatorTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/nonstiff/ThreeEighthesFieldStepInterpolatorTest.java
index dcc72ed65..93b07ad65 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/nonstiff/ThreeEighthesFieldStepInterpolatorTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/nonstiff/ThreeEighthesFieldStepInterpolatorTest.java
@@ -18,8 +18,8 @@
package org.apache.commons.math4.legacy.ode.nonstiff;
-import org.apache.commons.math4.legacy.Field;
-import org.apache.commons.math4.legacy.RealFieldElement;
+import org.apache.commons.math4.legacy.core.Field;
+import org.apache.commons.math4.legacy.core.RealFieldElement;
import org.apache.commons.math4.legacy.ode.FieldEquationsMapper;
import org.apache.commons.math4.legacy.ode.FieldODEStateAndDerivative;
import org.junit.Test;
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/nonstiff/ThreeEighthesIntegratorTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/nonstiff/ThreeEighthesIntegratorTest.java
index 68e8592a0..d81b7512c 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/nonstiff/ThreeEighthesIntegratorTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/nonstiff/ThreeEighthesIntegratorTest.java
@@ -35,7 +35,7 @@ import org.apache.commons.math4.legacy.ode.TestProblemHandler;
import org.apache.commons.math4.legacy.ode.events.EventHandler;
import org.apache.commons.math4.legacy.ode.sampling.StepHandler;
import org.apache.commons.math4.legacy.ode.sampling.StepInterpolator;
-import org.apache.commons.math4.legacy.util.FastMath;
+import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
import org.junit.Assert;
import org.junit.Test;
@@ -66,7 +66,7 @@ public class ThreeEighthesIntegratorTest {
double previousTimeError = Double.NaN;
for (int i = 4; i < 10; ++i) {
- double step = (pb.getFinalTime() - pb.getInitialTime()) * FastMath.pow(2.0, -i);
+ double step = (pb.getFinalTime() - pb.getInitialTime()) * AccurateMath.pow(2.0, -i);
FirstOrderIntegrator integ = new ThreeEighthesIntegrator(step);
TestProblemHandler handler = new TestProblemHandler(pb, integ);
@@ -84,13 +84,13 @@ public class ThreeEighthesIntegratorTest {
double error = handler.getMaximalValueError();
if (i > 4) {
- Assert.assertTrue(error < 1.01 * FastMath.abs(previousValueError));
+ Assert.assertTrue(error < 1.01 * AccurateMath.abs(previousValueError));
}
previousValueError = error;
double timeError = handler.getMaximalTimeError();
if (i > 4) {
- Assert.assertTrue(timeError <= FastMath.abs(previousTimeError));
+ Assert.assertTrue(timeError <= AccurateMath.abs(previousTimeError));
}
previousTimeError = timeError;
@@ -147,7 +147,7 @@ public class ThreeEighthesIntegratorTest {
MaxCountExceededException, NoBracketingException {
TestProblem5 pb = new TestProblem5();
- double step = FastMath.abs(pb.getFinalTime() - pb.getInitialTime()) * 0.001;
+ double step = AccurateMath.abs(pb.getFinalTime() - pb.getInitialTime()) * 0.001;
FirstOrderIntegrator integ = new ThreeEighthesIntegrator(step);
TestProblemHandler handler = new TestProblemHandler(pb, integ);
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/sampling/DummyFieldStepInterpolator.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/sampling/DummyFieldStepInterpolator.java
index 938ea9745..7708458cd 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/sampling/DummyFieldStepInterpolator.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/sampling/DummyFieldStepInterpolator.java
@@ -17,7 +17,7 @@
package org.apache.commons.math4.legacy.ode.sampling;
-import org.apache.commons.math4.legacy.RealFieldElement;
+import org.apache.commons.math4.legacy.core.RealFieldElement;
import org.apache.commons.math4.legacy.ode.FieldEquationsMapper;
import org.apache.commons.math4.legacy.ode.FieldODEStateAndDerivative;
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/sampling/DummyStepInterpolatorTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/sampling/DummyStepInterpolatorTest.java
index fa7139850..75bcd4cde 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/sampling/DummyStepInterpolatorTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/sampling/DummyStepInterpolatorTest.java
@@ -25,7 +25,7 @@ import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import org.apache.commons.math4.legacy.exception.MaxCountExceededException;
-import org.apache.commons.math4.legacy.util.FastMath;
+import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
import org.junit.Assert;
import org.junit.Test;
@@ -42,7 +42,7 @@ public class DummyStepInterpolatorTest {
double[] result = interpolator.getInterpolatedState();
for (int i = 0; i < result.length; ++i) {
- Assert.assertTrue(FastMath.abs(result[i] - y[i]) < 1.0e-10);
+ Assert.assertTrue(AccurateMath.abs(result[i] - y[i]) < 1.0e-10);
}
}
@@ -59,13 +59,13 @@ public class DummyStepInterpolatorTest {
interpolator.setInterpolatedTime(0.1);
double[] result = interpolator.getInterpolatedState();
for (int i = 0; i < result.length; ++i) {
- Assert.assertTrue(FastMath.abs(result[i] - y[i]) < 1.0e-10);
+ Assert.assertTrue(AccurateMath.abs(result[i] - y[i]) < 1.0e-10);
}
interpolator.setInterpolatedTime(0.5);
result = interpolator.getInterpolatedState();
for (int i = 0; i < result.length; ++i) {
- Assert.assertTrue(FastMath.abs(result[i] - y[i]) < 1.0e-10);
+ Assert.assertTrue(AccurateMath.abs(result[i] - y[i]) < 1.0e-10);
}
}
@@ -94,7 +94,7 @@ public class DummyStepInterpolatorTest {
dsi.setInterpolatedTime(0.5);
double[] result = dsi.getInterpolatedState();
for (int i = 0; i < result.length; ++i) {
- Assert.assertTrue(FastMath.abs(result[i] - y[i]) < 1.0e-10);
+ Assert.assertTrue(AccurateMath.abs(result[i] - y[i]) < 1.0e-10);
}
}
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/sampling/StepInterpolatorTestUtils.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/sampling/StepInterpolatorTestUtils.java
index 541b9d99a..bc631f9d0 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/sampling/StepInterpolatorTestUtils.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/sampling/StepInterpolatorTestUtils.java
@@ -17,7 +17,7 @@
package org.apache.commons.math4.legacy.ode.sampling;
-import org.apache.commons.math4.legacy.RealFieldElement;
+import org.apache.commons.math4.legacy.core.RealFieldElement;
import org.apache.commons.math4.legacy.exception.DimensionMismatchException;
import org.apache.commons.math4.legacy.exception.MaxCountExceededException;
import org.apache.commons.math4.legacy.exception.NoBracketingException;
@@ -28,7 +28,7 @@ import org.apache.commons.math4.legacy.ode.FieldODEStateAndDerivative;
import org.apache.commons.math4.legacy.ode.FirstOrderIntegrator;
import org.apache.commons.math4.legacy.ode.TestFieldProblemAbstract;
import org.apache.commons.math4.legacy.ode.TestProblemAbstract;
-import org.apache.commons.math4.legacy.util.FastMath;
+import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
import org.junit.Assert;
public class StepInterpolatorTestUtils {
@@ -49,7 +49,7 @@ public class StepInterpolatorTestUtils {
final double h = finiteDifferencesRatio * dt;
final double t = interpolator.getCurrentTime() - 0.3 * dt;
- if (FastMath.abs(h) < 10 * FastMath.ulp(t)) {
+ if (AccurateMath.abs(h) < 10 * AccurateMath.ulp(t)) {
return;
}
@@ -107,7 +107,7 @@ public class StepInterpolatorTestUtils {
final T h = interpolator.getCurrentState().getTime().subtract(interpolator.getPreviousState().getTime()).multiply(0.001);
final T t = interpolator.getCurrentState().getTime().subtract(h.multiply(300));
- if (h.abs().subtract(FastMath.ulp(t.getReal()) * 10).getReal() < 0) {
+ if (h.abs().subtract(AccurateMath.ulp(t.getReal()) * 10).getReal() < 0) {
return;
}
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/sampling/StepNormalizerTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/sampling/StepNormalizerTest.java
index 11958427c..505ef339f 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/sampling/StepNormalizerTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/ode/sampling/StepNormalizerTest.java
@@ -24,7 +24,7 @@ import org.apache.commons.math4.legacy.exception.NumberIsTooSmallException;
import org.apache.commons.math4.legacy.ode.FirstOrderIntegrator;
import org.apache.commons.math4.legacy.ode.TestProblem3;
import org.apache.commons.math4.legacy.ode.nonstiff.DormandPrince54Integrator;
-import org.apache.commons.math4.legacy.util.FastMath;
+import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
@@ -101,7 +101,7 @@ public class StepNormalizerTest {
}
public void checkValue(double value, double reference) {
- Assert.assertTrue(FastMath.abs(value - reference) < 1.0e-10);
+ Assert.assertTrue(AccurateMath.abs(value - reference) < 1.0e-10);
}
public void setLastSeen(boolean lastSeen) {
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/optim/nonlinear/scalar/noderiv/CMAESOptimizerTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/optim/nonlinear/scalar/noderiv/CMAESOptimizerTest.java
index 0f205e0e2..500bfde35 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/optim/nonlinear/scalar/noderiv/CMAESOptimizerTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/optim/nonlinear/scalar/noderiv/CMAESOptimizerTest.java
@@ -34,7 +34,7 @@ import org.apache.commons.math4.legacy.optim.SimpleBounds;
import org.apache.commons.math4.legacy.optim.nonlinear.scalar.GoalType;
import org.apache.commons.math4.legacy.optim.nonlinear.scalar.ObjectiveFunction;
import org.apache.commons.rng.simple.RandomSource;
-import org.apache.commons.math4.legacy.util.FastMath;
+import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -46,7 +46,7 @@ import org.junit.runner.RunWith;
public class CMAESOptimizerTest {
static final int DIM = 13;
- static final int LAMBDA = 4 + (int)(3.*FastMath.log(DIM));
+ static final int LAMBDA = 4 + (int)(3.*AccurateMath.log(DIM));
@Test(expected = NumberIsTooLargeException.class)
public void testInitOutofbounds1() {
@@ -353,10 +353,10 @@ public class CMAESOptimizerTest {
PointValuePair expected =
new PointValuePair(point(DIM,0.0),0.0);
doTest(new Rastrigin(), startPoint, insigma, boundaries,
- GoalType.MINIMIZE, (int)(200*FastMath.sqrt(DIM)), true, 0, 1e-13,
+ GoalType.MINIMIZE, (int)(200*AccurateMath.sqrt(DIM)), true, 0, 1e-13,
1e-13, 1e-6, 200000, expected);
doTest(new Rastrigin(), startPoint, insigma, boundaries,
- GoalType.MINIMIZE, (int)(200*FastMath.sqrt(DIM)), false, 0, 1e-13,
+ GoalType.MINIMIZE, (int)(200*AccurateMath.sqrt(DIM)), false, 0, 1e-13,
1e-13, 1e-6, 200000, expected);
}
@@ -671,7 +671,7 @@ public class CMAESOptimizerTest {
double f = 0;
x = B.Rotate(x);
for (int i = 0; i < x.length; ++i) {
- f += FastMath.pow(factor, i / (x.length - 1.)) * x[i] * x[i];
+ f += AccurateMath.pow(factor, i / (x.length - 1.)) * x[i] * x[i];
}
return f;
}
@@ -693,7 +693,7 @@ public class CMAESOptimizerTest {
public double value(double[] x) {
double f = 0;
for (int i = 0; i < x.length; ++i) {
- f += FastMath.pow(factor, i / (x.length - 1.)) * x[i] * x[i];
+ f += AccurateMath.pow(factor, i / (x.length - 1.)) * x[i] * x[i];
}
return f;
}
@@ -713,7 +713,7 @@ public class CMAESOptimizerTest {
public double value(double[] x) {
double f = 0;
for (int i = 0; i < x.length; ++i) {
- f += FastMath.pow(FastMath.abs(x[i]), 2. + 10 * (double) i
+ f += AccurateMath.pow(AccurateMath.abs(x[i]), 2. + 10 * (double) i
/ (x.length - 1.));
}
return f;
@@ -724,7 +724,7 @@ public class CMAESOptimizerTest {
@Override
public double value(double[] x) {
- double f = FastMath.pow(new DiffPow().value(x), 0.25);
+ double f = AccurateMath.pow(new DiffPow().value(x), 0.25);
return f;
}
}
@@ -759,12 +759,12 @@ public class CMAESOptimizerTest {
double res2 = 0;
double fac = 0;
for (int i = 0; i < x.length; ++i) {
- fac = FastMath.pow(axisratio, (i - 1.) / (x.length - 1.));
+ fac = AccurateMath.pow(axisratio, (i - 1.) / (x.length - 1.));
f += fac * fac * x[i] * x[i];
- res2 += FastMath.cos(2. * FastMath.PI * fac * x[i]);
+ res2 += AccurateMath.cos(2. * AccurateMath.PI * fac * x[i]);
}
- f = (20. - 20. * FastMath.exp(-0.2 * FastMath.sqrt(f / x.length))
- + FastMath.exp(1.) - FastMath.exp(res2 / x.length));
+ f = (20. - 20. * AccurateMath.exp(-0.2 * AccurateMath.sqrt(f / x.length))
+ + AccurateMath.exp(1.) - AccurateMath.exp(res2 / x.length));
return f;
}
}
@@ -788,12 +788,12 @@ public class CMAESOptimizerTest {
double f = 0;
double fac;
for (int i = 0; i < x.length; ++i) {
- fac = FastMath.pow(axisratio, (i - 1.) / (x.length - 1.));
+ fac = AccurateMath.pow(axisratio, (i - 1.) / (x.length - 1.));
if (i == 0 && x[i] < 0) {
fac *= 1.;
}
f += fac * fac * x[i] * x[i] + amplitude
- * (1. - FastMath.cos(2. * FastMath.PI * fac * x[i]));
+ * (1. - AccurateMath.cos(2. * AccurateMath.PI * fac * x[i]));
}
return f;
}
@@ -844,7 +844,7 @@ public class CMAESOptimizerTest {
sp += basis[i][k] * basis[i][k]; /* squared norm */
}
for (k = 0; k < DIM; ++k) {
- basis[i][k] /= FastMath.sqrt(sp);
+ basis[i][k] /= AccurateMath.sqrt(sp);
}
}
}
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/optim/nonlinear/scalar/noderiv/OptimTestUtils.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/optim/nonlinear/scalar/noderiv/OptimTestUtils.java
index 4cebe68dd..2d5b4fa7d 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/optim/nonlinear/scalar/noderiv/OptimTestUtils.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/optim/nonlinear/scalar/noderiv/OptimTestUtils.java
@@ -21,7 +21,7 @@ import java.util.Random;
import org.apache.commons.rng.UniformRandomProvider;
import org.apache.commons.rng.simple.RandomSource;
import org.apache.commons.math4.legacy.analysis.MultivariateFunction;
-import org.apache.commons.math4.legacy.util.FastMath;
+import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
/**
* Utilities for testing the optimizers.
@@ -143,7 +143,7 @@ class OptimTestUtils {
double f = 0;
x = B.Rotate(x);
for (int i = 0; i < x.length; ++i) {
- f += FastMath.pow(factor, i / (x.length - 1.)) * x[i] * x[i];
+ f += AccurateMath.pow(factor, i / (x.length - 1.)) * x[i] * x[i];
}
return f;
}
@@ -165,7 +165,7 @@ class OptimTestUtils {
public double value(double[] x) {
double f = 0;
for (int i = 0; i < x.length; ++i) {
- f += FastMath.pow(factor, i / (x.length - 1.)) * x[i] * x[i];
+ f += AccurateMath.pow(factor, i / (x.length - 1.)) * x[i] * x[i];
}
return f;
}
@@ -184,7 +184,7 @@ class OptimTestUtils {
public double value(double[] x) {
double f = 0;
for (int i = 0; i < x.length; ++i) {
- f += FastMath.pow(FastMath.abs(x[i]), 2. + 10 * (double) i
+ f += AccurateMath.pow(AccurateMath.abs(x[i]), 2. + 10 * (double) i
/ (x.length - 1.));
}
return f;
@@ -194,7 +194,7 @@ class OptimTestUtils {
static class SsDiffPow implements MultivariateFunction {
@Override
public double value(double[] x) {
- double f = FastMath.pow(new DiffPow().value(x), 0.25);
+ double f = AccurateMath.pow(new DiffPow().value(x), 0.25);
return f;
}
}
@@ -229,12 +229,12 @@ class OptimTestUtils {
double res2 = 0;
double fac = 0;
for (int i = 0; i < x.length; ++i) {
- fac = FastMath.pow(axisratio, (i - 1.) / (x.length - 1.));
+ fac = AccurateMath.pow(axisratio, (i - 1.) / (x.length - 1.));
f += fac * fac * x[i] * x[i];
- res2 += FastMath.cos(2. * FastMath.PI * fac * x[i]);
+ res2 += AccurateMath.cos(2. * AccurateMath.PI * fac * x[i]);
}
- f = (20. - 20. * FastMath.exp(-0.2 * FastMath.sqrt(f / x.length))
- + FastMath.exp(1.) - FastMath.exp(res2 / x.length));
+ f = (20. - 20. * AccurateMath.exp(-0.2 * AccurateMath.sqrt(f / x.length))
+ + AccurateMath.exp(1.) - AccurateMath.exp(res2 / x.length));
return f;
}
}
@@ -257,12 +257,12 @@ class OptimTestUtils {
double f = 0;
double fac;
for (int i = 0; i < x.length; ++i) {
- fac = FastMath.pow(axisratio, (i - 1.) / (x.length - 1.));
+ fac = AccurateMath.pow(axisratio, (i - 1.) / (x.length - 1.));
if (i == 0 && x[i] < 0) {
fac *= 1.;
}
f += fac * fac * x[i] * x[i] + amplitude
- * (1. - FastMath.cos(2. * FastMath.PI * fac * x[i]));
+ * (1. - AccurateMath.cos(2. * AccurateMath.PI * fac * x[i]));
}
return f;
}
@@ -284,7 +284,7 @@ class OptimTestUtils {
final double x = variables[0];
final double y = variables[1];
return (x == 0 || y == 0) ? 0 :
- FastMath.atan(x) * FastMath.atan(x + 2) * FastMath.atan(y) * FastMath.atan(y) / (x * y);
+ AccurateMath.atan(x) * AccurateMath.atan(x + 2) * AccurateMath.atan(y) * AccurateMath.atan(y) / (x * y);
}
}
@@ -329,7 +329,7 @@ class OptimTestUtils {
public double value(double[] point) {
final double x = point[0], y = point[1];
final double twoS2 = 2.0 * std * std;
- return 1.0 / (twoS2 * FastMath.PI) * FastMath.exp(-(x * x + y * y) / twoS2);
+ return 1.0 / (twoS2 * AccurateMath.PI) * AccurateMath.exp(-(x * x + y * y) / twoS2);
}
}
@@ -389,7 +389,7 @@ class OptimTestUtils {
sp += basis[i][k] * basis[i][k]; /* squared norm */
}
for (k = 0; k < DIM; ++k) {
- basis[i][k] /= FastMath.sqrt(sp);
+ basis[i][k] /= AccurateMath.sqrt(sp);
}
}
}
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/optim/nonlinear/scalar/noderiv/PowellOptimizerTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/optim/nonlinear/scalar/noderiv/PowellOptimizerTest.java
index e62bf17d2..89301b35d 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/optim/nonlinear/scalar/noderiv/PowellOptimizerTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/optim/nonlinear/scalar/noderiv/PowellOptimizerTest.java
@@ -25,7 +25,7 @@ import org.apache.commons.math4.legacy.optim.PointValuePair;
import org.apache.commons.math4.legacy.optim.SimpleBounds;
import org.apache.commons.math4.legacy.optim.nonlinear.scalar.GoalType;
import org.apache.commons.math4.legacy.optim.nonlinear.scalar.ObjectiveFunction;
-import org.apache.commons.math4.legacy.util.FastMath;
+import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
import org.junit.Assert;
import org.junit.Test;
@@ -153,7 +153,7 @@ public class PowellOptimizerTest {
public double value(double[] x) {
final double a = x[0] - 1;
final double b = x[1] - 1;
- return a * a * FastMath.sqrt(FastMath.abs(a)) + b * b + 1;
+ return a * a * AccurateMath.sqrt(AccurateMath.abs(a)) + b * b + 1;
}
};
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/optim/nonlinear/scalar/noderiv/SimplexOptimizerMultiDirectionalTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/optim/nonlinear/scalar/noderiv/SimplexOptimizerMultiDirectionalTest.java
index 60a07ede0..3b039428d 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/optim/nonlinear/scalar/noderiv/SimplexOptimizerMultiDirectionalTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/optim/nonlinear/scalar/noderiv/SimplexOptimizerMultiDirectionalTest.java
@@ -26,7 +26,7 @@ import org.apache.commons.math4.legacy.optim.SimpleBounds;
import org.apache.commons.math4.legacy.optim.SimpleValueChecker;
import org.apache.commons.math4.legacy.optim.nonlinear.scalar.GoalType;
import org.apache.commons.math4.legacy.optim.nonlinear.scalar.ObjectiveFunction;
-import org.apache.commons.math4.legacy.util.MathArrays;
+import org.apache.commons.math4.legacy.core.MathArrays;
import org.junit.Assert;
import org.junit.Test;
import org.junit.Ignore;
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/optim/nonlinear/scalar/noderiv/SimplexOptimizerNelderMeadTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/optim/nonlinear/scalar/noderiv/SimplexOptimizerNelderMeadTest.java
index eb1a73c7b..08422967a 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/optim/nonlinear/scalar/noderiv/SimplexOptimizerNelderMeadTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/optim/nonlinear/scalar/noderiv/SimplexOptimizerNelderMeadTest.java
@@ -31,7 +31,7 @@ import org.apache.commons.math4.legacy.optim.SimpleBounds;
import org.apache.commons.math4.legacy.optim.nonlinear.scalar.GoalType;
import org.apache.commons.math4.legacy.optim.nonlinear.scalar.LeastSquaresConverter;
import org.apache.commons.math4.legacy.optim.nonlinear.scalar.ObjectiveFunction;
-import org.apache.commons.math4.legacy.util.MathArrays;
+import org.apache.commons.math4.legacy.core.MathArrays;
import org.junit.Assert;
import org.junit.Test;
import org.junit.Ignore;
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/optim/univariate/BrentOptimizerTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/optim/univariate/BrentOptimizerTest.java
index 1ecb65212..fa09cab2d 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/optim/univariate/BrentOptimizerTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/optim/univariate/BrentOptimizerTest.java
@@ -29,7 +29,7 @@ import org.apache.commons.math4.legacy.optim.ConvergenceChecker;
import org.apache.commons.math4.legacy.optim.MaxEval;
import org.apache.commons.math4.legacy.optim.nonlinear.scalar.GoalType;
import org.apache.commons.math4.legacy.stat.descriptive.DescriptiveStatistics;
-import org.apache.commons.math4.legacy.util.FastMath;
+import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
import org.junit.Assert;
import org.junit.Test;
@@ -212,7 +212,7 @@ public final class BrentOptimizerTest {
final UnivariateFunction f = new UnivariateFunction() {
@Override
public double value(double x) {
- final double sqrtX = FastMath.sqrt(x);
+ final double sqrtX = AccurateMath.sqrt(x);
final double a = 1e2 * sqrtX;
final double b = 1e6 / x;
final double c = 1e4 / sqrtX;
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/optim/univariate/MultiStartUnivariateOptimizerTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/optim/univariate/MultiStartUnivariateOptimizerTest.java
index 7f18e6460..a76178aad 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/optim/univariate/MultiStartUnivariateOptimizerTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/optim/univariate/MultiStartUnivariateOptimizerTest.java
@@ -24,7 +24,7 @@ import org.apache.commons.math4.legacy.optim.MaxEval;
import org.apache.commons.math4.legacy.optim.nonlinear.scalar.GoalType;
import org.apache.commons.rng.UniformRandomProvider;
import org.apache.commons.rng.simple.RandomSource;
-import org.apache.commons.math4.legacy.util.FastMath;
+import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
import org.junit.Assert;
import org.junit.Test;
@@ -60,8 +60,8 @@ public class MultiStartUnivariateOptimizerTest {
new SearchInterval(-100.0, 100.0));
UnivariatePointValuePair[] optima = optimizer.getOptima();
for (int i = 1; i < optima.length; ++i) {
- double d = (optima[i].getPoint() - optima[i-1].getPoint()) / (2 * FastMath.PI);
- Assert.assertTrue(FastMath.abs(d - FastMath.rint(d)) < 1.0e-8);
+ double d = (optima[i].getPoint() - optima[i-1].getPoint()) / (2 * AccurateMath.PI);
+ Assert.assertTrue(AccurateMath.abs(d - AccurateMath.rint(d)) < 1.0e-8);
Assert.assertEquals(-1.0, f.value(optima[i].getPoint()), 1.0e-10);
Assert.assertEquals(f.value(optima[i].getPoint()), optima[i].getValue(), 1.0e-10);
}
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/random/CorrelatedRandomVectorGeneratorTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/random/CorrelatedRandomVectorGeneratorTest.java
index 1010c6476..a6622c6f0 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/random/CorrelatedRandomVectorGeneratorTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/random/CorrelatedRandomVectorGeneratorTest.java
@@ -29,7 +29,7 @@ import org.apache.commons.rng.sampling.distribution.ZigguratNormalizedGaussianSa
import org.apache.commons.math4.legacy.stat.correlation.StorelessCovariance;
import org.apache.commons.math4.legacy.stat.descriptive.moment.VectorialCovariance;
import org.apache.commons.math4.legacy.stat.descriptive.moment.VectorialMean;
-import org.apache.commons.math4.legacy.util.FastMath;
+import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
import org.junit.Test;
import org.junit.Assert;
@@ -91,8 +91,8 @@ public class CorrelatedRandomVectorGeneratorTest {
for (int i = 0; i < 10; i++) {
double[] generated = sg.get();
for (int j = 0; j < generated.length; ++j) {
- min[j] = FastMath.min(min[j], generated[j]);
- max[j] = FastMath.max(max[j], generated[j]);
+ min[j] = AccurateMath.min(min[j], generated[j]);
+ max[j] = AccurateMath.max(max[j], generated[j]);
}
}
for (int j = 0; j < min.length; ++j) {
@@ -130,7 +130,7 @@ public class CorrelatedRandomVectorGeneratorTest {
for (int j = 0; j <= i; ++j) {
Assert.assertEquals(covariance.getEntry(i, j),
estimatedCovariance.getEntry(i, j),
- 0.1 * (1.0 + FastMath.abs(mean[i])) * (1.0 + FastMath.abs(mean[j])));
+ 0.1 * (1.0 + AccurateMath.abs(mean[i])) * (1.0 + AccurateMath.abs(mean[j])));
}
}
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/random/RandomUtilsDataGeneratorAbstractTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/random/RandomUtilsDataGeneratorAbstractTest.java
index bd7141ada..ec25174a2 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/random/RandomUtilsDataGeneratorAbstractTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/random/RandomUtilsDataGeneratorAbstractTest.java
@@ -20,7 +20,7 @@ import org.apache.commons.math4.legacy.RetryRunner;
import org.apache.commons.math4.legacy.TestUtils;
import org.apache.commons.math4.legacy.exception.MathIllegalArgumentException;
import org.apache.commons.math4.legacy.stat.Frequency;
-import org.apache.commons.math4.legacy.util.FastMath;
+import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
import org.apache.commons.rng.UniformRandomProvider;
import org.junit.Assert;
import org.junit.Test;
@@ -127,8 +127,8 @@ public abstract class RandomUtilsDataGeneratorAbstractTest {
long min = Long.MAX_VALUE;
for (int i = 0; i < 10000000; ++i) {
long r = randomData.nextLong(lower, upper);
- max = FastMath.max(max, r);
- min = FastMath.min(min, r);
+ max = AccurateMath.max(max, r);
+ min = AccurateMath.min(min, r);
Assert.assertTrue(r >= lower);
Assert.assertTrue(r <= upper);
}
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/stat/StatUtilsTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/stat/StatUtilsTest.java
index 486c52d43..7f02b3f0f 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/stat/StatUtilsTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/stat/StatUtilsTest.java
@@ -21,7 +21,7 @@ import org.apache.commons.math4.legacy.TestUtils;
import org.apache.commons.math4.legacy.exception.MathIllegalArgumentException;
import org.apache.commons.math4.legacy.exception.NullArgumentException;
import org.apache.commons.math4.legacy.stat.descriptive.DescriptiveStatistics;
-import org.apache.commons.math4.legacy.util.FastMath;
+import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
import org.apache.commons.numbers.core.Precision;
import org.junit.Assert;
import org.junit.Test;
@@ -210,13 +210,13 @@ public final class StatUtilsTest {
// test one
x = new double[] {TWO};
- TestUtils.assertEquals(FastMath.log(TWO), StatUtils.sumLog(x), TOLERANCE);
- TestUtils.assertEquals(FastMath.log(TWO), StatUtils.sumLog(x, 0, 1), TOLERANCE);
+ TestUtils.assertEquals(AccurateMath.log(TWO), StatUtils.sumLog(x), TOLERANCE);
+ TestUtils.assertEquals(AccurateMath.log(TWO), StatUtils.sumLog(x, 0, 1), TOLERANCE);
// test many
x = new double[] {ONE, TWO, TWO, THREE};
- TestUtils.assertEquals(FastMath.log(ONE) + 2.0 * FastMath.log(TWO) + FastMath.log(THREE), StatUtils.sumLog(x), TOLERANCE);
- TestUtils.assertEquals(2.0 * FastMath.log(TWO), StatUtils.sumLog(x, 1, 2), TOLERANCE);
+ TestUtils.assertEquals(AccurateMath.log(ONE) + 2.0 * AccurateMath.log(TWO) + AccurateMath.log(THREE), StatUtils.sumLog(x), TOLERANCE);
+ TestUtils.assertEquals(2.0 * AccurateMath.log(TWO), StatUtils.sumLog(x, 1, 2), TOLERANCE);
}
@Test
@@ -457,9 +457,9 @@ public final class StatUtilsTest {
// expected
}
test = new double[] {2, 4, 6, 8};
- Assert.assertEquals(FastMath.exp(0.25d * StatUtils.sumLog(test)),
+ Assert.assertEquals(AccurateMath.exp(0.25d * StatUtils.sumLog(test)),
StatUtils.geometricMean(test), Double.MIN_VALUE);
- Assert.assertEquals(FastMath.exp(0.5 * StatUtils.sumLog(test, 0, 2)),
+ Assert.assertEquals(AccurateMath.exp(0.5 * StatUtils.sumLog(test, 0, 2)),
StatUtils.geometricMean(test, 0, 2), Double.MIN_VALUE);
}
@@ -471,7 +471,7 @@ public final class StatUtilsTest {
@Test
public void testNormalize1() {
double sample[] = { 50, 100 };
- double expectedSample[] = { -25 / FastMath.sqrt(1250), 25 / FastMath.sqrt(1250) };
+ double expectedSample[] = { -25 / AccurateMath.sqrt(1250), 25 / AccurateMath.sqrt(1250) };
double[] out = StatUtils.normalize(sample);
for (int i = 0; i < out.length; i++) {
Assert.assertTrue(Precision.equals(out[i], expectedSample[i], 1));
@@ -490,7 +490,7 @@ public final class StatUtilsTest {
int length = 77;
double sample[] = new double[length];
for (int i = 0; i < length; i++) {
- sample[i] = FastMath.random();
+ sample[i] = AccurateMath.random();
}
// normalize this sample
double standardizedSample[] = StatUtils.normalize(sample);
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/stat/correlation/PearsonsCorrelationTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/stat/correlation/PearsonsCorrelationTest.java
index 5f36a9793..130e867ba 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/stat/correlation/PearsonsCorrelationTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/stat/correlation/PearsonsCorrelationTest.java
@@ -21,7 +21,7 @@ import org.apache.commons.statistics.distribution.TDistribution;
import org.apache.commons.math4.legacy.exception.MathIllegalArgumentException;
import org.apache.commons.math4.legacy.linear.BlockRealMatrix;
import org.apache.commons.math4.legacy.linear.RealMatrix;
-import org.apache.commons.math4.legacy.util.FastMath;
+import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
import org.junit.Assert;
import org.junit.Test;
@@ -236,7 +236,7 @@ public class PearsonsCorrelationTest {
RealMatrix stdErrors = corrInstance.getCorrelationStandardErrors();
for (int i = 0; i < 5; i++) {
for (int j = 0; j < i; j++) {
- double t = FastMath.abs(rValues.getEntry(i, j)) / stdErrors.getEntry(i, j);
+ double t = AccurateMath.abs(rValues.getEntry(i, j)) / stdErrors.getEntry(i, j);
double p = 2 * (1 - tDistribution.cumulativeProbability(t));
Assert.assertEquals(p, pValues.getEntry(i, j), 10E-15);
}
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/stat/descriptive/MultivariateSummaryStatisticsTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/stat/descriptive/MultivariateSummaryStatisticsTest.java
index db06072a0..f0b3a7a8a 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/stat/descriptive/MultivariateSummaryStatisticsTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/stat/descriptive/MultivariateSummaryStatisticsTest.java
@@ -23,7 +23,7 @@ import org.apache.commons.math4.legacy.TestUtils;
import org.apache.commons.math4.legacy.exception.DimensionMismatchException;
import org.apache.commons.math4.legacy.exception.MathIllegalStateException;
import org.apache.commons.math4.legacy.stat.descriptive.moment.Mean;
-import org.apache.commons.math4.legacy.util.FastMath;
+import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
import org.junit.Test;
import org.junit.Assert;
@@ -211,8 +211,8 @@ public class MultivariateSummaryStatisticsTest {
Assert.assertEquals( 2.9129506302439405217, u.getGeometricMean()[1], 1.0e-10);
Assert.assertEquals( 2, u.getMean()[0], 1.0e-10);
Assert.assertEquals( 3, u.getMean()[1], 1.0e-10);
- Assert.assertEquals(FastMath.sqrt(2.0 / 3.0), u.getStandardDeviation()[0], 1.0e-10);
- Assert.assertEquals(FastMath.sqrt(2.0 / 3.0), u.getStandardDeviation()[1], 1.0e-10);
+ Assert.assertEquals(AccurateMath.sqrt(2.0 / 3.0), u.getStandardDeviation()[0], 1.0e-10);
+ Assert.assertEquals(AccurateMath.sqrt(2.0 / 3.0), u.getStandardDeviation()[1], 1.0e-10);
Assert.assertEquals(2.0 / 3.0, u.getCovariance().getEntry(0, 0), 1.0e-10);
Assert.assertEquals(2.0 / 3.0, u.getCovariance().getEntry(0, 1), 1.0e-10);
Assert.assertEquals(2.0 / 3.0, u.getCovariance().getEntry(1, 0), 1.0e-10);
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/stat/descriptive/ResizableDoubleArrayTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/stat/descriptive/ResizableDoubleArrayTest.java
index 8a2a5a7c1..220cfcc91 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/stat/descriptive/ResizableDoubleArrayTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/stat/descriptive/ResizableDoubleArrayTest.java
@@ -16,7 +16,7 @@
*/
package org.apache.commons.math4.legacy.stat.descriptive;
-import org.apache.commons.math4.legacy.util.MathArrays;
+import org.apache.commons.math4.legacy.core.MathArrays;
import org.apache.commons.statistics.distribution.DiscreteDistribution;
import org.apache.commons.statistics.distribution.UniformDiscreteDistribution;
import org.apache.commons.math4.legacy.exception.MathIllegalArgumentException;
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/stat/descriptive/StorelessUnivariateStatisticAbstractTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/stat/descriptive/StorelessUnivariateStatisticAbstractTest.java
index 7efbaca06..cde08f0ba 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/stat/descriptive/StorelessUnivariateStatisticAbstractTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/stat/descriptive/StorelessUnivariateStatisticAbstractTest.java
@@ -18,7 +18,7 @@ package org.apache.commons.math4.legacy.stat.descriptive;
import org.apache.commons.math4.legacy.TestUtils;
import org.apache.commons.math4.legacy.stat.descriptive.moment.SecondMoment;
-import org.apache.commons.math4.legacy.util.FastMath;
+import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
import org.junit.Assert;
import org.junit.Test;
@@ -191,7 +191,7 @@ public abstract class StorelessUnivariateStatisticAbstractTest
StorelessUnivariateStatistic replica = null;
// Randomly select a portion of testArray to load first
- long index = FastMath.round((FastMath.random()) * testArray.length);
+ long index = AccurateMath.round((AccurateMath.random()) * testArray.length);
// Put first half in master and copy master to replica
master.incrementAll(testArray, 0, (int) index);
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/stat/descriptive/SummaryStatisticsTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/stat/descriptive/SummaryStatisticsTest.java
index dac214050..1a8ca40d2 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/stat/descriptive/SummaryStatisticsTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/stat/descriptive/SummaryStatisticsTest.java
@@ -23,7 +23,7 @@ import org.apache.commons.math4.legacy.stat.descriptive.moment.GeometricMean;
import org.apache.commons.math4.legacy.stat.descriptive.moment.Mean;
import org.apache.commons.math4.legacy.stat.descriptive.moment.Variance;
import org.apache.commons.math4.legacy.stat.descriptive.summary.Sum;
-import org.apache.commons.math4.legacy.util.FastMath;
+import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
import org.junit.Assert;
import org.junit.Test;
/**
@@ -40,7 +40,7 @@ public class SummaryStatisticsTest {
private final double sum = 8;
private final double var = 0.666666666666666666667;
private final double popVar = 0.5;
- private final double std = FastMath.sqrt(var);
+ private final double std = AccurateMath.sqrt(var);
private final double n = 4;
private final double min = 1;
private final double max = 3;
@@ -275,7 +275,7 @@ public class SummaryStatisticsTest {
u.addValue(3);
Assert.assertEquals(4, u.getMean(), 1E-14);
Assert.assertEquals(4, u.getSumOfLogs(), 1E-14);
- Assert.assertEquals(FastMath.exp(2), u.getGeometricMean(), 1E-14);
+ Assert.assertEquals(AccurateMath.exp(2), u.getGeometricMean(), 1E-14);
u.clear();
u.addValue(1);
u.addValue(2);
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/stat/descriptive/UnivariateStatisticAbstractTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/stat/descriptive/UnivariateStatisticAbstractTest.java
index 308909271..2f3e2088c 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/stat/descriptive/UnivariateStatisticAbstractTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/stat/descriptive/UnivariateStatisticAbstractTest.java
@@ -24,7 +24,7 @@ import org.apache.commons.statistics.distribution.DiscreteDistribution;
import org.apache.commons.statistics.distribution.NormalDistribution;
import org.apache.commons.statistics.distribution.ContinuousDistribution;
import org.apache.commons.statistics.distribution.UniformDiscreteDistribution;
-import org.apache.commons.math4.legacy.util.FastMath;
+import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
import org.apache.commons.rng.simple.RandomSource;
import org.junit.Assert;
import org.junit.Test;
@@ -38,7 +38,7 @@ public abstract class UnivariateStatisticAbstractTest {
protected double geoMean = 12.070589161633011d;
protected double var = 10.00235930735931d;
- protected double std = FastMath.sqrt(var);
+ protected double std = AccurateMath.sqrt(var);
protected double skew = 1.437423729196190d;
protected double kurt = 2.377191264804700d;
@@ -59,7 +59,7 @@ public abstract class UnivariateStatisticAbstractTest {
protected double weightedMean = 12.366995073891626d;
protected double weightedVar = 9.974760968886391d;
- protected double weightedStd = FastMath.sqrt(weightedVar);
+ protected double weightedStd = AccurateMath.sqrt(weightedVar);
protected double weightedProduct = 8517647448765288000000d;
protected double weightedSum = 251.05d;
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/stat/descriptive/moment/StandardDeviationTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/stat/descriptive/moment/StandardDeviationTest.java
index 7be13d2bd..d2dd77c98 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/stat/descriptive/moment/StandardDeviationTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/stat/descriptive/moment/StandardDeviationTest.java
@@ -18,7 +18,7 @@ package org.apache.commons.math4.legacy.stat.descriptive.moment;
import org.apache.commons.math4.legacy.stat.descriptive.StorelessUnivariateStatisticAbstractTest;
import org.apache.commons.math4.legacy.stat.descriptive.UnivariateStatistic;
-import org.apache.commons.math4.legacy.util.FastMath;
+import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
import org.junit.Assert;
import org.junit.Test;
@@ -89,7 +89,7 @@ public class StandardDeviationTest extends StorelessUnivariateStatisticAbstractT
for (int i = 0; i < v.length; i++) {
sum += (v[i] - mean) * (v[i] - mean);
}
- return FastMath.sqrt(sum / v.length);
+ return AccurateMath.sqrt(sum / v.length);
}
}
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/stat/descriptive/moment/VarianceTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/stat/descriptive/moment/VarianceTest.java
index e7751bea3..a3261af32 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/stat/descriptive/moment/VarianceTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/stat/descriptive/moment/VarianceTest.java
@@ -18,7 +18,7 @@ package org.apache.commons.math4.legacy.stat.descriptive.moment;
import org.apache.commons.math4.legacy.stat.descriptive.StorelessUnivariateStatisticAbstractTest;
import org.apache.commons.math4.legacy.stat.descriptive.UnivariateStatistic;
-import org.apache.commons.math4.legacy.util.MathArrays;
+import org.apache.commons.math4.legacy.core.MathArrays;
import org.junit.Assert;
import org.junit.Test;
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/stat/descriptive/rank/PSquarePercentileTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/stat/descriptive/rank/PSquarePercentileTest.java
index b36454ca6..e7bf0d315 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/stat/descriptive/rank/PSquarePercentileTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/stat/descriptive/rank/PSquarePercentileTest.java
@@ -37,7 +37,7 @@ import org.apache.commons.math4.legacy.stat.descriptive.StorelessUnivariateStati
import org.apache.commons.math4.legacy.stat.descriptive.StorelessUnivariateStatisticAbstractTest;
import org.apache.commons.math4.legacy.stat.descriptive.UnivariateStatistic;
import org.apache.commons.math4.legacy.stat.descriptive.rank.PSquarePercentile.PSquareMarkers;
-import org.apache.commons.math4.legacy.util.FastMath;
+import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
import org.junit.Assert;
import org.junit.Test;
@@ -75,7 +75,7 @@ public class PSquarePercentileTest extends
StorelessUnivariateStatistic replica = null;
// select a portion of testArray till 75 % of the length to load first
- long index = FastMath.round(0.75 * testArray.length);
+ long index = AccurateMath.round(0.75 * testArray.length);
// Put first half in master and copy master to replica
master.incrementAll(testArray, 0, (int) index);
@@ -109,7 +109,7 @@ public class PSquarePercentileTest extends
// select a portion of testArray which is 10% of the length to load
// first
- long index = FastMath.round(0.1 * testArray.length);
+ long index = AccurateMath.round(0.1 * testArray.length);
// Put first half in master and copy master to replica
master.incrementAll(testArray, 0, (int) index);
@@ -542,8 +542,8 @@ public class PSquarePercentileTest extends
if (Double.isNaN(a)) {
Assert.assertTrue("" + b + " is not NaN.", Double.isNaN(a));
} else {
- double max = FastMath.max(a, b);
- double percentage = FastMath.abs(a - b) / max;
+ double max = AccurateMath.max(a, b);
+ double percentage = AccurateMath.abs(a - b) / max;
double deviation = delta;
Assert.assertTrue(String.format(
"Deviated = %f and is beyond %f as a=%f, b=%f",
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/stat/inference/GTestTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/stat/inference/GTestTest.java
index 2fdd6a893..3f544eb90 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/stat/inference/GTestTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/stat/inference/GTestTest.java
@@ -21,7 +21,7 @@ import org.apache.commons.math4.legacy.exception.NotPositiveException;
import org.apache.commons.math4.legacy.exception.NotStrictlyPositiveException;
import org.apache.commons.math4.legacy.exception.OutOfRangeException;
import org.apache.commons.math4.legacy.exception.ZeroException;
-import org.apache.commons.math4.legacy.util.FastMath;
+import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
import org.junit.Assert;
import org.junit.Test;
@@ -275,17 +275,17 @@ public class GTestTest {
// negative because k11 is lower than expected
Assert.assertTrue(testStatistic.rootLogLikelihoodRatio(36, 21928, 60280, 623876) < 0.0);
- Assert.assertEquals(FastMath.sqrt(2.772589), testStatistic.rootLogLikelihoodRatio(1, 0, 0, 1), 0.000001);
- Assert.assertEquals(-FastMath.sqrt(2.772589), testStatistic.rootLogLikelihoodRatio(0, 1, 1, 0), 0.000001);
- Assert.assertEquals(FastMath.sqrt(27.72589), testStatistic.rootLogLikelihoodRatio(10, 0, 0, 10), 0.00001);
+ Assert.assertEquals(AccurateMath.sqrt(2.772589), testStatistic.rootLogLikelihoodRatio(1, 0, 0, 1), 0.000001);
+ Assert.assertEquals(-AccurateMath.sqrt(2.772589), testStatistic.rootLogLikelihoodRatio(0, 1, 1, 0), 0.000001);
+ Assert.assertEquals(AccurateMath.sqrt(27.72589), testStatistic.rootLogLikelihoodRatio(10, 0, 0, 10), 0.00001);
- Assert.assertEquals(FastMath.sqrt(39.33052), testStatistic.rootLogLikelihoodRatio(5, 1995, 0, 100000), 0.00001);
- Assert.assertEquals(-FastMath.sqrt(39.33052), testStatistic.rootLogLikelihoodRatio(0, 100000, 5, 1995), 0.00001);
+ Assert.assertEquals(AccurateMath.sqrt(39.33052), testStatistic.rootLogLikelihoodRatio(5, 1995, 0, 100000), 0.00001);
+ Assert.assertEquals(-AccurateMath.sqrt(39.33052), testStatistic.rootLogLikelihoodRatio(0, 100000, 5, 1995), 0.00001);
- Assert.assertEquals(FastMath.sqrt(4730.737), testStatistic.rootLogLikelihoodRatio(1000, 1995, 1000, 100000), 0.001);
- Assert.assertEquals(-FastMath.sqrt(4730.737), testStatistic.rootLogLikelihoodRatio(1000, 100000, 1000, 1995), 0.001);
+ Assert.assertEquals(AccurateMath.sqrt(4730.737), testStatistic.rootLogLikelihoodRatio(1000, 1995, 1000, 100000), 0.001);
+ Assert.assertEquals(-AccurateMath.sqrt(4730.737), testStatistic.rootLogLikelihoodRatio(1000, 100000, 1000, 1995), 0.001);
- Assert.assertEquals(FastMath.sqrt(5734.343), testStatistic.rootLogLikelihoodRatio(1000, 1000, 1000, 100000), 0.001);
- Assert.assertEquals(FastMath.sqrt(5714.932), testStatistic.rootLogLikelihoodRatio(1000, 1000, 1000, 99000), 0.001);
+ Assert.assertEquals(AccurateMath.sqrt(5734.343), testStatistic.rootLogLikelihoodRatio(1000, 1000, 1000, 100000), 0.001);
+ Assert.assertEquals(AccurateMath.sqrt(5714.932), testStatistic.rootLogLikelihoodRatio(1000, 1000, 1000, 99000), 0.001);
}
}
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/stat/inference/InferenceTestUtilsTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/stat/inference/InferenceTestUtilsTest.java
index e40d333e9..f03e710a5 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/stat/inference/InferenceTestUtilsTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/stat/inference/InferenceTestUtilsTest.java
@@ -27,7 +27,7 @@ import org.apache.commons.math4.legacy.exception.NullArgumentException;
import org.apache.commons.math4.legacy.exception.NumberIsTooSmallException;
import org.apache.commons.math4.legacy.exception.OutOfRangeException;
import org.apache.commons.math4.legacy.stat.descriptive.SummaryStatistics;
-import org.apache.commons.math4.legacy.util.FastMath;
+import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
import org.junit.Assert;
import org.junit.Test;
@@ -514,18 +514,18 @@ public class InferenceTestUtilsTest {
// negative because k11 is lower than expected
Assert.assertTrue(InferenceTestUtils.rootLogLikelihoodRatio(36, 21928, 60280, 623876) < 0.0);
- Assert.assertEquals(FastMath.sqrt(2.772589), InferenceTestUtils.rootLogLikelihoodRatio(1, 0, 0, 1), 0.000001);
- Assert.assertEquals(-FastMath.sqrt(2.772589), InferenceTestUtils.rootLogLikelihoodRatio(0, 1, 1, 0), 0.000001);
- Assert.assertEquals(FastMath.sqrt(27.72589), InferenceTestUtils.rootLogLikelihoodRatio(10, 0, 0, 10), 0.00001);
+ Assert.assertEquals(AccurateMath.sqrt(2.772589), InferenceTestUtils.rootLogLikelihoodRatio(1, 0, 0, 1), 0.000001);
+ Assert.assertEquals(-AccurateMath.sqrt(2.772589), InferenceTestUtils.rootLogLikelihoodRatio(0, 1, 1, 0), 0.000001);
+ Assert.assertEquals(AccurateMath.sqrt(27.72589), InferenceTestUtils.rootLogLikelihoodRatio(10, 0, 0, 10), 0.00001);
- Assert.assertEquals(FastMath.sqrt(39.33052), InferenceTestUtils.rootLogLikelihoodRatio(5, 1995, 0, 100000), 0.00001);
- Assert.assertEquals(-FastMath.sqrt(39.33052), InferenceTestUtils.rootLogLikelihoodRatio(0, 100000, 5, 1995), 0.00001);
+ Assert.assertEquals(AccurateMath.sqrt(39.33052), InferenceTestUtils.rootLogLikelihoodRatio(5, 1995, 0, 100000), 0.00001);
+ Assert.assertEquals(-AccurateMath.sqrt(39.33052), InferenceTestUtils.rootLogLikelihoodRatio(0, 100000, 5, 1995), 0.00001);
- Assert.assertEquals(FastMath.sqrt(4730.737), InferenceTestUtils.rootLogLikelihoodRatio(1000, 1995, 1000, 100000), 0.001);
- Assert.assertEquals(-FastMath.sqrt(4730.737), InferenceTestUtils.rootLogLikelihoodRatio(1000, 100000, 1000, 1995), 0.001);
+ Assert.assertEquals(AccurateMath.sqrt(4730.737), InferenceTestUtils.rootLogLikelihoodRatio(1000, 1995, 1000, 100000), 0.001);
+ Assert.assertEquals(-AccurateMath.sqrt(4730.737), InferenceTestUtils.rootLogLikelihoodRatio(1000, 100000, 1000, 1995), 0.001);
- Assert.assertEquals(FastMath.sqrt(5734.343), InferenceTestUtils.rootLogLikelihoodRatio(1000, 1000, 1000, 100000), 0.001);
- Assert.assertEquals(FastMath.sqrt(5714.932), InferenceTestUtils.rootLogLikelihoodRatio(1000, 1000, 1000, 99000), 0.001);
+ Assert.assertEquals(AccurateMath.sqrt(5734.343), InferenceTestUtils.rootLogLikelihoodRatio(1000, 1000, 1000, 100000), 0.001);
+ Assert.assertEquals(AccurateMath.sqrt(5714.932), InferenceTestUtils.rootLogLikelihoodRatio(1000, 1000, 1000, 99000), 0.001);
}
@Test
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/stat/inference/KolmogorovSmirnovTestTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/stat/inference/KolmogorovSmirnovTestTest.java
index d779cfe1e..8346f8fdc 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/stat/inference/KolmogorovSmirnovTestTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/stat/inference/KolmogorovSmirnovTestTest.java
@@ -26,8 +26,8 @@ import org.apache.commons.statistics.distribution.UniformContinuousDistribution;
import org.apache.commons.rng.simple.RandomSource;
import org.apache.commons.rng.UniformRandomProvider;
import org.apache.commons.numbers.combinatorics.BinomialCoefficient;
-import org.apache.commons.math4.legacy.util.FastMath;
-import org.apache.commons.math4.legacy.util.MathArrays;
+import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
+import org.apache.commons.math4.legacy.core.MathArrays;
import org.apache.commons.math4.legacy.exception.NotANumberException;
import org.apache.commons.math4.legacy.exception.InsufficientDataException;
import org.junit.Assert;
@@ -261,7 +261,7 @@ public class KolmogorovSmirnovTestTest {
n = k[i];
m = k[j];
for (int l = 0; l < alpha.length; l++) {
- final double dCrit = c[l] * FastMath.sqrt((n + m) / (n * m));
+ final double dCrit = c[l] * AccurateMath.sqrt((n + m) / (n * m));
checkApproximateTable(k[i], k[j], dCrit, alpha[l], tol);
}
}
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/stat/ranking/NaturalRankingTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/stat/ranking/NaturalRankingTest.java
index acd938e6a..25e40f5aa 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/stat/ranking/NaturalRankingTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/stat/ranking/NaturalRankingTest.java
@@ -185,27 +185,27 @@ public class NaturalRankingTest {
randomGenerator);
double[] ranks = ranking.rank(exampleData);
double[] correctRanks = { 5, 3, 6, 7, 3, 8, Double.NaN, 1, 2 };
- if (!org.apache.commons.math4.legacy.util.MathArrays.equalsIncludingNaN(correctRanks, ranks)) continue;
+ if (!org.apache.commons.math4.legacy.core.MathArrays.equalsIncludingNaN(correctRanks, ranks)) continue;
ranks = ranking.rank(tiesFirst);
correctRanks = new double[] { 1, 2, 4, 3, 5 };
- if (!org.apache.commons.math4.legacy.util.MathArrays.equalsIncludingNaN(correctRanks, ranks)) continue;
+ if (!org.apache.commons.math4.legacy.core.MathArrays.equalsIncludingNaN(correctRanks, ranks)) continue;
ranks = ranking.rank(tiesLast);
correctRanks = new double[] { 3, 3, 2, 1 };
- if (!org.apache.commons.math4.legacy.util.MathArrays.equalsIncludingNaN(correctRanks, ranks)) continue;
+ if (!org.apache.commons.math4.legacy.core.MathArrays.equalsIncludingNaN(correctRanks, ranks)) continue;
ranks = ranking.rank(multipleNaNs);
correctRanks = new double[] { 1, 2, Double.NaN, Double.NaN };
- if (!org.apache.commons.math4.legacy.util.MathArrays.equalsIncludingNaN(correctRanks, ranks)) continue;
+ if (!org.apache.commons.math4.legacy.core.MathArrays.equalsIncludingNaN(correctRanks, ranks)) continue;
ranks = ranking.rank(multipleTies);
correctRanks = new double[] { 3, 2, 4, 4, 6, 7, 1 };
- if (!org.apache.commons.math4.legacy.util.MathArrays.equalsIncludingNaN(correctRanks, ranks)) continue;
+ if (!org.apache.commons.math4.legacy.core.MathArrays.equalsIncludingNaN(correctRanks, ranks)) continue;
ranks = ranking.rank(allSame);
correctRanks = new double[] { 2, 3, 3, 3 };
- if (!org.apache.commons.math4.legacy.util.MathArrays.equalsIncludingNaN(correctRanks, ranks)) continue;
+ if (!org.apache.commons.math4.legacy.core.MathArrays.equalsIncludingNaN(correctRanks, ranks)) continue;
++count;
//System.out.println("seed = " + i);
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/stat/regression/MillerUpdatingRegressionTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/stat/regression/MillerUpdatingRegressionTest.java
index ac3d11fbd..201bd3588 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/stat/regression/MillerUpdatingRegressionTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/stat/regression/MillerUpdatingRegressionTest.java
@@ -20,7 +20,7 @@ import org.apache.commons.math4.legacy.TestUtils;
import org.apache.commons.math4.legacy.exception.MathIllegalArgumentException;
import org.apache.commons.math4.legacy.linear.RealMatrix;
import org.apache.commons.math4.legacy.stat.correlation.PearsonsCorrelation;
-import org.apache.commons.math4.legacy.util.FastMath;
+import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
import org.junit.Assert;
import org.junit.Test;
@@ -68,10 +68,10 @@ public class MillerUpdatingRegressionTest {
double[] y = new double[airdata[0].length];
for (int i = 0; i < airdata[0].length; i++) {
xAll[i] = new double[3];
- xAll[i][0] = FastMath.log(airdata[3][i]);
- xAll[i][1] = FastMath.log(airdata[4][i]);
+ xAll[i][0] = AccurateMath.log(airdata[3][i]);
+ xAll[i][1] = AccurateMath.log(airdata[4][i]);
xAll[i][2] = airdata[5][i];
- y[i] = FastMath.log(airdata[2][i]);
+ y[i] = AccurateMath.log(airdata[2][i]);
}
instance.addObservations(xAll, y);
if (instance.getN() != xAll.length) {
@@ -170,10 +170,10 @@ public class MillerUpdatingRegressionTest {
for (int i = 0; i < airdata[0].length; i++) {
x[i] = new double[4];
x[i][0] = 1.0;
- x[i][1] = FastMath.log(airdata[3][i]);
- x[i][2] = FastMath.log(airdata[4][i]);
+ x[i][1] = AccurateMath.log(airdata[3][i]);
+ x[i][2] = AccurateMath.log(airdata[4][i]);
x[i][3] = airdata[5][i];
- y[i] = FastMath.log(airdata[2][i]);
+ y[i] = AccurateMath.log(airdata[2][i]);
}
instance.addObservations(x, y);
@@ -202,10 +202,10 @@ public class MillerUpdatingRegressionTest {
double[] y = new double[airdata[0].length];
for (int i = 0; i < airdata[0].length; i++) {
x[i] = new double[3];
- x[i][0] = FastMath.log(airdata[3][i]);
- x[i][1] = FastMath.log(airdata[4][i]);
+ x[i][0] = AccurateMath.log(airdata[3][i]);
+ x[i][1] = AccurateMath.log(airdata[4][i]);
x[i][2] = airdata[5][i];
- y[i] = FastMath.log(airdata[2][i]);
+ y[i] = AccurateMath.log(airdata[2][i]);
}
instance.addObservations(x, y);
@@ -723,10 +723,10 @@ public class MillerUpdatingRegressionTest {
// for (int i = 0; i < airdata[0].length; i++) {
// x[i] = new double[4];
// x[i][0] = 1.0;
-// x[i][1] = FastMath.log(airdata[3][i]);
-// x[i][2] = FastMath.log(airdata[4][i]);
+// x[i][1] = AccurateMath.log(airdata[3][i]);
+// x[i][2] = AccurateMath.log(airdata[4][i]);
// x[i][3] = airdata[5][i];
-// y[i] = FastMath.log(airdata[2][i]);
+// y[i] = AccurateMath.log(airdata[2][i]);
// }
//
// instance.addObservations(x, y);
@@ -740,16 +740,16 @@ public class MillerUpdatingRegressionTest {
//
// double[] beta = result.getParameterEstimates();
// double[] betar = resultInverse.getParameterEstimates();
-// if (FastMath.abs(beta[0] - betar[0]) > 1.0e-14) {
+// if (AccurateMath.abs(beta[0] - betar[0]) > 1.0e-14) {
// Assert.fail("Parameters not correct after reorder (0,3)");
// }
-// if (FastMath.abs(beta[1] - betar[1]) > 1.0e-14) {
+// if (AccurateMath.abs(beta[1] - betar[1]) > 1.0e-14) {
// Assert.fail("Parameters not correct after reorder (1,2)");
// }
-// if (FastMath.abs(beta[2] - betar[2]) > 1.0e-14) {
+// if (AccurateMath.abs(beta[2] - betar[2]) > 1.0e-14) {
// Assert.fail("Parameters not correct after reorder (2,1)");
// }
-// if (FastMath.abs(beta[3] - betar[3]) > 1.0e-14) {
+// if (AccurateMath.abs(beta[3] - betar[3]) > 1.0e-14) {
// Assert.fail("Parameters not correct after reorder (3,0)");
// }
// }
@@ -765,8 +765,8 @@ public class MillerUpdatingRegressionTest {
x[i] = new double[4];
x2[i] = new double[5];
x[i][0] = 1.0;
- x[i][1] = FastMath.log(airdata[3][i]);
- x[i][2] = FastMath.log(airdata[4][i]);
+ x[i][1] = AccurateMath.log(airdata[3][i]);
+ x[i][2] = AccurateMath.log(airdata[4][i]);
x[i][3] = airdata[5][i];
x2[i][0] = x[i][0];
@@ -775,7 +775,7 @@ public class MillerUpdatingRegressionTest {
x2[i][3] = x[i][3];
x2[i][4] = x[i][3];
- y[i] = FastMath.log(airdata[2][i]);
+ y[i] = AccurateMath.log(airdata[2][i]);
}
instance.addObservations(x, y);
@@ -791,14 +791,14 @@ public class MillerUpdatingRegressionTest {
double[] ser = resultRedundant.getStdErrorOfEstimates();
for (int i = 0; i < beta.length; i++) {
- if (FastMath.abs(beta[i] - betar[i]) > 1.0e-8) {
+ if (AccurateMath.abs(beta[i] - betar[i]) > 1.0e-8) {
Assert.fail("Parameters not correctly estimated");
}
- if (FastMath.abs(se[i] - ser[i]) > 1.0e-8) {
+ if (AccurateMath.abs(se[i] - ser[i]) > 1.0e-8) {
Assert.fail("Standard errors not correctly estimated");
}
for (int j = 0; j < i; j++) {
- if (FastMath.abs(result.getCovarianceOfParameters(i, j)
+ if (AccurateMath.abs(result.getCovarianceOfParameters(i, j)
- resultRedundant.getCovarianceOfParameters(i, j)) > 1.0e-8) {
Assert.fail("Variance Covariance not correct");
}
@@ -825,8 +825,8 @@ public class MillerUpdatingRegressionTest {
x[i] = new double[4];
x2[i] = new double[7];
x[i][0] = 1.0;
- x[i][1] = FastMath.log(airdata[3][i]);
- x[i][2] = FastMath.log(airdata[4][i]);
+ x[i][1] = AccurateMath.log(airdata[3][i]);
+ x[i][2] = AccurateMath.log(airdata[4][i]);
x[i][3] = airdata[5][i];
x2[i][0] = x[i][0];
@@ -837,7 +837,7 @@ public class MillerUpdatingRegressionTest {
x2[i][5] = x[i][3];
x2[i][6] = x[i][2];
- y[i] = FastMath.log(airdata[2][i]);
+ y[i] = AccurateMath.log(airdata[2][i]);
}
instance.addObservations(x, y);
@@ -852,71 +852,71 @@ public class MillerUpdatingRegressionTest {
double[] se = result.getStdErrorOfEstimates();
double[] ser = resultRedundant.getStdErrorOfEstimates();
- if (FastMath.abs(beta[0] - betar[0]) > 1.0e-8) {
+ if (AccurateMath.abs(beta[0] - betar[0]) > 1.0e-8) {
Assert.fail("Parameters not correct after reorder (0,3)");
}
- if (FastMath.abs(beta[1] - betar[2]) > 1.0e-8) {
+ if (AccurateMath.abs(beta[1] - betar[2]) > 1.0e-8) {
Assert.fail("Parameters not correct after reorder (1,2)");
}
- if (FastMath.abs(beta[2] - betar[3]) > 1.0e-8) {
+ if (AccurateMath.abs(beta[2] - betar[3]) > 1.0e-8) {
Assert.fail("Parameters not correct after reorder (2,1)");
}
- if (FastMath.abs(beta[3] - betar[5]) > 1.0e-8) {
+ if (AccurateMath.abs(beta[3] - betar[5]) > 1.0e-8) {
Assert.fail("Parameters not correct after reorder (3,0)");
}
- if (FastMath.abs(se[0] - ser[0]) > 1.0e-8) {
+ if (AccurateMath.abs(se[0] - ser[0]) > 1.0e-8) {
Assert.fail("Se not correct after reorder (0,3)");
}
- if (FastMath.abs(se[1] - ser[2]) > 1.0e-8) {
+ if (AccurateMath.abs(se[1] - ser[2]) > 1.0e-8) {
Assert.fail("Se not correct after reorder (1,2)");
}
- if (FastMath.abs(se[2] - ser[3]) > 1.0e-8) {
+ if (AccurateMath.abs(se[2] - ser[3]) > 1.0e-8) {
Assert.fail("Se not correct after reorder (2,1)");
}
- if (FastMath.abs(se[3] - ser[5]) > 1.0e-8) {
+ if (AccurateMath.abs(se[3] - ser[5]) > 1.0e-8) {
Assert.fail("Se not correct after reorder (3,0)");
}
- if (FastMath.abs(result.getCovarianceOfParameters(0, 0)
+ if (AccurateMath.abs(result.getCovarianceOfParameters(0, 0)
- resultRedundant.getCovarianceOfParameters(0, 0)) > 1.0e-8) {
Assert.fail("VCV not correct after reorder (0,0)");
}
- if (FastMath.abs(result.getCovarianceOfParameters(0, 1)
+ if (AccurateMath.abs(result.getCovarianceOfParameters(0, 1)
- resultRedundant.getCovarianceOfParameters(0, 2)) > 1.0e-8) {
Assert.fail("VCV not correct after reorder (0,1)<->(0,2)");
}
- if (FastMath.abs(result.getCovarianceOfParameters(0, 2)
+ if (AccurateMath.abs(result.getCovarianceOfParameters(0, 2)
- resultRedundant.getCovarianceOfParameters(0, 3)) > 1.0e-8) {
Assert.fail("VCV not correct after reorder (0,2)<->(0,1)");
}
- if (FastMath.abs(result.getCovarianceOfParameters(0, 3)
+ if (AccurateMath.abs(result.getCovarianceOfParameters(0, 3)
- resultRedundant.getCovarianceOfParameters(0, 5)) > 1.0e-8) {
Assert.fail("VCV not correct after reorder (0,3)<->(0,3)");
}
- if (FastMath.abs(result.getCovarianceOfParameters(1, 0)
+ if (AccurateMath.abs(result.getCovarianceOfParameters(1, 0)
- resultRedundant.getCovarianceOfParameters(2, 0)) > 1.0e-8) {
Assert.fail("VCV not correct after reorder (1,0)<->(2,0)");
}
- if (FastMath.abs(result.getCovarianceOfParameters(1, 1)
+ if (AccurateMath.abs(result.getCovarianceOfParameters(1, 1)
- resultRedundant.getCovarianceOfParameters(2, 2)) > 1.0e-8) {
Assert.fail("VCV not correct (1,1)<->(2,1)");
}
- if (FastMath.abs(result.getCovarianceOfParameters(1, 2)
+ if (AccurateMath.abs(result.getCovarianceOfParameters(1, 2)
- resultRedundant.getCovarianceOfParameters(2, 3)) > 1.0e-8) {
Assert.fail("VCV not correct (1,2)<->(2,2)");
}
- if (FastMath.abs(result.getCovarianceOfParameters(2, 0)
+ if (AccurateMath.abs(result.getCovarianceOfParameters(2, 0)
- resultRedundant.getCovarianceOfParameters(3, 0)) > 1.0e-8) {
Assert.fail("VCV not correct (2,0)<->(1,0)");
}
- if (FastMath.abs(result.getCovarianceOfParameters(2, 1)
+ if (AccurateMath.abs(result.getCovarianceOfParameters(2, 1)
- resultRedundant.getCovarianceOfParameters(3, 2)) > 1.0e-8) {
Assert.fail("VCV not correct (2,1)<->(1,2)");
}
- if (FastMath.abs(result.getCovarianceOfParameters(3, 3)
+ if (AccurateMath.abs(result.getCovarianceOfParameters(3, 3)
- resultRedundant.getCovarianceOfParameters(5, 5)) > 1.0e-8) {
Assert.fail("VCV not correct (3,3)<->(3,2)");
}
@@ -941,10 +941,10 @@ public class MillerUpdatingRegressionTest {
for (int i = 0; i < airdata[0].length; i++) {
x[i] = new double[4];
x[i][0] = 1.0;
- x[i][1] = FastMath.log(airdata[3][i]);
- x[i][2] = FastMath.log(airdata[4][i]);
+ x[i][1] = AccurateMath.log(airdata[3][i]);
+ x[i][2] = AccurateMath.log(airdata[4][i]);
x[i][3] = airdata[5][i];
- y[i] = FastMath.log(airdata[2][i]);
+ y[i] = AccurateMath.log(airdata[2][i]);
off = 0;
for (int j = 0; j < 4; j++) {
double tmp = x[i][j];
@@ -959,7 +959,7 @@ public class MillerUpdatingRegressionTest {
RealMatrix corr = pearson.getCorrelationMatrix();
off = 0;
for (int i = 0; i < 4; i++, off += (i + 1)) {
- diag[i] = FastMath.sqrt(cp[off]);
+ diag[i] = AccurateMath.sqrt(cp[off]);
}
instance.addObservations(x, y);
@@ -969,14 +969,14 @@ public class MillerUpdatingRegressionTest {
int off2 = 6;
for (int i = 0; i < 4; i++) {
for (int j = 0; j < i; j++) {
- if (FastMath.abs(pc[idx] - cp[off] / (diag[i] * diag[j])) > 1.0e-8) {
+ if (AccurateMath.abs(pc[idx] - cp[off] / (diag[i] * diag[j])) > 1.0e-8) {
Assert.fail("Failed cross products... i = " + i + " j = " + j);
}
++idx;
++off;
}
++off;
- if (FastMath.abs(pc[i+off2] - yxcorr[ i] / (FastMath.sqrt(sumysq) * diag[i])) > 1.0e-8) {
+ if (AccurateMath.abs(pc[i+off2] - yxcorr[ i] / (AccurateMath.sqrt(sumysq) * diag[i])) > 1.0e-8) {
Assert.fail("Assert.failed cross product i = " + i + " y");
}
}
@@ -986,7 +986,7 @@ public class MillerUpdatingRegressionTest {
for (int i = 1; i < 4; i++) {
for (int j = 1; j < i; j++) {
- if (FastMath.abs(pc2[idx] - corr.getEntry(j, i)) > 1.0e-8) {
+ if (AccurateMath.abs(pc2[idx] - corr.getEntry(j, i)) > 1.0e-8) {
Assert.fail("Failed cross products... i = " + i + " j = " + j);
}
++idx;
@@ -1007,10 +1007,10 @@ public class MillerUpdatingRegressionTest {
for (int i = 0; i < airdata[0].length; i++) {
x[i] = new double[4];
x[i][0] = 1.0;
- x[i][1] = FastMath.log(airdata[3][i]);
- x[i][2] = FastMath.log(airdata[4][i]);
+ x[i][1] = AccurateMath.log(airdata[3][i]);
+ x[i][2] = AccurateMath.log(airdata[4][i]);
x[i][3] = airdata[5][i];
- y[i] = FastMath.log(airdata[2][i]);
+ y[i] = AccurateMath.log(airdata[2][i]);
}
instance.addObservations(x, y);
OLSMultipleLinearRegression ols = new OLSMultipleLinearRegression();
@@ -1030,10 +1030,10 @@ public class MillerUpdatingRegressionTest {
double[] y = new double[airdata[0].length];
for (int i = 0; i < airdata[0].length; i++) {
x[i] = new double[3];
- x[i][0] = FastMath.log(airdata[3][i]);
- x[i][1] = FastMath.log(airdata[4][i]);
+ x[i][0] = AccurateMath.log(airdata[3][i]);
+ x[i][1] = AccurateMath.log(airdata[4][i]);
x[i][2] = airdata[5][i];
- y[i] = FastMath.log(airdata[2][i]);
+ y[i] = AccurateMath.log(airdata[2][i]);
}
instance.addObservations(x, y);
OLSMultipleLinearRegression ols = new OLSMultipleLinearRegression();
@@ -1066,15 +1066,15 @@ public class MillerUpdatingRegressionTest {
double[] y = new double[airdata[0].length];
for (int i = 0; i < airdata[0].length; i++) {
x[i] = new double[3];
- x[i][i0] = FastMath.log(airdata[3][i]);
- x[i][i1] = FastMath.log(airdata[4][i]);
+ x[i][i0] = AccurateMath.log(airdata[3][i]);
+ x[i][i1] = AccurateMath.log(airdata[4][i]);
x[i][i_exclude] = airdata[5][i];
xReduced[i] = new double[2];
- xReduced[i][0] = FastMath.log(airdata[3][i]);
- xReduced[i][1] = FastMath.log(airdata[4][i]);
+ xReduced[i][0] = AccurateMath.log(airdata[3][i]);
+ xReduced[i][1] = AccurateMath.log(airdata[4][i]);
- y[i] = FastMath.log(airdata[2][i]);
+ y[i] = AccurateMath.log(airdata[2][i]);
}
instance.addObservations(x, y);
diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/stat/regression/SimpleRegressionTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/stat/regression/SimpleRegressionTest.java
index 1bb90d42a..d1b7eb0b7 100644
--- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/stat/regression/SimpleRegressionTest.java
+++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/stat/regression/SimpleRegressionTest.java
@@ -22,7 +22,7 @@ import org.apache.commons.math4.legacy.exception.MathIllegalArgumentException;
import org.apache.commons.math4.legacy.exception.OutOfRangeException;
import org.apache.commons.rng.UniformRandomProvider;
import org.apache.commons.rng.simple.RandomSource;
-import org.apache.commons.math4.legacy.util.FastMath;
+import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
import org.junit.Assert;
import org.junit.Test;
@@ -163,46 +163,46 @@ public final class SimpleRegressionTest {
if (model1.getN() != model2.getN()) {
return false;
}
- if (FastMath.abs(model1.getIntercept() - model2.getIntercept()) > tol) {
+ if (AccurateMath.abs(model1.getIntercept() - model2.getIntercept()) > tol) {
return false;
}
- if (FastMath.abs(model1.getInterceptStdErr() - model2.getInterceptStdErr()) > tol) {
+ if (AccurateMath.abs(model1.getInterceptStdErr() - model2.getInterceptStdErr()) > tol) {
return false;
}
- if (FastMath.abs(model1.getMeanSquareError() - model2.getMeanSquareError()) > tol) {
+ if (AccurateMath.abs(model1.getMeanSquareError() - model2.getMeanSquareError()) > tol) {
return false;
}
- if (FastMath.abs(model1.getR() - model2.getR()) > tol) {
+ if (AccurateMath.abs(model1.getR() - model2.getR()) > tol) {
return false;
}
- if (FastMath.abs(model1.getRegressionSumSquares() - model2.getRegressionSumSquares()) > tol) {
+ if (AccurateMath.abs(model1.getRegressionSumSquares() - model2.getRegressionSumSquares()) > tol) {
return false;
}
- if (FastMath.abs(model1.getRSquare() - model2.getRSquare()) > tol) {
+ if (AccurateMath.abs(model1.getRSquare() - model2.getRSquare()) > tol) {
return false;
}
- if (FastMath.abs(model1.getSignificance() - model2.getSignificance()) > tol) {
+ if (AccurateMath.abs(model1.getSignificance() - model2.getSignificance()) > tol) {
return false;
}
- if (FastMath.abs(model1.getSlope() - model2.getSlope()) > tol) {
+ if (AccurateMath.abs(model1.getSlope() - model2.getSlope()) > tol) {
return false;
}
- if (FastMath.abs(model1.getSlopeConfidenceInterval() - model2.getSlopeConfidenceInterval()) > tol) {
+ if (AccurateMath.abs(model1.getSlopeConfidenceInterval() - model2.getSlopeConfidenceInterval()) > tol) {
return false;
}
- if (FastMath.abs(model1.getSlopeStdErr() - model2.getSlopeStdErr()) > tol) {
+ if (AccurateMath.abs(model1.getSlopeStdErr() - model2.getSlopeStdErr()) > tol) {
return false;
}
- if (FastMath.abs(model1.getSumOfCrossProducts() - model2.getSumOfCrossProducts()) > tol) {
+ if (AccurateMath.abs(model1.getSumOfCrossProducts() - model2.getSumOfCrossProducts()) > tol) {
return false;
}
- if (FastMath.abs(model1.getSumSquaredErrors() - model2.getSumSquaredErrors()) > tol) {
+ if (AccurateMath.abs(model1.getSumSquaredErrors() - model2.getSumSquaredErrors()) > tol) {
return false;
}
- if (FastMath.abs(model1.getTotalSumSquares() - model2.getTotalSumSquares()) > tol) {
+ if (AccurateMath.abs(model1.getTotalSumSquares() - model2.getTotalSumSquares()) > tol) {
return false;
}
- if (FastMath.abs(model1.getXSumSquares() - model2.getXSumSquares()) > tol) {
+ if (AccurateMath.abs(model1.getXSumSquares() - model2.getXSumSquares()) > tol) {
return false;
}
return true;
diff --git a/commons-math-legacy/src/test/maxima/special/RealFunctionValidation/RealFunctionValidation.java b/commons-math-legacy/src/test/maxima/special/RealFunctionValidation/RealFunctionValidation.java
index 63cf2029d..a8e9b8269 100755
--- a/commons-math-legacy/src/test/maxima/special/RealFunctionValidation/RealFunctionValidation.java
+++ b/commons-math-legacy/src/test/maxima/special/RealFunctionValidation/RealFunctionValidation.java
@@ -29,7 +29,7 @@ import java.util.List;
import java.util.Properties;
import org.apache.commons.math4.legacy.stat.descriptive.SummaryStatistics;
-import org.apache.commons.math4.legacy.util.FastMath;
+import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
/*
* plot 'logGamma.dat' binary format="%double%double" endian=big u 1:2 w l
@@ -298,11 +298,11 @@ public class RealFunctionValidation {
types[i]);
}
final double expected = in.readDouble();
- if (FastMath.abs(expected) > 1E-16) {
+ if (AccurateMath.abs(expected) > 1E-16) {
final Object value = method.invoke(null, parameters);
final double actual = ((Double) value).doubleValue();
- final double err = FastMath.abs(actual - expected);
- final double ulps = err / FastMath.ulp(expected);
+ final double err = AccurateMath.abs(actual - expected);
+ final double ulps = err / AccurateMath.ulp(expected);
out.writeDouble(expected);
out.writeDouble(actual);
out.writeDouble(ulps);
diff --git a/pom.xml b/pom.xml
index c162d94bb..42d58b6b5 100644
--- a/pom.xml
+++ b/pom.xml
@@ -111,6 +111,7 @@
commons-math-legacy-exception
+ commons-math-legacy-core
commons-math-legacy
@@ -147,6 +148,12 @@
${project.version}