Merge pull request 'Improve template & doc for PIMathFloatNullCompare' (#43) from math into master

Reviewed-on: https://git.shs.tools/SHS/pip/pulls/43
This commit was merged in pull request #43.
This commit is contained in:
2020-09-28 11:52:33 +03:00

View File

@@ -119,10 +119,10 @@ inline PIVector2D<double> abs(const PIVector2D<complexd> & v) {
/** /**
* @brief Inline funtion of compare with zero different types * @brief floating point number specific comparison between value passed as parameter and zero
* *
* @param v is input parameter of type T * @param v floating point parameter for comparison
* @return true if zero, false if not zero * @return true if v in locality of zero, otherwise false
*/ */
template<typename T, typename std::enable_if<std::is_floating_point<T>::value, int>::type = 0> template<typename T, typename std::enable_if<std::is_floating_point<T>::value, int>::type = 0>
inline bool PIMathFloatNullCompare(const T v) { inline bool PIMathFloatNullCompare(const T v) {
@@ -131,15 +131,15 @@ inline bool PIMathFloatNullCompare(const T v) {
} }
/** /**
* @brief Inline funtion of compare with zero colmplexf type * @brief floating point number specific comparison between parameter value and zero.
* *
* @param v is input parameter of type colmplexf * @param v complex with floating point real and imag parts
* @return true if zero, false if not zero * @return true if absolute of v in locality of zero, otherwise false
*/ */
template<typename T,typename std::enable_if< template<typename T,typename std::enable_if<
std::is_floating_point<decltype(T::real)>::value || std::is_floating_point<decltype(T::real)>::value &&
std::is_floating_point<decltype(T::imag)>::value std::is_floating_point<decltype(T::imag)>::value
, int>::type = 0> , int>::type = 0>
inline bool PIMathFloatNullCompare(const T v) { 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.real)>::value, "Type must be floating point");
static_assert(std::is_floating_point<decltype(v.imag)>::value, "Type must be floating point"); static_assert(std::is_floating_point<decltype(v.imag)>::value, "Type must be floating point");