35 #ifndef NEKTAR_LIB_UTILITIES_REALCOMPARISON_H
36 #define NEKTAR_LIB_UTILITIES_REALCOMPARISON_H
41 #include <type_traits>
42 #include <boost/math/special_functions/relative_difference.hpp>
46 namespace LibUtilities
52 class =
typename std::enable_if
54 std::is_floating_point
56 typename std::remove_cv<
57 typename std::remove_reference<T1>::type>::type
61 typename std::remove_cv<
62 typename std::remove_reference<T1>::type>::type,
63 typename std::remove_cv<
64 typename std::remove_reference<T2>::type>::type
72 ASSERTL1(factor >= 1,
"real comparison factor needs to be >= 1");
74 return boost::math::epsilon_difference(lhs, rhs) < factor;
81 class =
typename std::enable_if
83 std::is_floating_point
85 typename std::remove_cv<
86 typename std::remove_reference<T1>::type>::type
90 typename std::remove_cv<
91 typename std::remove_reference<T1>::type>::type,
92 typename std::remove_cv<
93 typename std::remove_reference<T2>::type>::type
101 ASSERTL1(tol >= 0,
"real comparison tolerance needs to be >= 0");
#define ASSERTL1(condition, msg)
Assert Level 1 – Debugging which is used whether in FULLDEBUG or DEBUG compilation mode....
bool IsRealClose(T1 &&lhs, T2 &&rhs, const NekDouble tol=NekConstants::kNekMachineEpsilon)
compare reals of same type with absolute tolerance
bool IsRealEqual(T1 &&lhs, T2 &&rhs, const unsigned int factor=NekConstants::kNekFloatCompFact)
compare reals of same type with relative tolerance
static const unsigned int kNekFloatCompFact
static const NekDouble kNekMachineEpsilon
The above copyright notice and this permission notice shall be included.
scalarT< T > abs(scalarT< T > in)