pimathfloatnullcompare
This commit is contained in:
@@ -117,4 +117,33 @@ inline PIVector2D<double> abs(const PIVector2D<complexd> & v) {
|
|||||||
return result;
|
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
|
#endif // PIMATHCOMPLEX_H
|
||||||
|
|||||||
@@ -28,34 +28,6 @@
|
|||||||
#include "pimathvector.h"
|
#include "pimathvector.h"
|
||||||
#include "pimathcomplex.h"
|
#include "pimathcomplex.h"
|
||||||
|
|
||||||
/**
|
|
||||||
* @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 _PIMathMatrixNullCompare(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 _PIMathMatrixNullCompare(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));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/// Matrix templated
|
/// Matrix templated
|
||||||
|
|
||||||
@@ -1219,7 +1191,7 @@ public:
|
|||||||
for (uint k = i; k < _V2D::cols_; ++k) smat.element(k, j) -= mul * smat.element(k, i);
|
for (uint k = i; k < _V2D::cols_; ++k) smat.element(k, j) -= mul * smat.element(k, i);
|
||||||
}
|
}
|
||||||
if (i < _V2D::cols_ - 1) {
|
if (i < _V2D::cols_ - 1) {
|
||||||
if (_PIMathMatrixNullCompare(smat.element(i + 1, i + 1))) {
|
if (PIMathFloatNullCompare(smat.element(i + 1, i + 1))) {
|
||||||
if (ok != 0) *ok = false;
|
if (ok != 0) *ok = false;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
@@ -1269,7 +1241,7 @@ public:
|
|||||||
if (sv != 0) (*sv)[j] -= mul * (*sv)[i];
|
if (sv != 0) (*sv)[j] -= mul * (*sv)[i];
|
||||||
}
|
}
|
||||||
if (i < _V2D::cols_ - 1) {
|
if (i < _V2D::cols_ - 1) {
|
||||||
if (_PIMathMatrixNullCompare(smat.element(i + 1, i + 1))) {
|
if (PIMathFloatNullCompare(smat.element(i + 1, i + 1))) {
|
||||||
if (ok != 0) *ok = false;
|
if (ok != 0) *ok = false;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user