MATH-602
Inverse condition number. git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@1157345 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
9edd2f24d7
commit
cec75d74f8
|
@ -545,6 +545,17 @@ public class SingularValueDecompositionImpl implements SingularValueDecompositio
|
|||
return singularValues[0] / singularValues[n - 1];
|
||||
}
|
||||
|
||||
/**
|
||||
* Computes the inverse of the condition number.
|
||||
* In cases of rank deficiency, the {@link #getConditionNumber() condition
|
||||
* number} will become undefined.
|
||||
*
|
||||
* @return the inverse of the condition number.
|
||||
*/
|
||||
public double getInverseConditionNumber() {
|
||||
return singularValues[n - 1] / singularValues[0];
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public int getRank() {
|
||||
int r = 0;
|
||||
|
|
|
@ -298,6 +298,13 @@ public class SingularValueDecompositionImplTest {
|
|||
Assert.assertEquals(3.0, svd.getConditionNumber(), 1.5e-15);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInverseConditionNumber() {
|
||||
SingularValueDecompositionImpl svd =
|
||||
new SingularValueDecompositionImpl(MatrixUtils.createRealMatrix(testSquare));
|
||||
Assert.assertEquals(1.0/3.0, svd.getInverseConditionNumber(), 1.5e-15);
|
||||
}
|
||||
|
||||
private RealMatrix createTestMatrix(final Random r, final int rows, final int columns,
|
||||
final double[] singularValues) {
|
||||
final RealMatrix u =
|
||||
|
|
Loading…
Reference in New Issue