pimathfloatnullcompare
This commit is contained in:
@@ -117,4 +117,33 @@ inline PIVector2D<double> abs(const PIVector2D<complexd> & v) {
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Inline funtion of compare with zero different types
|
||||
*
|
||||
* @param v is input parameter of type T
|
||||
* @return true if zero, false if not zero
|
||||
*/
|
||||
template<typename T, typename std::enable_if<std::is_floating_point<T>::value, int>::type = 0>
|
||||
inline bool PIMathFloatNullCompare(const T v) {
|
||||
static_assert(std::is_floating_point<T>::value, "Type must be floating point");
|
||||
return (piAbs(v) < T(1E-200));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Inline funtion of compare with zero colmplexf type
|
||||
*
|
||||
* @param v is input parameter of type colmplexf
|
||||
* @return true if zero, false if not zero
|
||||
*/
|
||||
template<typename T,typename std::enable_if<
|
||||
std::is_floating_point<decltype(T::real)>::value ||
|
||||
std::is_floating_point<decltype(T::imag)>::value
|
||||
, int>::type = 0>
|
||||
inline bool PIMathFloatNullCompare(const T v) {
|
||||
static_assert(std::is_floating_point<decltype(v.real)>::value, "Type must be floating point");
|
||||
static_assert(std::is_floating_point<decltype(v.imag)>::value, "Type must be floating point");
|
||||
return (abs(v) < float(1E-200));
|
||||
}
|
||||
|
||||
#endif // PIMATHCOMPLEX_H
|
||||
|
||||
Reference in New Issue
Block a user