You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by ce...@apache.org on 2012/03/21 06:49:14 UTC

svn commit: r1303292 - /commons/proper/math/trunk/src/test/java/org/apache/commons/math3/linear/SymmLQTest.java

Author: celestin
Date: Wed Mar 21 05:49:14 2012
New Revision: 1303292

URL: http://svn.apache.org/viewvc?rev=1303292&view=rev
Log:
Modified unit test of o.a.c.m3.linear.SymmLQ to show that lines 1208-1209 are essential (see MATH-761).

Modified:
    commons/proper/math/trunk/src/test/java/org/apache/commons/math3/linear/SymmLQTest.java

Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math3/linear/SymmLQTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math3/linear/SymmLQTest.java?rev=1303292&r1=1303291&r2=1303292&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math3/linear/SymmLQTest.java (original)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math3/linear/SymmLQTest.java Wed Mar 21 05:49:14 2012
@@ -486,6 +486,7 @@ public class SymmLQTest {
          * count[3] = number of calls to terminationPerformed
          */
         final int[] count = new int[] {0, 0, 0, 0};
+        final RealVector xFromListener = new ArrayRealVector(n);
         final IterationListener listener = new IterationListener() {
 
             public void initializationPerformed(final IterationEvent e) {
@@ -506,6 +507,8 @@ public class SymmLQTest {
 
             public void terminationPerformed(final IterationEvent e) {
                 ++count[3];
+                final IterativeLinearSolverEvent ilse = (IterativeLinearSolverEvent) e;
+                xFromListener.setSubVector(0, ilse.getSolution());
             }
         };
         solver = new SymmLQ(maxIterations, 1E-10, true);
@@ -515,11 +518,21 @@ public class SymmLQTest {
             Arrays.fill(count, 0);
             b.set(0.);
             b.setEntry(j, 1.);
-            solver.solve(a, b);
+            final RealVector xFromSolver = solver.solve(a, b);
             String msg = String.format("column %d (initialization)", j);
             Assert.assertEquals(msg, 1, count[0]);
             msg = String.format("column %d (finalization)", j);
             Assert.assertEquals(msg, 1, count[3]);
+            /*
+             *  Check that solution is not "over-refined". When the last iteration has
+             *  occurred, no further refinement should be performed.
+             */
+            for (int i = 0; i < n; i++){
+                msg = String.format("row %d, column %d", i, j);
+                final double expected = xFromSolver.getEntry(i);
+                final double actual = xFromListener.getEntry(i);
+                Assert.assertEquals(msg, expected, actual, 0.0);
+            }
         }
     }