From 188fbb17cfd18c87f60ec56f62476f97ef2779bb Mon Sep 17 00:00:00 2001 From: Martin Braun Date: Sat, 19 Jun 2021 00:06:52 +0200 Subject: uhd: Remove all occurences of boost::math::*round() Its behaviour is almost identical to std::lround, which we use instead. The only downside of std::lround is that it always returns a long, which we don't always need. We thus add some casts for those cases to make the compiler happy. --- host/lib/usrp/cores/dsp_core_utils.cpp | 4 ++-- host/lib/usrp/cores/rx_dsp_core_200.cpp | 5 ++--- host/lib/usrp/cores/rx_dsp_core_3000.cpp | 5 ++--- host/lib/usrp/cores/rx_frontend_core_200.cpp | 8 ++++---- host/lib/usrp/cores/rx_frontend_core_3000.cpp | 8 ++++---- host/lib/usrp/cores/tx_dsp_core_200.cpp | 5 ++--- host/lib/usrp/cores/tx_dsp_core_3000.cpp | 5 ++--- host/lib/usrp/cores/tx_frontend_core_200.cpp | 8 ++++---- 8 files changed, 22 insertions(+), 26 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 a96028d65..2e99cde4d 100644 --- a/host/lib/usrp/cores/dsp_core_utils.cpp +++ b/host/lib/usrp/cores/dsp_core_utils.cpp @@ -8,8 +8,8 @@ #include #include #include -#include #include +#include static const int32_t MAX_FREQ_WORD = boost::numeric::bounds::highest(); static const int32_t MIN_FREQ_WORD = boost::numeric::bounds::lowest(); @@ -47,7 +47,7 @@ void get_freq_and_freq_word(const double requested_freq, } else { /* The operation is safe. Perform normally. */ - freq_word = int32_t(boost::math::round((freq / tick_rate) * scale_factor)); + freq_word = int32_t(std::lround((freq / tick_rate) * scale_factor)); } actual_freq = (double(freq_word) / scale_factor) * tick_rate; diff --git a/host/lib/usrp/cores/rx_dsp_core_200.cpp b/host/lib/usrp/cores/rx_dsp_core_200.cpp index 5e2c3804f..f5d31a374 100644 --- a/host/lib/usrp/cores/rx_dsp_core_200.cpp +++ b/host/lib/usrp/cores/rx_dsp_core_200.cpp @@ -13,7 +13,6 @@ #include #include #include -#include #include #include #include @@ -186,7 +185,7 @@ public: double set_host_rate(const double rate) override { const size_t decim_rate = - boost::math::iround(_tick_rate / this->get_host_rates().clip(rate, true)); + std::lround(_tick_rate / this->get_host_rates().clip(rate, true)); size_t decim = decim_rate; // determine which half-band filters are activated @@ -229,7 +228,7 @@ public: const double factor = 1.0 + std::max(ceil_log2(_scaling_adjustment), 0.0); const double target_scalar = (1 << 17) * _scaling_adjustment / _dsp_extra_scaling / factor; - const int32_t actual_scalar = boost::math::iround(target_scalar); + const int32_t actual_scalar = static_cast(std::lround(target_scalar)); _fxpt_scalar_correction = target_scalar / actual_scalar * factor; // should be small _iface->poke32(REG_DSP_RX_SCALE_IQ, actual_scalar); diff --git a/host/lib/usrp/cores/rx_dsp_core_3000.cpp b/host/lib/usrp/cores/rx_dsp_core_3000.cpp index ff431fd41..9b7013cea 100644 --- a/host/lib/usrp/cores/rx_dsp_core_3000.cpp +++ b/host/lib/usrp/cores/rx_dsp_core_3000.cpp @@ -13,7 +13,6 @@ #include #include #include -#include #include #include #include @@ -136,7 +135,7 @@ public: double set_host_rate(const double rate) override { const size_t decim_rate = - boost::math::iround(_tick_rate / this->get_host_rates().clip(rate, true)); + std::lround(_tick_rate / this->get_host_rates().clip(rate, true)); size_t decim = decim_rate; // determine which half-band filters are activated @@ -228,7 +227,7 @@ public: { const double target_scalar = (1 << (_is_b200 ? 16 : 15)) * _scaling_adjustment / _dsp_extra_scaling; - const int32_t actual_scalar = boost::math::iround(target_scalar); + const int32_t actual_scalar = static_cast(std::lround(target_scalar)); // Calculate the error introduced by using integer representation for the scalar, // can be corrected in host later. _fxpt_scalar_correction = target_scalar / actual_scalar; diff --git a/host/lib/usrp/cores/rx_frontend_core_200.cpp b/host/lib/usrp/cores/rx_frontend_core_200.cpp index d96672da4..e9830e29f 100644 --- a/host/lib/usrp/cores/rx_frontend_core_200.cpp +++ b/host/lib/usrp/cores/rx_frontend_core_200.cpp @@ -7,7 +7,7 @@ #include #include -#include +#include #include using namespace uhd; @@ -29,7 +29,7 @@ static const double DC_OFFSET_MAX = 1.0; static uint32_t fs_to_bits(const double num, const size_t bits) { - return int32_t(boost::math::round(num * (1 << (bits - 1)))); + return int32_t(std::lround(num * (1 << (bits - 1)))); } rx_frontend_core_200::~rx_frontend_core_200(void) @@ -65,8 +65,8 @@ public: std::complex set_dc_offset(const std::complex& off) override { static const double scaler = double(1ul << 29); - _i_dc_off = boost::math::iround(off.real() * scaler); - _q_dc_off = boost::math::iround(off.imag() * scaler); + _i_dc_off = static_cast(std::lround(off.real() * scaler)); + _q_dc_off = static_cast(std::lround(off.imag() * scaler)); this->set_dc_offset(OFFSET_SET | OFFSET_FIXED); diff --git a/host/lib/usrp/cores/rx_frontend_core_3000.cpp b/host/lib/usrp/cores/rx_frontend_core_3000.cpp index abbe64b13..2424783e3 100644 --- a/host/lib/usrp/cores/rx_frontend_core_3000.cpp +++ b/host/lib/usrp/cores/rx_frontend_core_3000.cpp @@ -11,7 +11,7 @@ #include #include #include -#include +#include #include using namespace uhd; @@ -45,7 +45,7 @@ using namespace uhd::usrp; static uint32_t fs_to_bits(const double num, const size_t bits) { - return int32_t(boost::math::round(num * (1 << (bits - 1)))); + return int32_t(std::lround(num * (1 << (bits - 1)))); } rx_frontend_core_3000::~rx_frontend_core_3000(void) @@ -151,8 +151,8 @@ public: std::complex set_dc_offset(const std::complex& off) override { static const double scaler = double(1ul << 29); - _i_dc_off = boost::math::iround(off.real() * scaler); - _q_dc_off = boost::math::iround(off.imag() * scaler); + _i_dc_off = static_cast(std::lround(off.real() * scaler)); + _q_dc_off = static_cast(std::lround(off.imag() * scaler)); _set_dc_offset(OFFSET_SET | OFFSET_FIXED); diff --git a/host/lib/usrp/cores/tx_dsp_core_200.cpp b/host/lib/usrp/cores/tx_dsp_core_200.cpp index 1c743b0b0..e38938863 100644 --- a/host/lib/usrp/cores/tx_dsp_core_200.cpp +++ b/host/lib/usrp/cores/tx_dsp_core_200.cpp @@ -12,7 +12,6 @@ #include #include #include -#include #include #include #include @@ -118,7 +117,7 @@ public: double set_host_rate(const double rate) override { const size_t interp_rate = - boost::math::iround(_tick_rate / this->get_host_rates().clip(rate, true)); + std::lround(_tick_rate / this->get_host_rates().clip(rate, true)); size_t interp = interp_rate; // determine which half-band filters are activated @@ -159,7 +158,7 @@ public: const double factor = 1.0 + std::max(ceil_log2(_scaling_adjustment), 0.0); const double target_scalar = (1 << 17) * _scaling_adjustment / _dsp_extra_scaling / factor; - const int32_t actual_scalar = boost::math::iround(target_scalar); + const int32_t actual_scalar = static_cast(std::lround(target_scalar)); _fxpt_scalar_correction = target_scalar / actual_scalar * factor; // should be small _iface->poke32(REG_DSP_TX_SCALE_IQ, actual_scalar); diff --git a/host/lib/usrp/cores/tx_dsp_core_3000.cpp b/host/lib/usrp/cores/tx_dsp_core_3000.cpp index f46938de3..b7f5614a7 100644 --- a/host/lib/usrp/cores/tx_dsp_core_3000.cpp +++ b/host/lib/usrp/cores/tx_dsp_core_3000.cpp @@ -12,7 +12,6 @@ #include #include #include -#include #include #include #include @@ -76,7 +75,7 @@ public: double set_host_rate(const double rate) override { const size_t interp_rate = - boost::math::iround(_tick_rate / this->get_host_rates().clip(rate, true)); + std::lround(_tick_rate / this->get_host_rates().clip(rate, true)); size_t interp = interp_rate; // determine which half-band filters are activated @@ -123,7 +122,7 @@ public: void update_scalar(void) { const double target_scalar = (1 << 16) * _scaling_adjustment / _dsp_extra_scaling; - const int32_t actual_scalar = boost::math::iround(target_scalar); + const int32_t actual_scalar = static_cast(std::lround(target_scalar)); _fxpt_scalar_correction = target_scalar / actual_scalar; // should be small _iface->poke32(REG_DSP_TX_SCALE_IQ, actual_scalar); } diff --git a/host/lib/usrp/cores/tx_frontend_core_200.cpp b/host/lib/usrp/cores/tx_frontend_core_200.cpp index 45b2045dd..000f47977 100644 --- a/host/lib/usrp/cores/tx_frontend_core_200.cpp +++ b/host/lib/usrp/cores/tx_frontend_core_200.cpp @@ -10,7 +10,7 @@ #include #include #include -#include +#include #include using namespace uhd; @@ -33,7 +33,7 @@ static const double DC_OFFSET_MAX = 1.0; static uint32_t fs_to_bits(const double num, const size_t bits) { - return int32_t(boost::math::round(num * (1 << (bits - 1)))); + return int32_t(std::lround(num * (1 << (bits - 1)))); } tx_frontend_core_200::~tx_frontend_core_200(void) @@ -66,8 +66,8 @@ public: std::complex set_dc_offset(const std::complex& off) override { static const double scaler = double(1ul << 23); - const int32_t i_dc_off = boost::math::iround(off.real() * scaler); - const int32_t q_dc_off = boost::math::iround(off.imag() * scaler); + const int32_t i_dc_off = static_cast(std::lround(off.real() * scaler)); + const int32_t q_dc_off = static_cast(std::lround(off.imag() * scaler)); _iface->poke32(REG_TX_FE_DC_OFFSET_I, i_dc_off); _iface->poke32(REG_TX_FE_DC_OFFSET_Q, q_dc_off); -- cgit v1.2.3