Skip to content

Commit 1e5d3da

Browse files
committed
Added unit-test.
Added a unit-test that checks if the determinant of a Matrix is equal to the determinant of its transpose. This test will break without the determinant-fix.
1 parent 2e5bbd1 commit 1e5d3da

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

test/gov/nasa/worldwind/geom/MatrixTest.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,26 @@ public void testInverseOfNearSingular()
136136
Matrix identity = m.multiply(mInv);
137137
assertTrue("Matrix inverse is incorrect", equals(identity, Matrix.IDENTITY, NEAR_SINGULAR_EQUALITY_TOLERANCE));
138138
}
139+
140+
@Test
141+
public void testDeterminantEqualToDeterminantOfTranspose()
142+
{
143+
// Create sample matrix.
144+
Matrix matrix = new Matrix(
145+
1, 0, 0, 1,
146+
1, 1, 0, 0,
147+
0, 0, 1, 0,
148+
0, 0, 0, 1);
149+
150+
// Calculate the determinant.
151+
double determinant = matrix.getDeterminant();
152+
153+
// Transpose the matrix.
154+
Matrix transpose = matrix.getTranspose();
155+
156+
// The determinant and the determinant of the transpose should be equal.
157+
assertEquals(determinant, transpose.getDeterminant(), EQUALITY_TOLERANCE);
158+
}
139159

140160
//**************************************************************//
141161
//******************** Helper Methods ************************//

0 commit comments

Comments
 (0)