From 4a73dfc4fee6045f4e450f894429c0dade162231 Mon Sep 17 00:00:00 2001 From: Sebastien Brisard Date: Fri, 9 Sep 2011 02:12:22 +0000 Subject: [PATCH] Removed double[][] solve(double[][]) from EigenDecompositionImpl.Solver git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@1166962 13f79535-47bb-0310-9956-ffa450edef68 --- .../math/linear/EigenDecompositionImpl.java | 42 ++++--------------- 1 file changed, 8 insertions(+), 34 deletions(-) diff --git a/src/main/java/org/apache/commons/math/linear/EigenDecompositionImpl.java b/src/main/java/org/apache/commons/math/linear/EigenDecompositionImpl.java index 7941ee956..f6345f294 100644 --- a/src/main/java/org/apache/commons/math/linear/EigenDecompositionImpl.java +++ b/src/main/java/org/apache/commons/math/linear/EigenDecompositionImpl.java @@ -302,40 +302,24 @@ public class EigenDecompositionImpl implements EigenDecomposition { return new ArrayRealVector(bp, false); } - /** Solve the linear equation A × X = B for matrices A. - *

The A matrix is implicit, it is provided by the underlying - * decomposition algorithm.

- * @param b right-hand side of the equation A × 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 × 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,20 +336,10 @@ public class EigenDecompositionImpl implements EigenDecomposition { } } - 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); - } - /** * Check if the decomposed matrix is non-singular. * @return true if the decomposed matrix is non-singular