commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From celes...@apache.org
Subject svn commit: r1164615 - /commons/proper/math/trunk/src/main/java/org/apache/commons/math/optimization/general/GaussNewtonOptimizer.java
Date Fri, 02 Sep 2011 16:34:41 GMT
Author: celestin
Date: Fri Sep  2 16:34:41 2011
New Revision: 1164615

URL: http://svn.apache.org/viewvc?rev=1164615&view=rev
Log:
Replaced reference to DecompositionSolver.solve(double[]) by DecompositionSolver.solve(RealVector)
(see MATH-653)

Modified:
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/optimization/general/GaussNewtonOptimizer.java

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/optimization/general/GaussNewtonOptimizer.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/optimization/general/GaussNewtonOptimizer.java?rev=1164615&r1=1164614&r2=1164615&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/optimization/general/GaussNewtonOptimizer.java
(original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/optimization/general/GaussNewtonOptimizer.java
Fri Sep  2 16:34:41 2011
@@ -17,18 +17,20 @@
 
 package org.apache.commons.math.optimization.general;
 
-import org.apache.commons.math.exception.MathUserException;
 import org.apache.commons.math.exception.ConvergenceException;
+import org.apache.commons.math.exception.MathUserException;
 import org.apache.commons.math.exception.util.LocalizedFormats;
+import org.apache.commons.math.linear.ArrayRealVector;
 import org.apache.commons.math.linear.BlockRealMatrix;
 import org.apache.commons.math.linear.DecompositionSolver;
 import org.apache.commons.math.linear.LUDecompositionImpl;
 import org.apache.commons.math.linear.QRDecompositionImpl;
 import org.apache.commons.math.linear.RealMatrix;
+import org.apache.commons.math.linear.RealVector;
 import org.apache.commons.math.linear.SingularMatrixException;
-import org.apache.commons.math.optimization.VectorialPointValuePair;
 import org.apache.commons.math.optimization.ConvergenceChecker;
 import org.apache.commons.math.optimization.SimpleVectorialValueChecker;
+import org.apache.commons.math.optimization.VectorialPointValuePair;
 
 /**
  * Gauss-Newton least-squares solver.
@@ -146,8 +148,13 @@ public class GaussNewtonOptimizer extend
                 DecompositionSolver solver = useLU ?
                         new LUDecompositionImpl(mA).getSolver() :
                         new QRDecompositionImpl(mA).getSolver();
-                final double[] dX = solver.solve(b);
-
+                final RealVector dummy = solver.solve(new ArrayRealVector(b, false));
+                final double[] dX;
+                if (dummy instanceof ArrayRealVector){
+                    dX = ((ArrayRealVector) dummy).getDataRef();
+                }else{
+                    dX = dummy.getData();
+                }
                 // update the estimated parameters
                 for (int i = 0; i < cols; ++i) {
                     point[i] += dX[i];



Mime
View raw message