commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From celes...@apache.org
Subject svn commit: r1303292 - /commons/proper/math/trunk/src/test/java/org/apache/commons/math3/linear/SymmLQTest.java
Date Wed, 21 Mar 2012 05:49:14 GMT
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);
+            }
         }
     }
 



Mime
View raw message