aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/qr.cpp
diff options
context:
space:
mode:
authorGravatar Gael Guennebaud <g.gael@free.fr>2014-02-14 09:58:30 +0100
committerGravatar Gael Guennebaud <g.gael@free.fr>2014-02-14 09:58:30 +0100
commit6df3bee68751bd0b25c19cf4aae48c41259a4066 (patch)
tree44bf486a672dc83cdbe9097cbc67cf4cb9f529a8 /test/qr.cpp
parent97965dde9bc079d042d3c4037e1927bee0df443f (diff)
reduce false negative in the qr unit test
Diffstat (limited to 'test/qr.cpp')
-rw-r--r--test/qr.cpp9
1 files changed, 7 insertions, 2 deletions
diff --git a/test/qr.cpp b/test/qr.cpp
index a79e0dd34..98738777f 100644
--- a/test/qr.cpp
+++ b/test/qr.cpp
@@ -54,6 +54,8 @@ template<typename MatrixType> void qr_invertible()
{
using std::log;
using std::abs;
+ using std::pow;
+ using std::max;
typedef typename NumTraits<typename MatrixType::Scalar>::Real RealScalar;
typedef typename MatrixType::Scalar Scalar;
@@ -65,7 +67,7 @@ template<typename MatrixType> void qr_invertible()
if (internal::is_same<RealScalar,float>::value)
{
// 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();
}
@@ -81,8 +83,11 @@ template<typename MatrixType> void qr_invertible()
m3 = qr.householderQ(); // get a unitary
m1 = m3 * m1 * m3;
qr.compute(m1);
- VERIFY_IS_APPROX(absdet, qr.absDeterminant());
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()