diff options
author | Benoit Jacob <jacob.benoit.1@gmail.com> | 2009-08-24 00:35:42 -0400 |
---|---|---|
committer | Benoit Jacob <jacob.benoit.1@gmail.com> | 2009-08-24 00:35:42 -0400 |
commit | f31b5a71148387310a55a96158a494e83a19a0e2 (patch) | |
tree | 6799f01b30a73c267547eb1894f67cc90f9113e9 | |
parent | c9a307f3303ba7b49bc119ee0043df88d53cd995 (diff) |
add test for absDeterminant()
-rw-r--r-- | test/qr_fullpivoting.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/test/qr_fullpivoting.cpp b/test/qr_fullpivoting.cpp index 1e0601a83..d784e0d43 100644 --- a/test/qr_fullpivoting.cpp +++ b/test/qr_fullpivoting.cpp @@ -68,6 +68,8 @@ template<typename MatrixType> void qr() template<typename MatrixType> void qr_invertible() { typedef typename NumTraits<typename MatrixType::Scalar>::Real RealScalar; + typedef typename MatrixType::Scalar Scalar; + int size = ei_random<int>(10,50); MatrixType m1(size, size), m2(size, size), m3(size, size); @@ -88,6 +90,15 @@ template<typename MatrixType> void qr_invertible() m3 = MatrixType::Random(size,size); VERIFY(qr.solve(m3, &m2)); VERIFY_IS_APPROX(m3, m1*m2); + + // now construct a matrix with prescribed determinant + m1.setZero(); + for(int i = 0; i < size; i++) m1(i,i) = ei_random<Scalar>(); + RealScalar absdet = ei_abs(m1.diagonal().prod()); + m3 = qr.matrixQ(); // get a unitary + m1 = m3 * m1 * m3; + qr.compute(m1); + VERIFY_IS_APPROX(absdet, qr.absDeterminant()); } template<typename MatrixType> void qr_verify_assert() |