From 5ee6b828debbd60e03aff805bfd80e2030715a6f Mon Sep 17 00:00:00 2001 From: Martin Braun Date: Tue, 31 Aug 2021 11:49:51 +0200 Subject: uhd: math: Replace wrap-frequency math with a single function In multiple places in the UHD code, we were doing the same calculation for a wrapped frequency (wrap it into the first Nyquist zone). This math was using boost::math, too. Instead of editing every instance, we create a new function, uhd::math::wrap_frequency(), and replace all of its separate implementations with this function. The new function also no longer relies on boost::math::sign. --- host/lib/usrp/cores/dsp_core_utils.cpp | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'host/lib/usrp/cores') diff --git a/host/lib/usrp/cores/dsp_core_utils.cpp b/host/lib/usrp/cores/dsp_core_utils.cpp index 84331fcec..868e47234 100644 --- a/host/lib/usrp/cores/dsp_core_utils.cpp +++ b/host/lib/usrp/cores/dsp_core_utils.cpp @@ -8,7 +8,6 @@ #include #include #include -#include #include #include @@ -20,10 +19,7 @@ void get_freq_and_freq_word(const double requested_freq, double& actual_freq, int32_t& freq_word) { - // correct for outside of rate (wrap around) - double freq = std::fmod(requested_freq, tick_rate); - if (std::abs(freq) > tick_rate / 2.0) - freq -= boost::math::sign(freq) * tick_rate; + const double freq = uhd::math::wrap_frequency(requested_freq, tick_rate); // confirm that the target frequency is within range of the CORDIC UHD_ASSERT_THROW(std::abs(freq) <= tick_rate / 2.0); -- cgit v1.2.3