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