From 62ec1dd616377721d8be414911721bdc8967d677 Mon Sep 17 00:00:00 2001 From: Benoit Jacob Date: Tue, 15 Jul 2008 23:56:17 +0000 Subject: * big rework of Inverse.h: - remove all invertibility checking, will be redundant with LU - general case: adapt to matrix storage order for better perf - size 4 case: handle corner cases without falling back to gen case. - rationalize with selectors instead of compile time if - add C-style computeInverse() * update inverse test. * in snippets, default cout precision to 3 decimal places * add some cmake module from kdelibs to support btl with cmake 2.4 --- test/inverse.cpp | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) (limited to 'test/inverse.cpp') diff --git a/test/inverse.cpp b/test/inverse.cpp index ac5d7f180..0324cd1ea 100644 --- a/test/inverse.cpp +++ b/test/inverse.cpp @@ -38,32 +38,30 @@ template void inverse(const MatrixType& m) MatrixType m1 = MatrixType::random(rows, cols), m2 = MatrixType::random(rows, cols), - m3(rows, cols), mzero = MatrixType::zero(rows, cols), identity = MatrixType::identity(rows, rows); m2 = m1.inverse(); VERIFY_IS_APPROX(m1, m2.inverse() ); - m3 = (m1+m2).inverse(); - VERIFY_IS_APPROX(m3+m1, (m1+m2).inverse()+m1); + m1.computeInverse(&m2); + VERIFY_IS_APPROX(m1, m2.inverse() ); - VERIFY_IS_APPROX(m1, m1.inverse().eval().inverse() ); + VERIFY_IS_APPROX((Scalar(2)*m2).inverse(), m2.inverse()*Scalar(0.5)); - VERIFY_IS_NOT_APPROX(m1, m1.inverse() ); VERIFY_IS_APPROX(identity, m1.inverse() * m1 ); VERIFY_IS_APPROX(identity, m1 * m1.inverse() ); - // this one fails: - VERIFY_IS_APPROX(m1, (m1.inverse()).inverse() ); + VERIFY_IS_APPROX(m1, m1.inverse().inverse() ); } void test_inverse() { for(int i = 0; i < 1; i++) { - CALL_SUBTEST( inverse(Matrix2f()) ); + CALL_SUBTEST( inverse(Matrix()) ); + CALL_SUBTEST( inverse(Matrix2d()) ); CALL_SUBTEST( inverse(Matrix3f()) ); - CALL_SUBTEST( inverse(Matrix4d()) ); -// CALL_SUBTEST( inverse(MatrixXcd(7,7)) ); + CALL_SUBTEST( inverse(Matrix4f()) ); + CALL_SUBTEST( inverse(MatrixXcd(7,7)) ); } } -- cgit v1.2.3