Use "Arrays.copyOf" from JDK.
This commit is contained in:
parent
ed6b06d02f
commit
f4dd17aa7d
|
@ -19,10 +19,10 @@ package org.apache.commons.math4.fitting.leastsquares;
|
|||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
|
||||
import org.apache.commons.math4.analysis.MultivariateMatrixFunction;
|
||||
import org.apache.commons.math4.analysis.MultivariateVectorFunction;
|
||||
import org.apache.commons.math4.util.MathArrays;
|
||||
|
||||
/**
|
||||
* This class gives access to the statistical reference datasets provided by the
|
||||
|
@ -199,7 +199,7 @@ public abstract class StatisticalReferenceDataset {
|
|||
*/
|
||||
public double[][] getData() {
|
||||
return new double[][] {
|
||||
MathArrays.copyOf(x), MathArrays.copyOf(y)
|
||||
Arrays.copyOf(x, x.length), Arrays.copyOf(y, y.length)
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -238,7 +238,7 @@ public abstract class StatisticalReferenceDataset {
|
|||
* @return the values of the parameters
|
||||
*/
|
||||
public double[] getParameters() {
|
||||
return MathArrays.copyOf(a);
|
||||
return Arrays.copyOf(a, a.length);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -257,7 +257,7 @@ public abstract class StatisticalReferenceDataset {
|
|||
* @return the standard deviations of the parameters
|
||||
*/
|
||||
public double[] getParametersStandardDeviations() {
|
||||
return MathArrays.copyOf(sigA);
|
||||
return Arrays.copyOf(sigA, sigA.length);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -297,7 +297,7 @@ public abstract class StatisticalReferenceDataset {
|
|||
* @return the starting point
|
||||
*/
|
||||
public double[] getStartingPoint(final int i) {
|
||||
return MathArrays.copyOf(startingValues[i]);
|
||||
return Arrays.copyOf(startingValues[i], startingValues[i].length);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -223,7 +223,7 @@ public abstract class RealVectorAbstractTest {
|
|||
public void testSetEntry() {
|
||||
final double x = getPreferredEntryValue();
|
||||
final double[] data = {x, 1d, 2d, x, x};
|
||||
final double[] expected = MathArrays.copyOf(data);
|
||||
final double[] expected = Arrays.copyOf(data, data.length);
|
||||
final RealVector actual = create(data);
|
||||
|
||||
/*
|
||||
|
@ -270,7 +270,7 @@ public abstract class RealVectorAbstractTest {
|
|||
final double x = getPreferredEntryValue();
|
||||
final double[] data1 = {x, 1d, 2d, x, x};
|
||||
|
||||
final double[] expected = MathArrays.copyOf(data1);
|
||||
final double[] expected = Arrays.copyOf(data1, data1.length);
|
||||
final RealVector actual = create(data1);
|
||||
|
||||
/*
|
||||
|
|
|
@ -32,7 +32,6 @@ import org.apache.commons.math4.stat.descriptive.rank.Percentile.EstimationType;
|
|||
import org.apache.commons.math4.stat.ranking.NaNStrategy;
|
||||
import org.apache.commons.math4.util.CentralPivotingStrategy;
|
||||
import org.apache.commons.math4.util.KthSelector;
|
||||
import org.apache.commons.math4.util.MathArrays;
|
||||
import org.apache.commons.math4.util.MedianOf3PivotingStrategy;
|
||||
import org.apache.commons.math4.util.PivotingStrategyInterface;
|
||||
import org.apache.commons.math4.util.RandomPivotingStrategy;
|
||||
|
@ -630,7 +629,7 @@ public class PercentileTest extends UnivariateStatisticAbstractTest{
|
|||
public void testAllEstimationTechniquesOnlyLimits() {
|
||||
final int N=testArray.length;
|
||||
|
||||
final double[] input=MathArrays.copyOf(testArray);
|
||||
final double[] input = Arrays.copyOf(testArray, testArray.length);
|
||||
Arrays.sort(input);
|
||||
final double min = input[0];
|
||||
final double max=input[input.length-1];
|
||||
|
|
|
@ -709,8 +709,8 @@ public class KolmogorovSmirnovTestTest {
|
|||
public void testFixTiesNoOp() throws Exception {
|
||||
final double[] x = {0, 1, 2, 3, 4};
|
||||
final double[] y = {5, 6, 7, 8};
|
||||
final double[] origX = MathArrays.copyOf(x);
|
||||
final double[] origY = MathArrays.copyOf(y);
|
||||
final double[] origX = Arrays.copyOf(x, x.length);
|
||||
final double[] origY = Arrays.copyOf(y, y.length);
|
||||
fixTies(x,y);
|
||||
Assert.assertArrayEquals(origX, x, 0);
|
||||
Assert.assertArrayEquals(origY, y, 0);
|
||||
|
@ -724,11 +724,11 @@ public class KolmogorovSmirnovTestTest {
|
|||
public void testFixTiesConsistency() throws Exception {
|
||||
final double[] x = {0, 1, 2, 3, 4, 2};
|
||||
final double[] y = {5, 6, 7, 8, 1, 2};
|
||||
final double[] xP = MathArrays.copyOf(x);
|
||||
final double[] yP = MathArrays.copyOf(y);
|
||||
final double[] xP = Arrays.copyOf(x, x.length);
|
||||
final double[] yP = Arrays.copyOf(y, y.length);
|
||||
checkFixTies(x, y);
|
||||
final double[] fixedX = MathArrays.copyOf(x);
|
||||
final double[] fixedY = MathArrays.copyOf(y);
|
||||
final double[] fixedX = Arrays.copyOf(x, x.length);
|
||||
final double[] fixedY = Arrays.copyOf(y, y.length);
|
||||
checkFixTies(xP, yP);
|
||||
Assert.assertArrayEquals(fixedX, xP, 0);
|
||||
Assert.assertArrayEquals(fixedY, yP, 0);
|
||||
|
|
Loading…
Reference in New Issue