aboutsummaryrefslogtreecommitdiffstats
path: root/host/include/uhd/utils/math.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'host/include/uhd/utils/math.hpp')
-rw-r--r--host/include/uhd/utils/math.hpp12
1 files changed, 11 insertions, 1 deletions
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 <cmath>
#include <uhd/config.hpp>
#include <boost/cstdint.hpp>
#include <boost/numeric/conversion/bounds.hpp>
-
namespace uhd {
/*!
@@ -237,6 +237,16 @@ namespace fp_compare {
== fp_compare::fp_compare_delta<double>(rhs, FREQ_COMPARISON_DELTA_HZ));
}
+ //! Portable log2()
+ template <typename float_t> 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