mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-06-04 18:54:00 +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;
|
using std::abs;
|
||||||
typedef typename MatrixType::Scalar Scalar;
|
typedef typename MatrixType::Scalar Scalar;
|
||||||
typedef typename MatrixType::RealScalar RealScalar;
|
|
||||||
double error_sum = 0., error_max = 0.;
|
double error_sum = 0., error_max = 0.;
|
||||||
for(int i = 0; i < repeat; ++i)
|
for(int i = 0; i < repeat; ++i)
|
||||||
{
|
{
|
||||||
MatrixType m;
|
MatrixType m;
|
||||||
RealScalar absdet;
|
bool is_invertible;
|
||||||
do {
|
do {
|
||||||
m = MatrixType::Random();
|
m = MatrixType::Random();
|
||||||
absdet = abs(m.determinant());
|
is_invertible = Eigen::FullPivLU<MatrixType>(m).isInvertible();
|
||||||
} while(absdet < NumTraits<Scalar>::epsilon());
|
} while(!is_invertible);
|
||||||
MatrixType inv = m.inverse();
|
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_sum += error;
|
||||||
error_max = (std::max)(error_max, error);
|
error_max = (std::max)(error_max, error);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user