From 3df5cf363e342cf922f63eb341ee7801b110706b Mon Sep 17 00:00:00 2001 From: Gilles Sadowski Date: Mon, 11 Jul 2011 10:01:39 +0000 Subject: [PATCH] Using "copyOf" from "MathUtils". git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@1145101 13f79535-47bb-0310-9956-ffa450edef68 --- .../math/stat/regression/RegressionResults.java | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/main/java/org/apache/commons/math/stat/regression/RegressionResults.java b/src/main/java/org/apache/commons/math/stat/regression/RegressionResults.java index b3af88cda..6e6e40f8a 100644 --- a/src/main/java/org/apache/commons/math/stat/regression/RegressionResults.java +++ b/src/main/java/org/apache/commons/math/stat/regression/RegressionResults.java @@ -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); } /**