From 3e006bfd31e4389e8c5718c30409cddb65a73b04 Mon Sep 17 00:00:00 2001 From: Guoqiang QI Date: Thu, 13 May 2021 15:03:30 +0000 Subject: Ensure all generated matrices for inverse_4x4 testes are invertible, this fix #2248 . --- test/prec_inverse_4x4.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/test/prec_inverse_4x4.cpp b/test/prec_inverse_4x4.cpp index 072466467..86f057118 100644 --- a/test/prec_inverse_4x4.cpp +++ b/test/prec_inverse_4x4.cpp @@ -30,18 +30,17 @@ template void inverse_general_4x4(int repeat) { using std::abs; typedef typename MatrixType::Scalar Scalar; - typedef typename MatrixType::RealScalar RealScalar; double error_sum = 0., error_max = 0.; for(int i = 0; i < repeat; ++i) { MatrixType m; - RealScalar absdet; + bool is_invertible; do { m = MatrixType::Random(); - absdet = abs(m.determinant()); - } while(absdet < NumTraits::epsilon()); + is_invertible = Eigen::FullPivLU(m).isInvertible(); + } while(!is_invertible); MatrixType inv = m.inverse(); - double error = double( (m*inv-MatrixType::Identity()).norm() * absdet / NumTraits::epsilon() ); + double error = double( (m*inv-MatrixType::Identity()).norm()); error_sum += error; error_max = (std::max)(error_max, error); } -- cgit v1.2.3