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
This commit is contained in:
parent
fc1bf19d9a
commit
4a73dfc4fe
|
@ -302,40 +302,24 @@ public class EigenDecompositionImpl implements EigenDecomposition {
|
||||||
return new ArrayRealVector(bp, false);
|
return new ArrayRealVector(bp, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Solve the linear equation A × X = B for matrices A.
|
/** {@inheritDoc} */
|
||||||
* <p>The A matrix is implicit, it is provided by the underlying
|
public RealMatrix solve(RealMatrix b) {
|
||||||
* decomposition algorithm.</p>
|
|
||||||
* @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) {
|
|
||||||
|
|
||||||
if (!isNonSingular()) {
|
if (!isNonSingular()) {
|
||||||
throw new SingularMatrixException();
|
throw new SingularMatrixException();
|
||||||
}
|
}
|
||||||
|
|
||||||
final int m = realEigenvalues.length;
|
final int m = realEigenvalues.length;
|
||||||
if (b.length != m) {
|
if (b.getRowDimension() != m) {
|
||||||
throw new DimensionMismatchException(b.length, m);
|
throw new DimensionMismatchException(b.getRowDimension(), m);
|
||||||
}
|
}
|
||||||
|
|
||||||
final int nColB = b[0].length;
|
final int nColB = b.getColumnDimension();
|
||||||
final double[][] bp;
|
final double[][] bp = new double[m][nColB];
|
||||||
if (reuseB) {
|
|
||||||
bp = b;
|
|
||||||
} else {
|
|
||||||
bp = new double[m][nColB];
|
|
||||||
}
|
|
||||||
final double[] tmpCol = new double[m];
|
final double[] tmpCol = new double[m];
|
||||||
for (int k = 0; k < nColB; ++k) {
|
for (int k = 0; k < nColB; ++k) {
|
||||||
for (int i = 0; i < m; ++i) {
|
for (int i = 0; i < m; ++i) {
|
||||||
tmpCol[i] = b[i][k];
|
tmpCol[i] = b.getEntry(i, k);
|
||||||
bp[i][k] = 0;
|
bp[i][k] = 0;
|
||||||
}
|
}
|
||||||
for (int i = 0; i < m; ++i) {
|
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.
|
* Check if the decomposed matrix is non-singular.
|
||||||
* @return true if the decomposed matrix is non-singular
|
* @return true if the decomposed matrix is non-singular
|
||||||
|
|
Loading…
Reference in New Issue