Using "copyOf" from "MathUtils".

git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@1145101 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Gilles Sadowski 2011-07-11 10:01:39 +00:00
parent ce13d98d2e
commit 3df5cf363e
1 changed files with 4 additions and 7 deletions

View File

@ -19,6 +19,7 @@ package org.apache.commons.math.stat.regression;
import java.io.Serializable;
import java.util.Arrays;
import org.apache.commons.math.util.FastMath;
import org.apache.commons.math.util.MathUtils;
/**
* Results of a Multiple Linear Regression model fit.
@ -65,12 +66,10 @@ public class RegressionResults implements Serializable {
final boolean containsConstant,
final boolean copyData) {
if (copyData) {
this.parameters = new double[parameters.length];
System.arraycopy(parameters, 0, this.parameters, 0, parameters.length);
this.parameters = MathUtils.copyOf(parameters);
this.varCovData = new double[varcov.length][];
for (int i = 0; i < varcov.length; i++) {
this.varCovData[i] = new double[varcov[i].length];
System.arraycopy(varcov[i], 0, this.varCovData[i], 0, varcov[i].length);
this.varCovData[i] = MathUtils.copyOf(varcov[i]);
}
} else {
this.parameters = parameters;
@ -137,9 +136,7 @@ public class RegressionResults implements Serializable {
if (this.parameters == null) {
return null;
}
double[] out = new double[parameters.length];
System.arraycopy(parameters, 0, out, 0, parameters.length);
return out;
return MathUtils.copyOf(parameters);
}
/**