# commons-commits mailing list archives

##### Site index · List index
Message view
Top
From celes...@apache.org
Subject svn commit: r1166961 - /commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/CholeskyDecompositionImpl.java
Date Fri, 09 Sep 2011 02:11:28 GMT
```Author: celestin
Date: Fri Sep  9 02:11:27 2011
New Revision: 1166961

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

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

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/CholeskyDecompositionImpl.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/CholeskyDecompositionImpl.java?rev=1166961&r1=1166960&r2=1166961&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/CholeskyDecompositionImpl.java
(original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/CholeskyDecompositionImpl.java
Fri Sep  9 02:11:27 2011
@@ -226,34 +226,15 @@ public class CholeskyDecompositionImpl i
return new ArrayRealVector(x, false);
}

-        /** Solve the linear equation A &times; 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) {
final int m = lTData.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[][] x;
-            if (reuseB) {
-                x = b;
-            } else {
-                x = new double[b.length][nColB];
-                for (int i = 0; i < b.length; ++i) {
-                    System.arraycopy(b[i], 0, x[i], 0, nColB);
-                }
-            }
+            final int nColB = b.getColumnDimension();
+            final double[][] x = b.getData();

// Solve LY = b
for (int j = 0; j < m; j++) {
@@ -288,18 +269,7 @@ public class CholeskyDecompositionImpl i
}
}

-            return x;
-
-        }
-
-        /** {@inheritDoc} */
-        public double[][] solve(double[][] b) {
-            return solve(b, false);
-        }
-
-        /** {@inheritDoc} */
-        public RealMatrix solve(RealMatrix b) {
-            return new Array2DRowRealMatrix(solve(b.getData(), true), false);
+            return new Array2DRowRealMatrix(x);
}

/** {@inheritDoc} */

```
Mime
View raw message