mirror of
https://gitlab.com/libeigen/eigen.git
synced 2026-04-10 11:34:33 +08:00
Fix gpu special function tests.
Some checks used incorrect values, partly from copy-paste errors,
partly from the change in behaviour introduced in !398.
Modified results to match scipy, simplified tests by updating
`VERIFY_IS_CWISE_APPROX` to work for scalars.
(cherry picked from commit 701f5d1c91)
This commit is contained in:
18
test/main.h
18
test/main.h
@@ -391,6 +391,8 @@ inline void verify_impl(bool condition, const char *testname, const char *file,
|
||||
#define VERIFY_IS_NOT_MUCH_SMALLER_THAN(a, b) VERIFY(!test_isMuchSmallerThan(a, b))
|
||||
#define VERIFY_IS_APPROX_OR_LESS_THAN(a, b) VERIFY(test_isApproxOrLessThan(a, b))
|
||||
#define VERIFY_IS_NOT_APPROX_OR_LESS_THAN(a, b) VERIFY(!test_isApproxOrLessThan(a, b))
|
||||
#define VERIFY_IS_CWISE_EQUAL(a, b) VERIFY(verifyIsCwiseApprox(a, b, true))
|
||||
#define VERIFY_IS_CWISE_APPROX(a, b) VERIFY(verifyIsCwiseApprox(a, b, false))
|
||||
|
||||
#define VERIFY_IS_UNITARY(a) VERIFY(test_isUnitary(a))
|
||||
|
||||
@@ -598,6 +600,22 @@ inline bool verifyIsApprox(const Type1& a, const Type2& b)
|
||||
return ret;
|
||||
}
|
||||
|
||||
// verifyIsCwiseApprox is a wrapper to test_isCwiseApprox that outputs the relative difference magnitude if the test fails.
|
||||
template<typename Type1, typename Type2>
|
||||
inline bool verifyIsCwiseApprox(const Type1& a, const Type2& b, bool exact)
|
||||
{
|
||||
bool ret = test_isCwiseApprox(a,b,exact);
|
||||
if(!ret) {
|
||||
if (exact) {
|
||||
std::cerr << "Values are not an exact match";
|
||||
} else {
|
||||
std::cerr << "Difference too large wrt tolerance " << get_test_precision(a);
|
||||
}
|
||||
std::cerr << ", relative error is: " << test_relative_error(a,b) << std::endl;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
// The idea behind this function is to compare the two scalars a and b where
|
||||
// the scalar ref is a hint about the expected order of magnitude of a and b.
|
||||
// WARNING: the scalar a and b must be positive
|
||||
|
||||
Reference in New Issue
Block a user