commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From er...@apache.org
Subject svn commit: r1157345 - in /commons/proper/math/trunk/src: main/java/org/apache/commons/math/linear/SingularValueDecompositionImpl.java test/java/org/apache/commons/math/linear/SingularValueDecompositionImplTest.java
Date Sat, 13 Aug 2011 07:45:43 GMT
Author: erans
Date: Sat Aug 13 07:45:42 2011
New Revision: 1157345

URL: http://svn.apache.org/viewvc?rev=1157345&view=rev
Log:
MATH-602
Inverse condition number.

Modified:
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/SingularValueDecompositionImpl.java
    commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/SingularValueDecompositionImplTest.java

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/SingularValueDecompositionImpl.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/SingularValueDecompositionImpl.java?rev=1157345&r1=1157344&r2=1157345&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/SingularValueDecompositionImpl.java
(original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/SingularValueDecompositionImpl.java
Sat Aug 13 07:45:42 2011
@@ -545,6 +545,17 @@ public class SingularValueDecompositionI
         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;

Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/SingularValueDecompositionImplTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/SingularValueDecompositionImplTest.java?rev=1157345&r1=1157344&r2=1157345&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/SingularValueDecompositionImplTest.java
(original)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/SingularValueDecompositionImplTest.java
Sat Aug 13 07:45:42 2011
@@ -298,6 +298,13 @@ public class SingularValueDecompositionI
         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 =



Mime
View raw message