From 27aa985f450a7d2312f8731991d4e4e9ec122e8d Mon Sep 17 00:00:00 2001 From: Martin Braun Date: Thu, 23 Oct 2014 18:07:07 +0200 Subject: math: Added a portable log2() --- host/include/uhd/utils/math.hpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'host/include') diff --git a/host/include/uhd/utils/math.hpp b/host/include/uhd/utils/math.hpp index 21825c3dc..a41a35d67 100644 --- a/host/include/uhd/utils/math.hpp +++ b/host/include/uhd/utils/math.hpp @@ -18,11 +18,11 @@ #ifndef INCLUDED_UHD_UTILS_MATH_HPP #define INCLUDED_UHD_UTILS_MATH_HPP +#include #include #include #include - namespace uhd { /*! @@ -237,6 +237,16 @@ namespace fp_compare { == fp_compare::fp_compare_delta(rhs, FREQ_COMPARISON_DELTA_HZ)); } + //! Portable log2() + template UHD_INLINE + float_t log2(float_t x) + { + // C++11 defines std::log2(), when that's universally supported + // we can switch over. + return std::log(x) / std::log(2); + } + + } // namespace math } // namespace uhd -- cgit v1.2.3