diff options
author | Michael Dickens <mlk@alum.mit.edu> | 2018-12-06 13:17:06 -0500 |
---|---|---|
committer | Brent Stapleton <brent.stapleton@ettus.com> | 2018-12-12 19:23:21 -0800 |
commit | eac84f1b7f3b652bc46a1370c8f68aa5b2477330 (patch) | |
tree | eff83a226bcec0d0725cd238d9f76826060f7916 /host/include | |
parent | 865151108279e1b3cb25d288335d76dc3eef7e4e (diff) | |
download | uhd-eac84f1b7f3b652bc46a1370c8f68aa5b2477330.tar.gz uhd-eac84f1b7f3b652bc46a1370c8f68aa5b2477330.tar.bz2 uhd-eac84f1b7f3b652bc46a1370c8f68aa5b2477330.zip |
various: use "std::abs" instead of "std::fabs"
+ better compiler compatibility
+ let the compiler figure out the actual function IO signature that
makes sense, instead of forcing float.
Diffstat (limited to 'host/include')
-rw-r--r-- | host/include/uhd/utils/fp_compare_delta.ipp | 6 | ||||
-rw-r--r-- | host/include/uhd/utils/fp_compare_epsilon.ipp | 12 |
2 files changed, 9 insertions, 9 deletions
diff --git a/host/include/uhd/utils/fp_compare_delta.ipp b/host/include/uhd/utils/fp_compare_delta.ipp index 95288c3ba..a9734c8c1 100644 --- a/host/include/uhd/utils/fp_compare_delta.ipp +++ b/host/include/uhd/utils/fp_compare_delta.ipp @@ -58,7 +58,7 @@ namespace uhd { namespace math { namespace fp_compare { template<typename float_t> UHD_INLINE bool operator==(fp_compare_delta<float_t> lhs, fp_compare_delta<float_t> rhs) { float_t delta = fp_compare_select_delta(lhs._delta, rhs._delta); - return (std::fabs(lhs._value - rhs._value) < delta); + return (std::abs(lhs._value - rhs._value) < delta); } template<typename float_t> UHD_INLINE @@ -92,7 +92,7 @@ namespace uhd { namespace math { namespace fp_compare { bool operator==(fp_compare_delta<float_t> lhs, double rhs) { float_t delta = float_t(fp_compare_select_delta(double(lhs._delta), DOUBLE_PRECISION_DELTA)); - return (std::fabs(lhs._value - rhs) < delta); + return (std::abs(lhs._value - rhs) < delta); } template<typename float_t> UHD_INLINE @@ -128,7 +128,7 @@ namespace uhd { namespace math { namespace fp_compare { bool operator==(double lhs, fp_compare_delta<float_t> rhs) { float_t delta = fp_compare_select_delta(DOUBLE_PRECISION_DELTA, double(rhs._delta)); - return (std::fabs(lhs - rhs._value) < delta); + return (std::abs(lhs - rhs._value) < delta); } template<typename float_t> UHD_INLINE diff --git a/host/include/uhd/utils/fp_compare_epsilon.ipp b/host/include/uhd/utils/fp_compare_epsilon.ipp index 0fa98de09..bbd702512 100644 --- a/host/include/uhd/utils/fp_compare_epsilon.ipp +++ b/host/include/uhd/utils/fp_compare_epsilon.ipp @@ -53,9 +53,9 @@ namespace uhd { namespace math { namespace fp_compare { template<typename float_t> UHD_INLINE bool operator==(fp_compare_epsilon<float_t> lhs, fp_compare_epsilon<float_t> rhs) { - bool lhs_compare = ((std::fabs(lhs._value - rhs._value) / std::fabs(lhs._value)) + bool lhs_compare = ((std::abs(lhs._value - rhs._value) / std::abs(lhs._value)) <= lhs._epsilon); - bool rhs_compare = ((std::fabs(lhs._value - rhs._value) / std::fabs(rhs._value)) + bool rhs_compare = ((std::abs(lhs._value - rhs._value) / std::abs(rhs._value)) <= rhs._epsilon); return (lhs_compare && rhs_compare); @@ -89,9 +89,9 @@ namespace uhd { namespace math { namespace fp_compare { template<typename float_t> UHD_INLINE bool operator==(fp_compare_epsilon<float_t> lhs, double rhs) { - bool lhs_compare = ((std::fabs(lhs._value - rhs) / std::fabs(lhs._value)) + bool lhs_compare = ((std::abs(lhs._value - rhs) / std::abs(lhs._value)) <= lhs._epsilon); - bool rhs_compare = ((std::fabs(lhs._value - rhs) / std::fabs(rhs)) + bool rhs_compare = ((std::abs(lhs._value - rhs) / std::abs(rhs)) <= DOUBLE_PRECISION_EPSILON); return (lhs_compare && rhs_compare); @@ -127,9 +127,9 @@ namespace uhd { namespace math { namespace fp_compare { template<typename float_t> UHD_INLINE bool operator==(double lhs, fp_compare_epsilon<float_t> rhs) { - bool lhs_compare = ((std::fabs(lhs - rhs._value) / std::fabs(lhs)) + bool lhs_compare = ((std::abs(lhs - rhs._value) / std::abs(lhs)) <= DOUBLE_PRECISION_EPSILON); - bool rhs_compare = ((std::fabs(lhs - rhs._value) / std::fabs(rhs._value)) + bool rhs_compare = ((std::abs(lhs - rhs._value) / std::abs(rhs._value)) <= rhs._epsilon); return (lhs_compare && rhs_compare); |