commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From l..@apache.org
Subject svn commit: r701810 - /commons/proper/math/branches/MATH_2_0/src/test/org/apache/commons/math/linear/TriDiagonalTransformerTest.java
Date Sun, 05 Oct 2008 15:37:02 GMT
Author: luc
Date: Sun Oct  5 08:37:02 2008
New Revision: 701810

URL: http://svn.apache.org/viewvc?rev=701810&view=rev
Log:
added a test ensuring the part of the symmetric matrix below the diagonal is never used

Modified:
    commons/proper/math/branches/MATH_2_0/src/test/org/apache/commons/math/linear/TriDiagonalTransformerTest.java

Modified: commons/proper/math/branches/MATH_2_0/src/test/org/apache/commons/math/linear/TriDiagonalTransformerTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_0/src/test/org/apache/commons/math/linear/TriDiagonalTransformerTest.java?rev=701810&r1=701809&r2=701810&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_0/src/test/org/apache/commons/math/linear/TriDiagonalTransformerTest.java
(original)
+++ commons/proper/math/branches/MATH_2_0/src/test/org/apache/commons/math/linear/TriDiagonalTransformerTest.java
Sun Oct  5 08:37:02 2008
@@ -17,6 +17,8 @@
 
 package org.apache.commons.math.linear;
 
+import java.util.Arrays;
+
 import junit.framework.Test;
 import junit.framework.TestCase;
 import junit.framework.TestSuite;
@@ -66,6 +68,26 @@
         assertEquals(0, norm, 4.0e-15);
     }
 
+    public void testNoAccessBelowDiagonal() {
+        checkNoAccessBelowDiagonal(testSquare5);
+        checkNoAccessBelowDiagonal(testSquare3);
+    }
+
+    private void checkNoAccessBelowDiagonal(double[][] data) {
+        double[][] modifiedData = new double[data.length][];
+        for (int i = 0; i < data.length; ++i) {
+            modifiedData[i] = data[i].clone();
+            Arrays.fill(modifiedData[i], 0, i, Double.NaN);
+        }
+        RealMatrix matrix = new RealMatrixImpl(modifiedData, false);
+        TriDiagonalTransformer transformer = new TriDiagonalTransformer(matrix);
+        RealMatrix q  = transformer.getQ();
+        RealMatrix qT = transformer.getQT();
+        RealMatrix t  = transformer.getT();
+        double norm = q.multiply(t).multiply(qT).subtract(new RealMatrixImpl(data, false)).getNorm();
+        assertEquals(0, norm, 4.0e-15);
+    }
+
     public void testQOrthogonal() {
         checkOrthogonal(new TriDiagonalTransformer(new RealMatrixImpl(testSquare5, false)).getQ());
         checkOrthogonal(new TriDiagonalTransformer(new RealMatrixImpl(testSquare3, false)).getQ());



Mime
View raw message