From f31b5a71148387310a55a96158a494e83a19a0e2 Mon Sep 17 00:00:00 2001 From: Benoit Jacob Date: Mon, 24 Aug 2009 00:35:42 -0400 Subject: add test for absDeterminant() --- test/qr_fullpivoting.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) 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 void qr() template void qr_invertible() { typedef typename NumTraits::Real RealScalar; + typedef typename MatrixType::Scalar Scalar; + int size = ei_random(10,50); MatrixType m1(size, size), m2(size, size), m3(size, size); @@ -88,6 +90,15 @@ template 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(); + 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 void qr_verify_assert() -- cgit v1.2.3