commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From celes...@apache.org
Subject svn commit: r1166962 - /commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/EigenDecompositionImpl.java
Date Fri, 09 Sep 2011 02:12:22 GMT
Author: celestin
Date: Fri Sep  9 02:12:22 2011
New Revision: 1166962

URL: http://svn.apache.org/viewvc?rev=1166962&view=rev
Log:
Removed double[][] solve(double[][]) from EigenDecompositionImpl.Solver

Modified:
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/EigenDecompositionImpl.java

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/EigenDecompositionImpl.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/EigenDecompositionImpl.java?rev=1166962&r1=1166961&r2=1166962&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/EigenDecompositionImpl.java
(original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/EigenDecompositionImpl.java
Fri Sep  9 02:12:22 2011
@@ -302,40 +302,24 @@ public class EigenDecompositionImpl impl
             return new ArrayRealVector(bp, false);
         }
 
-        /** Solve the linear equation A × X = B for matrices A.
-         * <p>The A matrix is implicit, it is provided by the underlying
-         * decomposition algorithm.</p>
-         * @param b right-hand side of the equation A &times; X = B
-         * @param reuseB if true, the b array will be reused and returned,
-         * instead of being copied
-         * @return a matrix X that minimizes the two norm of A &times; X - B
-         * @throws org.apache.commons.math.exception.DimensionMismatchException
-         * if the matrices dimensions do not match.
-         * @throws SingularMatrixException
-         * if the decomposed matrix is singular.
-         */
-        private double[][] solve(double[][] b, boolean reuseB) {
+        /** {@inheritDoc} */
+        public RealMatrix solve(RealMatrix b) {
 
             if (!isNonSingular()) {
                 throw new SingularMatrixException();
             }
 
             final int m = realEigenvalues.length;
-            if (b.length != m) {
-                throw new DimensionMismatchException(b.length, m);
+            if (b.getRowDimension() != m) {
+                throw new DimensionMismatchException(b.getRowDimension(), m);
             }
 
-            final int nColB = b[0].length;
-            final double[][] bp;
-            if (reuseB) {
-                bp = b;
-            } else {
-                bp = new double[m][nColB];
-            }
+            final int nColB = b.getColumnDimension();
+            final double[][] bp = new double[m][nColB];
             final double[] tmpCol = new double[m];
             for (int k = 0; k < nColB; ++k) {
                 for (int i = 0; i < m; ++i) {
-                    tmpCol[i] = b[i][k];
+                    tmpCol[i] = b.getEntry(i, k);
                     bp[i][k]  = 0;
                 }
                 for (int i = 0; i < m; ++i) {
@@ -352,18 +336,8 @@ public class EigenDecompositionImpl impl
                 }
             }
 
-            return bp;
-
-        }
+            return new Array2DRowRealMatrix(bp, false);
 
-        /** {@inheritDoc} */
-        public double[][] solve(double[][] b) {
-            return solve(b, false);
-        }
-
-        /** {@inheritDoc} */
-        public RealMatrix solve(RealMatrix b) {
-            return new Array2DRowRealMatrix(solve(b.getData(), true), false);
         }
 
         /**



Mime
View raw message