mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-04-23 10:09:36 +08:00
Ensure all generated matrices for inverse_4x4 testes are invertible, this fix #2248 .
This commit is contained in:
parent
972cf0c28a
commit
3e006bfd31
@ -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);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user