template experiment, PIMutex recursive in all systems

This commit is contained in:
2020-09-25 14:34:07 +03:00
parent 53cd72a4b0
commit a42e5a7756
2 changed files with 9 additions and 15 deletions

View File

@@ -34,7 +34,7 @@
* @param v is input parameter of type T * @param v is input parameter of type T
* @return true if zero, false if not zero * @return true if zero, false if not zero
*/ */
template<typename T> template<typename T, typename std::enable_if<std::is_floating_point<T>::value, int>::type = 0>
inline bool _PIMathMatrixNullCompare(const T v) { inline bool _PIMathMatrixNullCompare(const T v) {
static_assert(std::is_floating_point<T>::value, "Type must be floating point"); static_assert(std::is_floating_point<T>::value, "Type must be floating point");
return (piAbs(v) < T(1E-200)); return (piAbs(v) < T(1E-200));
@@ -46,22 +46,16 @@ inline bool _PIMathMatrixNullCompare(const T v) {
* @param v is input parameter of type colmplexf * @param v is input parameter of type colmplexf
* @return true if zero, false if not zero * @return true if zero, false if not zero
*/ */
template<> template<typename T,typename std::enable_if<
inline bool _PIMathMatrixNullCompare<complexf>(const complexf v) { 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)); return (abs(v) < float(1E-200));
} }
/**
* @brief Inline funtion of compare with zero complexd type
*
* @param v is input parameter of type colmplexd
* @return true if zero, false if not zero
*/
template<>
inline bool _PIMathMatrixNullCompare<complexd>(const complexd v) {
return (abs(v) < double(1E-200));
}
/// Matrix templated /// Matrix templated

View File

@@ -105,7 +105,7 @@ void PIMutex::init() {
pthread_mutexattr_t attr; pthread_mutexattr_t attr;
memset(&attr, 0, sizeof(attr)); memset(&attr, 0, sizeof(attr));
pthread_mutexattr_init(&attr); pthread_mutexattr_init(&attr);
pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_NORMAL); pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
memset(&(PRIVATE->mutex), 0, sizeof(PRIVATE->mutex)); memset(&(PRIVATE->mutex), 0, sizeof(PRIVATE->mutex));
pthread_mutex_init(&(PRIVATE->mutex), &attr); pthread_mutex_init(&(PRIVATE->mutex), &attr);
pthread_mutexattr_destroy(&attr); pthread_mutexattr_destroy(&attr);