Fixed a wrong dimension check in SVD solver

thanks to Dimitri for identifying and solving this

git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@891436 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Luc Maisonobe 2009-12-16 21:44:13 +00:00
parent 01e5f22cc5
commit 204990415d
3 changed files with 11 additions and 8 deletions

View File

@ -24,8 +24,8 @@ package org.apache.commons.math.linear;
* Singular Value Decomposition of a real matrix. * Singular Value Decomposition of a real matrix.
* <p>The Singular Value Decomposition of matrix A is a set of three matrices: * <p>The Singular Value Decomposition of matrix A is a set of three matrices:
* U, &Sigma; and V such that A = U &times; &Sigma; &times; V<sup>T</sup>. * U, &Sigma; and V such that A = U &times; &Sigma; &times; V<sup>T</sup>.
* Let A be an m &times; n matrix, then U is an m &times; m orthogonal matrix, * Let A be an m &times; n matrix, then U is an m &times; n orthogonal matrix,
* &Sigma; is a m &times; n diagonal matrix with positive diagonal elements, * &Sigma; is a n &times; n diagonal matrix with positive diagonal elements,
* and V is an n &times; n orthogonal matrix.</p> * and V is an n &times; n orthogonal matrix.</p>
* <p>This interface is similar to the class with similar name from the * <p>This interface is similar to the class with similar name from the
* <a href="http://math.nist.gov/javanumerics/jama/">JAMA</a> library, with the * <a href="http://math.nist.gov/javanumerics/jama/">JAMA</a> library, with the

View File

@ -24,8 +24,8 @@ import org.apache.commons.math.util.MathUtils;
* Calculates the Singular Value Decomposition of a matrix. * Calculates the Singular Value Decomposition of a matrix.
* <p>The Singular Value Decomposition of matrix A is a set of three matrices: * <p>The Singular Value Decomposition of matrix A is a set of three matrices:
* U, &Sigma; and V such that A = U &times; &Sigma; &times; V<sup>T</sup>. * U, &Sigma; and V such that A = U &times; &Sigma; &times; V<sup>T</sup>.
* Let A be an m &times; n matrix, then U is an m &times; m orthogonal matrix, * Let A be an m &times; n matrix, then U is an m &times; n orthogonal matrix,
* &Sigma; is a m &times; n diagonal matrix with positive diagonal elements, * &Sigma; is a n &times; n diagonal matrix with positive diagonal elements,
* and V is an n &times; n orthogonal matrix.</p> * and V is an n &times; n orthogonal matrix.</p>
* *
* @version $Revision$ $Date$ * @version $Revision$ $Date$
@ -361,10 +361,10 @@ public class SingularValueDecompositionImpl implements SingularValueDecompositio
public double[] solve(final double[] b) public double[] solve(final double[] b)
throws IllegalArgumentException, InvalidMatrixException { throws IllegalArgumentException, InvalidMatrixException {
if (b.length != singularValues.length) { if (b.length != uT.getColumnDimension()) {
throw MathRuntimeException.createIllegalArgumentException( throw MathRuntimeException.createIllegalArgumentException(
"vector length mismatch: got {0} but expected {1}", "vector length mismatch: got {0} but expected {1}",
b.length, singularValues.length); b.length, uT.getColumnDimension());
} }
final double[] w = uT.operate(b); final double[] w = uT.operate(b);
@ -390,10 +390,10 @@ public class SingularValueDecompositionImpl implements SingularValueDecompositio
public RealVector solve(final RealVector b) public RealVector solve(final RealVector b)
throws IllegalArgumentException, InvalidMatrixException { throws IllegalArgumentException, InvalidMatrixException {
if (b.getDimension() != singularValues.length) { if (b.getDimension() != uT.getColumnDimension()) {
throw MathRuntimeException.createIllegalArgumentException( throw MathRuntimeException.createIllegalArgumentException(
"vector length mismatch: got {0} but expected {1}", "vector length mismatch: got {0} but expected {1}",
b.getDimension(), singularValues.length); b.getDimension(), uT.getColumnDimension());
} }
final RealVector w = uT.operate(b); final RealVector w = uT.operate(b);

View File

@ -39,6 +39,9 @@ The <action> type attribute can be add,update,fix,remove.
</properties> </properties>
<body> <body>
<release version="2.1" date="TBD" description="TBD"> <release version="2.1" date="TBD" description="TBD">
<action dev="luc" type="fix" due-to="Dimitri Pourbaix">
Fixed a wrong dimension check in SVD solver.
</action>
<action dev="luc" type="fix" issue="MATH-313" due-to="Jake Mannix"> <action dev="luc" type="fix" issue="MATH-313" due-to="Jake Mannix">
Added composition features for real functions. Added composition features for real functions.
</action> </action>