diff options
author | 2007-10-13 14:19:23 +0000 | |
---|---|---|
committer | 2007-10-13 14:19:23 +0000 | |
commit | 12bcafdc7587d3ea14195eeeb1e9a307db6131cd (patch) | |
tree | dd5653078dd1eb26c755f301218ee8407e26ed4b /test | |
parent | a4626cc80837007673dd95e43c4a97e636ae79eb (diff) |
some renaming in the fuzzy compares, and in the multiplications
Diffstat (limited to 'test')
-rw-r--r-- | test/main.h | 45 | ||||
-rw-r--r-- | test/matrixops.cpp | 2 |
2 files changed, 31 insertions, 16 deletions
diff --git a/test/main.h b/test/main.h index 85968134c..fcb1b23ab 100644 --- a/test/main.h +++ b/test/main.h @@ -57,32 +57,47 @@ template<> inline int TestEpsilon<std::complex<int> >() { return TestEpsilon<int template<> inline float TestEpsilon<std::complex<float> >() { return TestEpsilon<float>(); } template<> inline double TestEpsilon<std::complex<double> >() { return TestEpsilon<double>(); } -template<typename T> bool TestNegligible(const T& a, const T& b) +template<typename T> bool TestMuchSmallerThan(const T& a, const T& b) { - return(Abs(a) <= Abs(b) * TestEpsilon<T>()); + return NumTraits<T>::isMuchSmallerThan(a, b, TestEpsilon<T>()); } -//template<typename Scalar, typename Derived, typename OtherDerived> -//bool TestNegligible +template<typename Scalar, typename Derived, typename OtherDerived> +bool TestMuchSmallerThan( + const Object<Scalar, Derived>& a, + const Object<Scalar, OtherDerived>& b) +{ + return a.isMuchSmallerThan(b, TestEpsilon<Scalar>()); +} template<typename T> bool TestApprox(const T& a, const T& b) { - if(Eigen::NumTraits<T>::IsFloat) - return(Abs(a - b) <= std::min(Abs(a), Abs(b)) * TestEpsilon<T>()); - else - return(a == b); + return NumTraits<T>::isApprox(a, b, TestEpsilon<T>()); +} + +template<typename Scalar, typename Derived, typename OtherDerived> +bool TestApprox( + const Object<Scalar, Derived>& a, + const Object<Scalar, OtherDerived>& b) +{ + return a.isApprox(b, TestEpsilon<Scalar>()); +} + +template<typename T> bool TestApproxOrLessThan(const T& a, const T& b) +{ + return NumTraits<T>::isApproxOrLessThan(a, b, TestEpsilon<T>()); } -template<typename T> bool TestLessThanOrApprox(const T& a, const T& b) +template<typename Scalar, typename Derived, typename OtherDerived> +bool TestApproxOrLessThan( + const Object<Scalar, Derived>& a, + const Object<Scalar, OtherDerived>& b) { - if(Eigen::NumTraits<T>::IsFloat) - return(a < b || Approx(a, b)); - else - return(a <= b); + return a.isApproxOrLessThan(b, TestEpsilon<Scalar>()); } -#define QVERIFY_NEGLIGIBLE(a, b) QVERIFY(TestNegligible(a, b)) +#define QVERIFY_MUCH_SMALLER_THAN(a, b) QVERIFY(TestMuchSmallerThan(a, b)) #define QVERIFY_APPROX(a, b) QVERIFY(TestApprox(a, b)) -#define QVERIFY_LESS_THAN_OR_APPROX(a, b) QVERIFY(TestLessThanOrApprox(a, b)) +#define QVERIFY_APPROX_OR_LESS_THAN(a, b) QVERIFY(TestApproxOrLessThan(a, b)) #endif // EI_TEST_MAIN_H diff --git a/test/matrixops.cpp b/test/matrixops.cpp index c763ff687..9c0933d89 100644 --- a/test/matrixops.cpp +++ b/test/matrixops.cpp @@ -51,7 +51,7 @@ template<typename MatrixType1, if(rows1 == cols1) { a *= b; - a.lazyMul(b); + a.lazyProduct(b); } MatrixType1 d(rows1, cols1); |