Use functionality defined in "Commons Numbers".
This commit is contained in:
parent
b509678e95
commit
a1f2a98c28
|
@ -89,6 +89,11 @@
|
|||
<artifactId>commons-numbers-quaternion</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-numbers-arrays</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-rng-client-api</artifactId>
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
package org.apache.commons.math4.legacy.analysis.interpolation;
|
||||
|
||||
import org.apache.commons.numbers.angle.Reduce;
|
||||
|
||||
import org.apache.commons.numbers.arrays.SortInPlace;
|
||||
import org.apache.commons.math4.legacy.analysis.UnivariateFunction;
|
||||
import org.apache.commons.math4.legacy.exception.MathIllegalArgumentException;
|
||||
import org.apache.commons.math4.legacy.exception.NonMonotonicSequenceException;
|
||||
|
@ -114,7 +114,7 @@ public class UnivariatePeriodicInterpolator
|
|||
y[index] = yval[i];
|
||||
}
|
||||
|
||||
MathArrays.sortInPlace(x, y);
|
||||
SortInPlace.ASCENDING.accept(x, y);
|
||||
|
||||
final UnivariateFunction f = interpolator.interpolate(x, y);
|
||||
return new UnivariateFunction() {
|
||||
|
|
|
@ -16,6 +16,8 @@
|
|||
*/
|
||||
package org.apache.commons.math4.legacy.analysis.polynomials;
|
||||
|
||||
import org.apache.commons.numbers.core.Precision;
|
||||
import org.apache.commons.numbers.arrays.SortInPlace;
|
||||
import org.apache.commons.math4.legacy.analysis.UnivariateFunction;
|
||||
import org.apache.commons.math4.legacy.exception.DimensionMismatchException;
|
||||
import org.apache.commons.math4.legacy.exception.NonMonotonicSequenceException;
|
||||
|
@ -77,7 +79,7 @@ public class PolynomialFunctionLagrangeForm implements UnivariateFunction {
|
|||
coefficientsComputed = false;
|
||||
|
||||
if (!verifyInterpolationArray(x, y, false)) {
|
||||
MathArrays.sortInPlace(this.x, this.y);
|
||||
SortInPlace.ASCENDING.accept(this.x, this.y);
|
||||
// Second check in case some abscissa is duplicated.
|
||||
verifyInterpolationArray(this.x, this.y, true);
|
||||
}
|
||||
|
@ -182,7 +184,7 @@ public class PolynomialFunctionLagrangeForm implements UnivariateFunction {
|
|||
System.arraycopy(x, 0, xNew, 0, x.length);
|
||||
System.arraycopy(y, 0, yNew, 0, y.length);
|
||||
|
||||
MathArrays.sortInPlace(xNew, yNew);
|
||||
SortInPlace.ASCENDING.accept(xNew, yNew);
|
||||
// Second check in case some abscissa is duplicated.
|
||||
verifyInterpolationArray(xNew, yNew, true);
|
||||
return evaluateInternal(xNew, yNew, z);
|
||||
|
|
|
@ -26,6 +26,8 @@ import java.util.Collection;
|
|||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.numbers.core.Precision;
|
||||
import org.apache.commons.numbers.arrays.SortInPlace;
|
||||
import org.apache.commons.math4.legacy.analysis.UnivariateFunction;
|
||||
import org.apache.commons.math4.legacy.analysis.interpolation.LinearInterpolator;
|
||||
import org.apache.commons.math4.legacy.analysis.interpolation.NevilleInterpolator;
|
||||
|
@ -37,7 +39,6 @@ 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.core.MathArrays;
|
||||
import org.apache.commons.numbers.core.Precision;
|
||||
|
||||
/**
|
||||
* A {@link StorelessUnivariateStatistic} estimating percentiles using the
|
||||
|
@ -767,7 +768,7 @@ public class PSquarePercentile extends AbstractStorelessUnivariateStatistic
|
|||
new double[] { xval[1], xval[1 + delta] };
|
||||
final double[] yBad =
|
||||
new double[] { yval[1], yval[1 + delta] };
|
||||
MathArrays.sortInPlace(xBad, yBad);// since d can be +/- 1
|
||||
SortInPlace.ASCENDING.accept(xBad, yBad);// since d can be +/- 1
|
||||
univariateFunction = linear.interpolate(xBad, yBad);
|
||||
markerHeight = univariateFunction.value(xD);
|
||||
}
|
||||
|
|
|
@ -20,6 +20,8 @@ import java.io.Serializable;
|
|||
import java.util.Arrays;
|
||||
import java.util.BitSet;
|
||||
|
||||
import org.apache.commons.numbers.core.Precision;
|
||||
import org.apache.commons.numbers.arrays.SortInPlace;
|
||||
import org.apache.commons.math4.legacy.exception.NullArgumentException;
|
||||
import org.apache.commons.math4.legacy.exception.MathIllegalArgumentException;
|
||||
import org.apache.commons.math4.legacy.exception.NotPositiveException;
|
||||
|
@ -30,7 +32,6 @@ import org.apache.commons.math4.legacy.stat.descriptive.AbstractUnivariateStatis
|
|||
import org.apache.commons.math4.legacy.stat.ranking.NaNStrategy;
|
||||
import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath;
|
||||
import org.apache.commons.math4.legacy.core.MathArrays;
|
||||
import org.apache.commons.numbers.core.Precision;
|
||||
|
||||
/**
|
||||
* Provides percentile computation.
|
||||
|
@ -1149,7 +1150,7 @@ public class Percentile extends AbstractUnivariateStatistic implements Serializa
|
|||
@Override
|
||||
public double evaluate(final double[] work, final double[] sampleWeights,
|
||||
final double p) {
|
||||
MathArrays.sortInPlace(work, sampleWeights);
|
||||
SortInPlace.ASCENDING.accept(work, sampleWeights);
|
||||
double[] sk = new double[work.length];
|
||||
for(int k = 0; k < work.length; k++) {
|
||||
sk[k] = 0;
|
||||
|
|
6
pom.xml
6
pom.xml
|
@ -214,6 +214,12 @@
|
|||
<version>${math.commons.numbers.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-numbers-arrays</artifactId>
|
||||
<version>${math.commons.numbers.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-rng-client-api</artifactId>
|
||||
|
|
Loading…
Reference in New Issue