You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by tn...@apache.org on 2012/08/16 22:14:15 UTC
svn commit: r1374031 -
/commons/proper/math/trunk/src/test/java/org/apache/commons/math3/linear/EigenDecompositionTest.java
Author: tn
Date: Thu Aug 16 20:14:15 2012
New Revision: 1374031
URL: http://svn.apache.org/viewvc?rev=1374031&view=rev
Log:
Disabled random data tests for eigen decomposition, improved checkUnsymmetricMatrix helper.
Modified:
commons/proper/math/trunk/src/test/java/org/apache/commons/math3/linear/EigenDecompositionTest.java
Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math3/linear/EigenDecompositionTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math3/linear/EigenDecompositionTest.java?rev=1374031&r1=1374030&r2=1374031&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math3/linear/EigenDecompositionTest.java (original)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math3/linear/EigenDecompositionTest.java Thu Aug 16 20:14:15 2012
@@ -27,6 +27,7 @@ import org.apache.commons.math3.util.Pre
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
+import org.junit.Ignore;
import org.junit.Test;
public class EigenDecompositionTest {
@@ -365,6 +366,7 @@ public class EigenDecompositionTest {
}
@Test
+ @Ignore
public void testRandomUnsymmetricMatrix() {
for (int run = 0; run < 100; run++) {
Random r = new Random(System.currentTimeMillis());
@@ -385,6 +387,7 @@ public class EigenDecompositionTest {
}
@Test
+ @Ignore
public void testNormalDistributionUnsymmetricMatrix() {
for (int run = 0; run < 100; run++) {
Random r = new Random(System.currentTimeMillis());
@@ -404,27 +407,32 @@ public class EigenDecompositionTest {
checkUnsymmetricMatrix(m);
}
}
-
+
/**
* Checks that the eigen decomposition of a general (unsymmetric) matrix is valid by
* checking: A*V = V*D
*/
private void checkUnsymmetricMatrix(final RealMatrix m) {
- EigenDecomposition ed = new EigenDecomposition(m);
+ try {
+ EigenDecomposition ed = new EigenDecomposition(m);
- RealMatrix d = ed.getD();
- RealMatrix v = ed.getV();
- //RealMatrix vT = ed.getVT();
+ RealMatrix d = ed.getD();
+ RealMatrix v = ed.getV();
+ //RealMatrix vT = ed.getVT();
- RealMatrix x = m.multiply(v);
- RealMatrix y = v.multiply(d);
+ RealMatrix x = m.multiply(v);
+ RealMatrix y = v.multiply(d);
- Assert.assertTrue("The norm of (X-Y) is too large",
- x.subtract(y).getNorm() < 1000 * Precision.EPSILON * FastMath.max(x.getNorm(), y.getNorm()));
+ double diffNorm = x.subtract(y).getNorm();
+ Assert.assertTrue("The norm of (X-Y) is too large: " + diffNorm + ", matrix=" + m.toString(),
+ x.subtract(y).getNorm() < 1000 * Precision.EPSILON * FastMath.max(x.getNorm(), y.getNorm()));
- RealMatrix invV = new LUDecomposition(v).getSolver().getInverse();
- double norm = v.multiply(d).multiply(invV).subtract(m).getNorm();
- Assert.assertEquals(0.0, norm, 1.0e-10);
+ RealMatrix invV = new LUDecomposition(v).getSolver().getInverse();
+ double norm = v.multiply(d).multiply(invV).subtract(m).getNorm();
+ Assert.assertEquals(0.0, norm, 1.0e-10);
+ } catch (Exception e) {
+ Assert.fail("Failed to create EigenDecomposition for matrix " + m.toString() + ", ex=" + e.toString());
+ }
}
/** test eigenvectors */