* move dummy_precision and epsilon to NumTraits

* make NumTraits inherits std::numeric_limits
This commit is contained in:
Gael Guennebaud
2010-02-10 10:52:28 +01:00
parent c11df02f0d
commit fe0827495a
34 changed files with 108 additions and 103 deletions

View File

@@ -35,7 +35,7 @@ template<typename MatrixType> void inverse_permutation_4x4()
{
MatrixType m = PermutationMatrix<4>(indices);
MatrixType inv = m.inverse();
double error = double( (m*inv-MatrixType::Identity()).norm() / epsilon<Scalar>() );
double error = double( (m*inv-MatrixType::Identity()).norm() / NumTraits<Scalar>::epsilon() );
VERIFY(error == 0.0);
std::next_permutation(indices.data(),indices.data()+4);
}
@@ -53,9 +53,9 @@ template<typename MatrixType> void inverse_general_4x4(int repeat)
do {
m = MatrixType::Random();
absdet = ei_abs(m.determinant());
} while(absdet < epsilon<Scalar>());
} while(absdet < NumTraits<Scalar>::epsilon());
MatrixType inv = m.inverse();
double error = double( (m*inv-MatrixType::Identity()).norm() * absdet / epsilon<Scalar>() );
double error = double( (m*inv-MatrixType::Identity()).norm() * absdet / NumTraits<Scalar>::epsilon() );
error_sum += error;
error_max = std::max(error_max, error);
}

View File

@@ -26,7 +26,7 @@
#include <Eigen/QR>
template<typename Derived1, typename Derived2>
bool areNotApprox(const MatrixBase<Derived1>& m1, const MatrixBase<Derived2>& m2, typename Derived1::RealScalar epsilon = dummy_precision<typename Derived1::RealScalar>())
bool areNotApprox(const MatrixBase<Derived1>& m1, const MatrixBase<Derived2>& m2, typename Derived1::RealScalar epsilon = NumTraits<typename Derived1::RealScalar>::dummy_precision())
{
return !((m1-m2).cwiseAbs2().maxCoeff() < epsilon * epsilon
* std::max(m1.cwiseAbs2().maxCoeff(), m2.cwiseAbs2().maxCoeff()));