mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-01-24 14:45:14 +08:00
Added support for fp16 to test_isApprox, test_isMuchSmallerThan, and test_isApproxOrLessThan
This commit is contained in:
parent
5c13765ee3
commit
7b3d7acebe
12
test/main.h
12
test/main.h
@ -316,9 +316,9 @@ inline bool test_isMuchSmallerThan(const float& a, const float& b)
|
||||
{ return internal::isMuchSmallerThan(a, b, test_precision<float>()); }
|
||||
inline bool test_isApproxOrLessThan(const float& a, const float& b)
|
||||
{ return internal::isApproxOrLessThan(a, b, test_precision<float>()); }
|
||||
|
||||
inline bool test_isApprox(const double& a, const double& b)
|
||||
{ return internal::isApprox(a, b, test_precision<double>()); }
|
||||
|
||||
inline bool test_isMuchSmallerThan(const double& a, const double& b)
|
||||
{ return internal::isMuchSmallerThan(a, b, test_precision<double>()); }
|
||||
inline bool test_isApproxOrLessThan(const double& a, const double& b)
|
||||
@ -359,6 +359,12 @@ inline bool test_isApproxOrLessThan(const long double& a, const long double& b)
|
||||
{ return internal::isApproxOrLessThan(a, b, test_precision<long double>()); }
|
||||
#endif // EIGEN_TEST_NO_LONGDOUBLE
|
||||
|
||||
inline bool test_isApprox(const half& a, const half& b)
|
||||
{ return internal::isApprox(a, b, test_precision<half>()); }
|
||||
inline bool test_isMuchSmallerThan(const half& a, const half& b)
|
||||
{ return internal::isMuchSmallerThan(a, b, test_precision<half>()); }
|
||||
inline bool test_isApproxOrLessThan(const half& a, const half& b)
|
||||
{ return internal::isApproxOrLessThan(a, b, test_precision<half>()); }
|
||||
|
||||
// test_relative_error returns the relative difference between a and b as a real scalar as used in isApprox.
|
||||
template<typename T1,typename T2>
|
||||
@ -426,9 +432,7 @@ template<typename T1,typename T2>
|
||||
typename NumTraits<T1>::Real test_relative_error(const T1 &a, const T2 &b, typename internal::enable_if<internal::is_arithmetic<typename NumTraits<T1>::Real>::value, T1>::type* = 0)
|
||||
{
|
||||
typedef typename NumTraits<T1>::Real RealScalar;
|
||||
using std::min;
|
||||
using std::sqrt;
|
||||
return sqrt(RealScalar(numext::abs2(a-b))/RealScalar((min)(numext::abs2(a),numext::abs2(b))));
|
||||
return numext::sqrt(RealScalar(numext::abs2(a-b))/RealScalar((numext::mini)(numext::abs2(a),numext::abs2(b))));
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
|
Loading…
Reference in New Issue
Block a user