aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/prec_inverse_4x4.cpp
diff options
context:
space:
mode:
authorGravatar Benoit Jacob <jacob.benoit.1@gmail.com>2009-11-23 11:24:06 -0500
committerGravatar Benoit Jacob <jacob.benoit.1@gmail.com>2009-11-23 11:24:06 -0500
commite6ea9e401c6933c102a534d853eb2b59cdd6be3b (patch)
tree733d2da2b621cf3963f2a9d6bcef5a127f8b4e62 /test/prec_inverse_4x4.cpp
parent44d0d667cd629a18e29b9c248633891c1b04f75c (diff)
improve precision test
Diffstat (limited to 'test/prec_inverse_4x4.cpp')
-rw-r--r--test/prec_inverse_4x4.cpp28
1 files changed, 25 insertions, 3 deletions
diff --git a/test/prec_inverse_4x4.cpp b/test/prec_inverse_4x4.cpp
index 77763f830..c5c7af5d2 100644
--- a/test/prec_inverse_4x4.cpp
+++ b/test/prec_inverse_4x4.cpp
@@ -26,6 +26,28 @@
#include <Eigen/LU>
#include <algorithm>
+Matrix4f inverse(const Matrix4f& m)
+{
+ Matrix4f r;
+ r(0,0) = m.minor(0,0).determinant();
+ r(1,0) = -m.minor(0,1).determinant();
+ r(2,0) = m.minor(0,2).determinant();
+ r(3,0) = -m.minor(0,3).determinant();
+ r(0,2) = m.minor(2,0).determinant();
+ r(1,2) = -m.minor(2,1).determinant();
+ r(2,2) = m.minor(2,2).determinant();
+ r(3,2) = -m.minor(2,3).determinant();
+ r(0,1) = -m.minor(1,0).determinant();
+ r(1,1) = m.minor(1,1).determinant();
+ r(2,1) = -m.minor(1,2).determinant();
+ r(3,1) = m.minor(1,3).determinant();
+ r(0,3) = -m.minor(3,0).determinant();
+ r(1,3) = m.minor(3,1).determinant();
+ r(2,3) = -m.minor(3,2).determinant();
+ r(3,3) = m.minor(3,3).determinant();
+ return r / (m(0,0)*r(0,0) + m(1,0)*r(0,1) + m(2,0)*r(0,2) + m(3,0)*r(0,3));
+}
+
template<typename MatrixType> void inverse_permutation_4x4()
{
typedef typename MatrixType::Scalar Scalar;
@@ -42,7 +64,7 @@ template<typename MatrixType> void inverse_permutation_4x4()
}
std::cerr << "inverse_permutation_4x4, Scalar = " << type_name<Scalar>() << std::endl;
EIGEN_DEBUG_VAR(error_max);
- VERIFY(error_max < (NumTraits<Scalar>::IsComplex ? 150.0 : 60.) );
+ VERIFY(error_max < 1. );
}
template<typename MatrixType> void inverse_general_4x4(int repeat)
@@ -57,7 +79,7 @@ template<typename MatrixType> void inverse_general_4x4(int repeat)
do {
m = MatrixType::Random();
absdet = ei_abs(m.determinant());
- } while(absdet == RealScalar(0));
+ } while(absdet < 2*epsilon<Scalar>() );
MatrixType inv = m.inverse();
double error = double( (m*inv-MatrixType::Identity()).norm() * absdet / epsilon<Scalar>() );
error_sum += error;
@@ -68,7 +90,7 @@ template<typename MatrixType> void inverse_general_4x4(int repeat)
EIGEN_DEBUG_VAR(error_avg);
EIGEN_DEBUG_VAR(error_max);
VERIFY(error_avg < (NumTraits<Scalar>::IsComplex ? 8.4 : 1.4) );
- VERIFY(error_max < (NumTraits<Scalar>::IsComplex ? 150.0 : 60.) );
+ VERIFY(error_max < (NumTraits<Scalar>::IsComplex ? 150.0 : 75.) );
}
void test_prec_inverse_4x4()