mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-04-23 10:09:36 +08:00
reduce false negative in the qr unit test
This commit is contained in:
parent
97965dde9b
commit
6df3bee687
@ -54,6 +54,8 @@ template<typename MatrixType> void qr_invertible()
|
|||||||
{
|
{
|
||||||
using std::log;
|
using std::log;
|
||||||
using std::abs;
|
using std::abs;
|
||||||
|
using std::pow;
|
||||||
|
using std::max;
|
||||||
typedef typename NumTraits<typename MatrixType::Scalar>::Real RealScalar;
|
typedef typename NumTraits<typename MatrixType::Scalar>::Real RealScalar;
|
||||||
typedef typename MatrixType::Scalar Scalar;
|
typedef typename MatrixType::Scalar Scalar;
|
||||||
|
|
||||||
@ -65,7 +67,7 @@ template<typename MatrixType> void qr_invertible()
|
|||||||
if (internal::is_same<RealScalar,float>::value)
|
if (internal::is_same<RealScalar,float>::value)
|
||||||
{
|
{
|
||||||
// let's build a matrix more stable to inverse
|
// let's build a matrix more stable to inverse
|
||||||
MatrixType a = MatrixType::Random(size,size*2);
|
MatrixType a = MatrixType::Random(size,size*4);
|
||||||
m1 += a * a.adjoint();
|
m1 += a * a.adjoint();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -81,8 +83,11 @@ template<typename MatrixType> void qr_invertible()
|
|||||||
m3 = qr.householderQ(); // get a unitary
|
m3 = qr.householderQ(); // get a unitary
|
||||||
m1 = m3 * m1 * m3;
|
m1 = m3 * m1 * m3;
|
||||||
qr.compute(m1);
|
qr.compute(m1);
|
||||||
VERIFY_IS_APPROX(absdet, qr.absDeterminant());
|
|
||||||
VERIFY_IS_APPROX(log(absdet), qr.logAbsDeterminant());
|
VERIFY_IS_APPROX(log(absdet), qr.logAbsDeterminant());
|
||||||
|
// This test is tricky if the determinant becomes too small.
|
||||||
|
// Since we generate random numbers with magnitude rrange [0,1], the average determinant is 0.5^size
|
||||||
|
VERIFY_IS_MUCH_SMALLER_THAN( abs(absdet-qr.absDeterminant()), (max)(RealScalar(pow(0.5,size)),(max)(abs(absdet),abs(qr.absDeterminant()))) );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename MatrixType> void qr_verify_assert()
|
template<typename MatrixType> void qr_verify_assert()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user