aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Guoqiang QI <guoqiang.qi1@gmail.com>2021-05-13 15:03:30 +0000
committerGravatar Rasmus Munk Larsen <rmlarsen@google.com>2021-05-13 15:03:30 +0000
commit3e006bfd31e4389e8c5718c30409cddb65a73b04 (patch)
treedc384cc8a6d59d0cca08b148185de5d6faab6d71
parent972cf0c28a8d2ee0808c1277dea2c5c206591ce6 (diff)
Ensure all generated matrices for inverse_4x4 testes are invertible, this fix #2248 .
-rw-r--r--test/prec_inverse_4x4.cpp9
1 files 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<typename MatrixType> 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<Scalar>::epsilon());
+ is_invertible = Eigen::FullPivLU<MatrixType>(m).isInvertible();
+ } while(!is_invertible);
MatrixType inv = m.inverse();
- double error = double( (m*inv-MatrixType::Identity()).norm() * absdet / NumTraits<Scalar>::epsilon() );
+ double error = double( (m*inv-MatrixType::Identity()).norm());
error_sum += error;
error_max = (std::max)(error_max, error);
}