Author: erans Date: Fri Jan 13 15:33:34 2012 New Revision: 1231133 URL: http://svn.apache.org/viewvc?rev=1231133&view=rev Log: Added a test.
Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/QRDecompositionTest.java Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/QRDecompositionTest.java URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/QRDecompositionTest.java?rev=1231133&r1=1231132&r2=1231133&view=diff ============================================================================== --- commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/QRDecompositionTest.java (original) +++ commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/QRDecompositionTest.java Fri Jan 13 15:33:34 2012 @@ -18,28 +18,29 @@ package org.apache.commons.math.linear; import java.util.Random; +import org.apache.commons.math.linear.SingularMatrixException; import org.junit.Assert; import org.junit.Test; public class QRDecompositionTest { - double[][] testData3x3NonSingular = { + private double[][] testData3x3NonSingular = { { 12, -51, 4 }, { 6, 167, -68 }, { -4, 24, -41 }, }; - double[][] testData3x3Singular = { + private double[][] testData3x3Singular = { { 1, 4, 7, }, { 2, 5, 8, }, { 3, 6, 9, }, }; - double[][] testData3x4 = { + private double[][] testData3x4 = { { 12, -51, 4, 1 }, { 6, 167, -68, 2 }, { -4, 24, -41, 3 }, }; - double[][] testData4x3 = { + private double[][] testData4x3 = { { 12, -51, 4, }, { 6, 167, -68, }, { -4, 24, -41, }, @@ -240,6 +241,14 @@ public class QRDecompositionTest { } + @Test(expected=SingularMatrixException.class) + public void testNonInvertible() { + QRDecomposition qr = + new QRDecomposition(MatrixUtils.createRealMatrix(testData3x3Singular)); + + final RealMatrix inv = qr.getSolver().getInverse(); + } + private RealMatrix createTestMatrix(final Random r, final int rows, final int columns) { RealMatrix m = MatrixUtils.createRealMatrix(rows, columns); m.walkInOptimizedOrder(new DefaultRealMatrixChangingVisitor(){