big rewrite in Inverse.h

in particular, the API is essentially finalized and the 4x4 case is fixed to be numerically stable.
This commit is contained in:
Benoit Jacob
2009-10-26 11:18:23 -04:00
parent 68d48511b2
commit ec02388a5d
3 changed files with 259 additions and 215 deletions

View File

@@ -53,9 +53,6 @@ template<typename MatrixType> void inverse(const MatrixType& m)
m2 = m1.inverse();
VERIFY_IS_APPROX(m1, m2.inverse() );
m1.computeInverse(&m2);
VERIFY_IS_APPROX(m1, m2.inverse() );
VERIFY_IS_APPROX((Scalar(2)*m2).inverse(), m2.inverse()*Scalar(0.5));
VERIFY_IS_APPROX(identity, m1.inverse() * m1 );
@@ -66,17 +63,23 @@ template<typename MatrixType> void inverse(const MatrixType& m)
// since for the general case we implement separately row-major and col-major, test that
VERIFY_IS_APPROX(m1.transpose().inverse(), m1.inverse().transpose());
//computeInverseWithCheck tests
#if !defined(EIGEN_TEST_PART_5) && !defined(EIGEN_TEST_PART_6)
//computeInverseAndDetWithCheck tests
//First: an invertible matrix
bool invertible = m1.computeInverseWithCheck(&m2);
bool invertible;
RealScalar det;
m1.computeInverseAndDetWithCheck(m2, det, invertible);
VERIFY(invertible);
VERIFY_IS_APPROX(identity, m1*m2);
VERIFY_IS_APPROX(det, m1.determinant());
//Second: a rank one matrix (not invertible, except for 1x1 matrices)
VectorType v3 = VectorType::Random(rows);
MatrixType m3 = v3*v3.transpose(), m4(rows,cols);
invertible = m3.computeInverseWithCheck( &m4 );
m3.computeInverseAndDetWithCheck(m4, det, invertible);
VERIFY( rows==1 ? invertible : !invertible );
VERIFY_IS_APPROX(det, m3.determinant());
#endif
}
void test_inverse()