diff options
author | Martin Braun <martin.braun@ettus.com> | 2018-01-22 09:54:46 -0800 |
---|---|---|
committer | Martin Braun <martin.braun@ettus.com> | 2018-02-19 14:51:47 -0800 |
commit | 74f45ae2a723107adce1038a708d2958aca97487 (patch) | |
tree | a87139dfef5c863a71f3e4e832c2de3e914b5831 /host/lib/rfnoc/duc_block_ctrl_impl.cpp | |
parent | eff796f64b1e05036b7eca2185f53528a0de870b (diff) | |
download | uhd-74f45ae2a723107adce1038a708d2958aca97487.tar.gz uhd-74f45ae2a723107adce1038a708d2958aca97487.tar.bz2 uhd-74f45ae2a723107adce1038a708d2958aca97487.zip |
rfnoc: Factor out ceil_log2() into central location
- New file: uhdlib/utils/math.hpp
Diffstat (limited to 'host/lib/rfnoc/duc_block_ctrl_impl.cpp')
-rw-r--r-- | host/lib/rfnoc/duc_block_ctrl_impl.cpp | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/host/lib/rfnoc/duc_block_ctrl_impl.cpp b/host/lib/rfnoc/duc_block_ctrl_impl.cpp index 0e1521d9f..c8989d65c 100644 --- a/host/lib/rfnoc/duc_block_ctrl_impl.cpp +++ b/host/lib/rfnoc/duc_block_ctrl_impl.cpp @@ -9,18 +9,14 @@ #include <uhd/utils/log.hpp> #include <uhd/convert.hpp> #include <uhd/types/ranges.hpp> -#include <uhdlib/utils/narrow.hpp> #include <uhdlib/utils/compat_check.hpp> +#include <uhdlib/utils/math.hpp> +#include <uhdlib/utils/narrow.hpp> #include <boost/math/special_functions/round.hpp> #include <cmath> using namespace uhd::rfnoc; -// TODO move this to a central location -template <class T> T ceil_log2(T num){ - return std::ceil(std::log(num)/std::log(T(2))); -} - // TODO remove this once we have actual lambdas static double lambda_forward_prop(uhd::property_tree::sptr tree, uhd::fs_path prop, double value) { @@ -250,7 +246,8 @@ private: // This must also encompass the CORDIC gain static const double CONSTANT_GAIN = 1.1644; - const double scaling_adjustment = std::pow(2, ceil_log2(rate_pow))/(CONSTANT_GAIN*rate_pow); + const double scaling_adjustment = + std::pow(2, uhd::math::ceil_log2(rate_pow))/(CONSTANT_GAIN*rate_pow); update_scalar(scaling_adjustment, chan); return output_rate/interp_rate; } |