void vctDeterminantTest::TestDeterminant2x2ByInverse(const vctFixedSizeMatrix<ElementType, 2, 2> & inputMatrix) { const ElementType determinant = vctDeterminant<2>::Compute(inputMatrix); const ElementType tolerance = cmnTypeTraits<ElementType>::Tolerance(); if (fabs(determinant) < tolerance) { vctFixedSizeVector<ElementType, 2> rowRatio; rowRatio.ElementwiseRatioOf( inputMatrix.Row(0), inputMatrix.Row(1) ); CPPUNIT_ASSERT_DOUBLES_EQUAL( rowRatio[0], rowRatio[1], tolerance ); vctFixedSizeVector<ElementType, 2> columnRatio; columnRatio.ElementwiseRatioOf( inputMatrix.Column(0), inputMatrix.Column(1) ); CPPUNIT_ASSERT_DOUBLES_EQUAL( columnRatio[0], columnRatio[1], tolerance ); return; } const vctFixedSizeMatrix<ElementType, 2, 2> inverse( inputMatrix[1][1] / determinant, -inputMatrix[0][1] / determinant, -inputMatrix[1][0] / determinant, inputMatrix[0][0] / determinant ); /* gcc (Ubuntu 4.4.3-4ubuntu5) 4.4.3 crashes with internal error on ubuntu 64 - Ubuntu 10.04.1 LTS with const */ /* const */ vctFixedSizeMatrix<ElementType, 2, 2> product( inputMatrix * inverse ); const vctFixedSizeMatrix<ElementType, 2, 2> identity( ElementType(1), ElementType(0), ElementType(0), ElementType(1) ); const vctFixedSizeMatrix<ElementType, 2, 2> difference = product - identity; ElementType diffNorm = difference.Norm(); CPPUNIT_ASSERT_DOUBLES_EQUAL( 0, diffNorm, tolerance ); }