commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From l..@apache.org
Subject svn commit: r1570994 - in /commons/proper/math/trunk/src: changes/ main/java/org/apache/commons/math3/linear/ site/xdoc/userguide/ test/java/org/apache/commons/math3/linear/
Date Sun, 23 Feb 2014 11:10:41 GMT
Author: luc
Date: Sun Feb 23 11:10:41 2014
New Revision: 1570994

URL: http://svn.apache.org/r1570994
Log:
Improved documentation of QR decomposition handling of singular matrix.

JIRA: MATH-1101

Modified:
    commons/proper/math/trunk/src/changes/changes.xml
    commons/proper/math/trunk/src/main/java/org/apache/commons/math3/linear/QRDecomposition.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math3/linear/RRQRDecomposition.java
    commons/proper/math/trunk/src/site/xdoc/userguide/linear.xml
    commons/proper/math/trunk/src/test/java/org/apache/commons/math3/linear/QRDecompositionTest.java

Modified: commons/proper/math/trunk/src/changes/changes.xml
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/changes/changes.xml?rev=1570994&r1=1570993&r2=1570994&view=diff
==============================================================================
--- commons/proper/math/trunk/src/changes/changes.xml (original)
+++ commons/proper/math/trunk/src/changes/changes.xml Sun Feb 23 11:10:41 2014
@@ -51,6 +51,9 @@ If the output is not quite correct, chec
   </properties>
   <body>
     <release version="3.3" date="TBD" description="TBD">
+      <action dev="luc" type="add" issue="MATH-1101">
+        Improved documentation of QR decomposition handling of singular matrices.
+      </action>
       <action dev="luc" type="add" issue="MATH-1053" due-to="Sean Owen">
         QR decomposition can compute pseudo-inverses for tall matrices.
       </action>

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math3/linear/QRDecomposition.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/linear/QRDecomposition.java?rev=1570994&r1=1570993&r2=1570994&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math3/linear/QRDecomposition.java
(original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math3/linear/QRDecomposition.java
Sun Feb 23 11:10:41 2014
@@ -291,6 +291,14 @@ public class QRDecomposition {
 
     /**
      * Get a solver for finding the A &times; X = B solution in least square sense.
+     * <p>
+     * Least Square sense means a solver can be computed for an overdetermined system,
+     * (i.e. a system with more equations than unknowns, which corresponds to a tall A
+     * matrix with more rows than columns). In any case, if the matrix is singular
+     * within the tolerance set at {@link QRDecomposition#QRDecomposition(RealMatrix,
+     * double) construction}, an error will be triggered when
+     * the {@link DecompositionSolver#solve(RealVector) solve} method will be called.
+     * </p>
      * @return a solver
      */
     public DecompositionSolver getSolver() {

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math3/linear/RRQRDecomposition.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/linear/RRQRDecomposition.java?rev=1570994&r1=1570993&r2=1570994&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math3/linear/RRQRDecomposition.java
(original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math3/linear/RRQRDecomposition.java
Sun Feb 23 11:10:41 2014
@@ -184,6 +184,14 @@ public class RRQRDecomposition extends Q
 
     /**
      * Get a solver for finding the A &times; X = B solution in least square sense.
+     * <p>
+     * Least Square sense means a solver can be computed for an overdetermined system,
+     * (i.e. a system with more equations than unknowns, which corresponds to a tall A
+     * matrix with more rows than columns). In any case, if the matrix is singular
+     * within the tolerance set at {@link RRQRDecomposition#RRQRDecomposition(RealMatrix,
+     * double) construction}, an error will be triggered when
+     * the {@link DecompositionSolver#solve(RealVector) solve} method will be called.
+     * </p>
      * @return a solver
      */
     @Override

Modified: commons/proper/math/trunk/src/site/xdoc/userguide/linear.xml
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/site/xdoc/userguide/linear.xml?rev=1570994&r1=1570993&r2=1570994&view=diff
==============================================================================
--- commons/proper/math/trunk/src/site/xdoc/userguide/linear.xml (original)
+++ commons/proper/math/trunk/src/site/xdoc/userguide/linear.xml Sun Feb 23 11:10:41 2014
@@ -144,10 +144,16 @@ RealVector solution = solver.solve(const
           Each type of decomposition has its specific semantics and constraints on
           the coefficient matrix as shown in the following table. For algorithms that
           solve AX=B in least squares sense the value returned for X is such that the
-          residual AX-B has minimal norm. If an exact solution exist (i.e. if for some
-          X the residual AX-B is exactly 0), then this exact solution is also the solution
-          in least square sense. This implies that algorithms suited for least squares
-          problems can also be used to solve exact problems, but the reverse is not true.

+          residual AX-B has minimal norm. Least Square sense means a solver can be computed
+          for an overdetermined system, (i.e. a system with more equations than unknowns,
+          which corresponds to a tall A matrix with more rows than columns). If an exact
+          solution exist (i.e. if for some X the residual AX-B is exactly 0), then this
+          exact solution is also the solution in least square sense. This implies that
+          algorithms suited for least squares problems can also be used to solve exact
+          problems, but the reverse is not true. In any case, if the matrix is singular
+          within the tolerance set at construction, an error will be triggered when
+          the solve method will be called, both for algorithms that compute exact solutions
+          and for algorithms that compute least square solutions.
         </p>
         <p>
           <table border="1" align="center">

Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math3/linear/QRDecompositionTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math3/linear/QRDecompositionTest.java?rev=1570994&r1=1570993&r2=1570994&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math3/linear/QRDecompositionTest.java
(original)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math3/linear/QRDecompositionTest.java
Sun Feb 23 11:10:41 2014
@@ -273,5 +273,14 @@ public class QRDecompositionTest {
         });
         return m;
     }
+    
+    @Test(expected=SingularMatrixException.class)
+    public void testQRSingular() {
+        final RealMatrix a = MatrixUtils.createRealMatrix(new double[][] {
+            { 1, 6, 4 }, { 2, 4, -1 }, { -1, 2, 5 }
+        });
+        final RealVector b = new ArrayRealVector(new double[]{ 5, 6, 1 });
+        new QRDecomposition(a, 1.0e-15).getSolver().solve(b);
+    }
 
 }



Mime
View raw message