diff options
Diffstat (limited to 'host/lib')
32 files changed, 104 insertions, 101 deletions
| diff --git a/host/lib/convert/convert_with_tables.cpp b/host/lib/convert/convert_with_tables.cpp index 3df510092..3443e02c7 100644 --- a/host/lib/convert/convert_with_tables.cpp +++ b/host/lib/convert/convert_with_tables.cpp @@ -7,7 +7,7 @@  #include "convert_common.hpp"  #include <uhd/utils/byteswap.hpp> -#include <boost/math/special_functions/round.hpp> +#include <cmath>  #include <vector>  using namespace uhd::convert; @@ -30,7 +30,7 @@ public:      {          for (size_t i = 0; i < sc16_table_len; i++) {              const int16_t val = uint16_t(i); -            _table[i]         = int8_t(boost::math::iround(val * scalar / 32767.)); +            _table[i]         = int8_t(std::lround(val * scalar / 32767.));          }      } @@ -120,7 +120,7 @@ public:      static type conv(const int8_t& num, const double scalar)      {          if (sizeof(type) == sizeof(s16_t)) { -            return type(boost::math::iround(num * scalar * 32767)); +            return type(std::lround(num * scalar * 32767));          }          return type(num * scalar);      } diff --git a/host/lib/include/uhdlib/usrp/common/max287x.hpp b/host/lib/include/uhdlib/usrp/common/max287x.hpp index 8aa7e947e..de3db9b4b 100644 --- a/host/lib/include/uhdlib/usrp/common/max287x.hpp +++ b/host/lib/include/uhdlib/usrp/common/max287x.hpp @@ -18,8 +18,8 @@  #include <uhd/utils/safe_call.hpp>  #include <stdint.h>  #include <boost/assign.hpp> -#include <boost/math/special_functions/round.hpp>  #include <chrono> +#include <cmath>  #include <functional>  #include <thread>  #include <vector> @@ -584,7 +584,7 @@ double max287x<max287x_regs_t>::set_frequency(          N = int((vco_freq / pfd_freq) / fb_divisor);          // Fractional-N calculation -        FRAC = int(boost::math::round(((vco_freq / pfd_freq) / fb_divisor - N) * MOD)); +        FRAC = int(std::lround(((vco_freq / pfd_freq) / fb_divisor - N) * MOD));          if (is_int_n) {              if (FRAC diff --git a/host/lib/rfnoc/ddc_block_control.cpp b/host/lib/rfnoc/ddc_block_control.cpp index 91c53a5e9..3326d4e46 100644 --- a/host/lib/rfnoc/ddc_block_control.cpp +++ b/host/lib/rfnoc/ddc_block_control.cpp @@ -16,7 +16,7 @@  #include <uhdlib/usrp/cores/dsp_core_utils.hpp>  #include <uhdlib/utils/compat_check.hpp>  #include <uhdlib/utils/math.hpp> -#include <boost/math/special_functions/round.hpp> +#include <cmath>  #include <set>  #include <string> @@ -520,7 +520,7 @@ private:          const double compensation_factor  = 1. / dsp_gain;          // Convert to fixpoint          const double target_factor  = FIXPOINT_SCALING * compensation_factor; -        const int32_t actual_factor = boost::math::iround(target_factor); +        const int32_t actual_factor = std::lround(target_factor);          // Write DDC with scaling correction for CIC and DDS that maximizes          // dynamic range          _ddc_reg_iface.poke32(SR_SCALE_IQ_ADDR, actual_factor, chan); diff --git a/host/lib/rfnoc/duc_block_control.cpp b/host/lib/rfnoc/duc_block_control.cpp index 87f6500a2..12937ac21 100644 --- a/host/lib/rfnoc/duc_block_control.cpp +++ b/host/lib/rfnoc/duc_block_control.cpp @@ -16,7 +16,7 @@  #include <uhdlib/usrp/cores/dsp_core_utils.hpp>  #include <uhdlib/utils/compat_check.hpp>  #include <uhdlib/utils/math.hpp> -#include <boost/math/special_functions/round.hpp> +#include <cmath>  #include <set>  #include <string> @@ -504,7 +504,7 @@ private:          const double compensation_factor  = 1. / dsp_gain;          // Convert to fixpoint          const double target_factor  = FIXPOINT_SCALING * compensation_factor; -        const int32_t actual_factor = boost::math::iround(target_factor); +        const int32_t actual_factor = static_cast<int32_t>(std::lround(target_factor));          // Write DUC with scaling correction for CIC and DDS that maximizes          // dynamic range          _duc_reg_iface.poke32(SR_SCALE_IQ_ADDR, actual_factor, chan); diff --git a/host/lib/types/ranges.cpp b/host/lib/types/ranges.cpp index f7fbc0f92..16edeccca 100644 --- a/host/lib/types/ranges.cpp +++ b/host/lib/types/ranges.cpp @@ -7,8 +7,8 @@  #include <uhd/exception.hpp>  #include <uhd/types/ranges.hpp> -#include <boost/math/special_functions/round.hpp>  #include <algorithm> +#include <cmath>  #include <sstream>  using namespace uhd; @@ -148,8 +148,7 @@ double meta_range_t::clip(double value, bool clip_step) const          if (value <= r.stop()) {              if (not clip_step or r.step() == 0)                  return value; -            return boost::math::round((value - r.start()) / r.step()) * r.step() -                   + r.start(); +            return std::round((value - r.start()) / r.step()) * r.step() + r.start();          }          // continue on to the next range          last_stop = r.stop(); diff --git a/host/lib/usrp/b100/codec_ctrl.cpp b/host/lib/usrp/b100/codec_ctrl.cpp index fad25cf8c..4b9f0e62b 100644 --- a/host/lib/usrp/b100/codec_ctrl.cpp +++ b/host/lib/usrp/b100/codec_ctrl.cpp @@ -13,9 +13,10 @@  #include <uhd/utils/algorithm.hpp>  #include <uhd/utils/log.hpp>  #include <uhd/utils/safe_call.hpp> -#include <stdint.h> +#include <uhdlib/utils/narrow.hpp> +#include <cstdint>  #include <boost/assign/list_of.hpp> -#include <boost/math/special_functions/round.hpp> +#include <cmath>  #include <tuple>  using namespace uhd; @@ -241,7 +242,8 @@ void b100_codec_ctrl_impl::write_aux_dac(aux_dac_t which, double volts)  {      // special case for aux dac d (aka sigma delta word)      if (which == AUX_DAC_D) { -        uint16_t dac_word = uhd::clip(boost::math::iround(volts * 0xfff / 3.3), 0, 0xfff); +        uint16_t dac_word = +            uhd::clip(uhd::narrow_cast<int>(std::lround(volts * 0xfff / 3.3)), 0, 0xfff);          _ad9862_regs.sig_delt_11_4 = uint8_t(dac_word >> 4);          _ad9862_regs.sig_delt_3_0  = uint8_t(dac_word & 0xf);          this->send_reg(42); @@ -250,7 +252,8 @@ void b100_codec_ctrl_impl::write_aux_dac(aux_dac_t which, double volts)      }      // calculate the dac word for aux dac a, b, c -    uint8_t dac_word = uhd::clip(boost::math::iround(volts * 0xff / 3.3), 0, 0xff); +    uint8_t dac_word = +        uhd::clip(uhd::narrow_cast<int>(std::lround(volts * 0xff / 3.3)), 0, 0xff);      // setup a lookup table for the aux dac params (reg ref, reg addr)      typedef std::tuple<uint8_t*, uint8_t> dac_params_t; diff --git a/host/lib/usrp/common/ad9361_driver/ad9361_device.cpp b/host/lib/usrp/common/ad9361_driver/ad9361_device.cpp index 9e088871d..9275c83f5 100644 --- a/host/lib/usrp/common/ad9361_driver/ad9361_device.cpp +++ b/host/lib/usrp/common/ad9361_driver/ad9361_device.cpp @@ -5,17 +5,16 @@  // SPDX-License-Identifier: GPL-3.0-or-later  // +#define _USE_MATH_DEFINES  #include "ad9361_device.h"  #include "ad9361_client.h"  #include "ad9361_filter_taps.h"  #include "ad9361_gain_tables.h"  #include "ad9361_synth_lut.h" -#define _USE_MATH_DEFINES  #include <uhd/exception.hpp>  #include <uhd/utils/log.hpp>  #include <stdint.h>  #include <boost/format.hpp> -#include <boost/math/special_functions.hpp>  #include <boost/scoped_array.hpp>  #include <chrono>  #include <cmath> @@ -1237,7 +1236,7 @@ double ad9361_device_t::_tune_bbvco(const double rate)      int nint = static_cast<int>(vcorate / fref);      UHD_LOG_TRACE("AD936X", "[ad9361_device_t::_tune_bbvco] (nint)=" << (vcorate / fref));      int nfrac = static_cast<int>( -        boost::math::round(((vcorate / fref) - (double)nint) * (double)modulus)); +        std::lround(((vcorate / fref) - (double)nint) * (double)modulus));      UHD_LOG_TRACE("AD936X",          "[ad9361_device_t::_tune_bbvco] (nfrac)=" << ((vcorate / fref) - (double)nint)                                                           * (double)modulus); 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 <uhd/exception.hpp>  #include <uhd/utils/math.hpp>  #include <uhdlib/usrp/cores/dsp_core_utils.hpp> -#include <boost/math/special_functions/round.hpp>  #include <boost/math/special_functions/sign.hpp> +#include <cmath>  static const int32_t MAX_FREQ_WORD = boost::numeric::bounds<int32_t>::highest();  static const int32_t MIN_FREQ_WORD = boost::numeric::bounds<int32_t>::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 <uhdlib/usrp/cores/dsp_core_utils.hpp>  #include <uhdlib/usrp/cores/rx_dsp_core_200.hpp>  #include <boost/assign/list_of.hpp> -#include <boost/math/special_functions/round.hpp>  #include <boost/numeric/conversion/bounds.hpp>  #include <algorithm>  #include <chrono> @@ -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<int32_t>(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 <uhdlib/usrp/cores/dsp_core_utils.hpp>  #include <uhdlib/usrp/cores/rx_dsp_core_3000.hpp>  #include <boost/assign/list_of.hpp> -#include <boost/math/special_functions/round.hpp>  #include <algorithm>  #include <cmath>  #include <functional> @@ -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<int32_t>(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 <uhd/types/ranges.hpp>  #include <uhdlib/usrp/cores/rx_frontend_core_200.hpp> -#include <boost/math/special_functions/round.hpp> +#include <cmath>  #include <functional>  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<double> set_dc_offset(const std::complex<double>& 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<int32_t>(std::lround(off.real() * scaler)); +        _q_dc_off = static_cast<int32_t>(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 <uhdlib/usrp/cores/dsp_core_utils.hpp>  #include <uhdlib/usrp/cores/rx_frontend_core_3000.hpp>  #include <boost/assign/list_of.hpp> -#include <boost/math/special_functions/round.hpp> +#include <cmath>  #include <functional>  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<double> set_dc_offset(const std::complex<double>& 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<int32_t>(std::lround(off.real() * scaler)); +        _q_dc_off = static_cast<int32_t>(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 <uhdlib/usrp/cores/dsp_core_utils.hpp>  #include <uhdlib/usrp/cores/tx_dsp_core_200.hpp>  #include <boost/assign/list_of.hpp> -#include <boost/math/special_functions/round.hpp>  #include <algorithm>  #include <chrono>  #include <cmath> @@ -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<int32_t>(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 <uhdlib/usrp/cores/dsp_core_utils.hpp>  #include <uhdlib/usrp/cores/tx_dsp_core_3000.hpp>  #include <boost/assign/list_of.hpp> -#include <boost/math/special_functions/round.hpp>  #include <algorithm>  #include <cmath>  #include <functional> @@ -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<int32_t>(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 <uhd/types/ranges.hpp>  #include <uhdlib/usrp/cores/tx_frontend_core_200.hpp>  #include <boost/assign/list_of.hpp> -#include <boost/math/special_functions/round.hpp> +#include <cmath>  #include <functional>  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<double> set_dc_offset(const std::complex<double>& 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<int>(std::lround(off.real() * scaler)); +        const int32_t q_dc_off     = static_cast<int>(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); diff --git a/host/lib/usrp/dboard/db_dbsrx.cpp b/host/lib/usrp/dboard/db_dbsrx.cpp index a55e5fc70..09690a3d1 100644 --- a/host/lib/usrp/dboard/db_dbsrx.cpp +++ b/host/lib/usrp/dboard/db_dbsrx.cpp @@ -21,7 +21,6 @@  #include <uhd/utils/static.hpp>  #include <boost/assign/list_of.hpp>  #include <boost/format.hpp> -#include <boost/math/special_functions/round.hpp>  #include <chrono>  #include <cmath>  #include <functional> @@ -491,11 +490,11 @@ static int gain_to_gc2_vga_reg(double& gain)      // Half dB steps from 0-5dB, 1dB steps from 5-24dB      if (gain < 5) { -        reg  = boost::math::iround(31.0 - gain / 0.5); -        gain = double(boost::math::iround(gain) * 0.5); +        reg  = static_cast<int>(std::lround(31.0 - gain / 0.5)); +        gain = std::round(gain) * 0.5;      } else { -        reg  = boost::math::iround(22.0 - (gain - 4.0)); -        gain = double(boost::math::iround(gain)); +        reg  = static_cast<int>(std::lround(22.0 - (gain - 4.0))); +        gain = std::round(gain);      }      UHD_LOGGER_TRACE("DBSRX") << boost::format("DBSRX GC2 Gain: %f dB, reg: %d") % gain diff --git a/host/lib/usrp/dboard/db_dbsrx2.cpp b/host/lib/usrp/dboard/db_dbsrx2.cpp index 7635327b1..16a418417 100644 --- a/host/lib/usrp/dboard/db_dbsrx2.cpp +++ b/host/lib/usrp/dboard/db_dbsrx2.cpp @@ -19,8 +19,8 @@  #include <uhd/utils/static.hpp>  #include <boost/assign/list_of.hpp>  #include <boost/format.hpp> -#include <boost/math/special_functions/round.hpp>  #include <boost/thread.hpp> +#include <cmath>  #include <functional>  #include <utility> @@ -258,7 +258,7 @@ double dbsrx2::set_lo_freq(double target_freq)      N       = (target_freq * R * ext_div) / (ref_freq); // actual spec range is (19, 251)      intdiv  = int(std::floor(N)); //  if (intdiv < 19  or intdiv > 251) continue; -    fracdiv = boost::math::iround((N - intdiv) * double(1 << 20)); +    fracdiv = static_cast<int>(std::lround((N - intdiv) * double(1 << 20)));      // calculate the actual freq from the values above      N        = double(intdiv) + double(fracdiv) / double(1 << 20); @@ -305,7 +305,7 @@ double dbsrx2::set_lo_freq(double target_freq)   */  static int gain_to_bbg_vga_reg(double& gain)  { -    int reg = boost::math::iround(dbsrx2_gain_ranges["BBG"].clip(gain)); +    int reg = static_cast<int>(std::lround(dbsrx2_gain_ranges["BBG"].clip(gain)));      gain = double(reg); diff --git a/host/lib/usrp/dboard/db_rfx.cpp b/host/lib/usrp/dboard/db_rfx.cpp index f4de7ccaa..ff26c2d29 100644 --- a/host/lib/usrp/dboard/db_rfx.cpp +++ b/host/lib/usrp/dboard/db_rfx.cpp @@ -35,7 +35,7 @@  #include <uhd/utils/static.hpp>  #include <boost/assign/list_of.hpp>  #include <boost/format.hpp> -#include <boost/math/special_functions/round.hpp> +#include <cmath>  #include <functional>  using namespace uhd; @@ -441,7 +441,7 @@ double rfx_xcvr::set_lo_freq(dboard_iface::unit_t unit, double target_freq)                  // calculate B and A from N                  double N = target_freq * R / ref_freq;                  B        = int(std::floor(N / P)); -                A        = boost::math::iround(N - P * B); +                A        = static_cast<int>(std::lround(N - P * B));                  if (B < A or B > 8191 or B < 3 or A > 31) {                      continue; // constraints on A, B                  } diff --git a/host/lib/usrp/dboard/db_tvrx2.cpp b/host/lib/usrp/dboard/db_tvrx2.cpp index cc1249dee..6f7581953 100644 --- a/host/lib/usrp/dboard/db_tvrx2.cpp +++ b/host/lib/usrp/dboard/db_tvrx2.cpp @@ -54,9 +54,10 @@  #include <uhd/usrp/dboard_base.hpp>  #include <uhd/usrp/dboard_manager.hpp>  #include <boost/assign/list_of.hpp> +#include <uhdlib/utils/narrow.hpp>  #include <boost/format.hpp>  #include <boost/array.hpp> -#include <boost/math/special_functions/round.hpp> +#include <cmath>  #include <utility>  #include <cmath>  #include <chrono> @@ -1966,7 +1967,8 @@ double tvrx2::set_gain(double gain, const std::string& name)   **********************************************************************/  static tda18272hnm_regs_t::lp_fc_t bandwidth_to_lp_fc_reg(double& bandwidth)  { -    int reg = uhd::clip(boost::math::iround((bandwidth - 5.0e6) / 1.0e6), 0, 4); +    int reg = +        uhd::clip(uhd::narrow_cast<int>(std::lround((bandwidth - 5.0e6)) / 1.0e6), 0, 4);      switch (reg) {          case 0: diff --git a/host/lib/usrp/dboard/db_wbx_common.cpp b/host/lib/usrp/dboard/db_wbx_common.cpp index df89e3779..6e306f36b 100644 --- a/host/lib/usrp/dboard/db_wbx_common.cpp +++ b/host/lib/usrp/dboard/db_wbx_common.cpp @@ -12,6 +12,7 @@  #include <uhd/utils/algorithm.hpp>  #include <uhd/utils/assert_has.hpp>  #include <uhd/utils/log.hpp> +#include <cmath>  #include <functional>  using namespace uhd; @@ -31,7 +32,7 @@ static int rx_pga0_gain_to_iobits(double& gain)      double attn = wbx_rx_gain_ranges["PGA0"].stop() - gain;      // calculate the attenuation -    int attn_code = boost::math::iround(attn * 2); +    int attn_code = static_cast<int>(std::lround(attn * 2));      int iobits    = ((~attn_code) << RX_ATTN_SHIFT) & RX_ATTN_MASK;      UHD_LOGGER_TRACE("WBX") diff --git a/host/lib/usrp/dboard/db_wbx_version3.cpp b/host/lib/usrp/dboard/db_wbx_version3.cpp index 51902b3aa..599119899 100644 --- a/host/lib/usrp/dboard/db_wbx_version3.cpp +++ b/host/lib/usrp/dboard/db_wbx_version3.cpp @@ -16,7 +16,7 @@  #include <boost/algorithm/string.hpp>  #include <boost/assign/list_of.hpp>  #include <boost/format.hpp> -#include <boost/math/special_functions/round.hpp> +#include <cmath>  #include <functional>  using namespace uhd; @@ -44,7 +44,7 @@ static int tx_pga0_gain_to_iobits(double& gain)      double attn = wbx_v3_tx_gain_ranges["PGA0"].stop() - gain;      // calculate the attenuation -    int attn_code = boost::math::iround(attn); +    int attn_code = static_cast<int>(std::lround(attn));      int iobits    = ((attn_code & 16 ? 0 : TX_ATTN_16) | (attn_code & 8 ? 0 : TX_ATTN_8)                       | (attn_code & 4 ? 0 : TX_ATTN_4) | (attn_code & 2 ? 0 : TX_ATTN_2)                       | (attn_code & 1 ? 0 : TX_ATTN_1)) diff --git a/host/lib/usrp/dboard/db_wbx_version4.cpp b/host/lib/usrp/dboard/db_wbx_version4.cpp index 54c0a9c21..cc278dd0b 100644 --- a/host/lib/usrp/dboard/db_wbx_version4.cpp +++ b/host/lib/usrp/dboard/db_wbx_version4.cpp @@ -16,7 +16,7 @@  #include <boost/algorithm/string.hpp>  #include <boost/assign/list_of.hpp>  #include <boost/format.hpp> -#include <boost/math/special_functions/round.hpp> +#include <cmath>  #include <functional>  using namespace uhd; @@ -45,7 +45,7 @@ static int tx_pga0_gain_to_iobits(double& gain)      double attn = wbx_v4_tx_gain_ranges["PGA0"].stop() - gain;      // calculate the attenuation -    int attn_code = boost::math::iround(attn); +    int attn_code = static_cast<int>(std::lround(attn));      int iobits    = ((attn_code & 16 ? 0 : TX_ATTN_16) | (attn_code & 8 ? 0 : TX_ATTN_8)                       | (attn_code & 4 ? 0 : TX_ATTN_4) | (attn_code & 2 ? 0 : TX_ATTN_2)                       | (attn_code & 1 ? 0 : TX_ATTN_1)) diff --git a/host/lib/usrp/dboard/db_xcvr2450.cpp b/host/lib/usrp/dboard/db_xcvr2450.cpp index 26c0d5950..b6b8858e7 100644 --- a/host/lib/usrp/dboard/db_xcvr2450.cpp +++ b/host/lib/usrp/dboard/db_xcvr2450.cpp @@ -50,10 +50,11 @@  #include <uhd/utils/log.hpp>  #include <uhd/utils/safe_call.hpp>  #include <uhd/utils/static.hpp> +#include <uhdlib/utils/narrow.hpp>  #include <boost/assign/list_of.hpp>  #include <boost/format.hpp> -#include <boost/math/special_functions/round.hpp>  #include <chrono> +#include <cmath>  #include <functional>  #include <thread>  #include <utility> @@ -410,7 +411,7 @@ double xcvr2450::set_lo_freq_core(double target_freq)          for (R = 1; R <= 7; R++) {              double N = (target_freq * scaler * R * _ad9515div) / ref_freq;              intdiv   = int(std::floor(N)); -            fracdiv  = boost::math::iround((N - intdiv) * double(1 << 16)); +            fracdiv  = uhd::narrow_cast<int>(std::lround((N - intdiv)) * double(1 << 16));              // actual minimum is 128, but most chips seems to require higher to lock              if (intdiv < 131 or intdiv > 255)                  continue; @@ -504,7 +505,7 @@ void xcvr2450::set_rx_ant(const std::string& ant)  static int gain_to_tx_vga_reg(double& gain)  {      // calculate the register value -    int reg = uhd::clip(boost::math::iround(gain * 60 / 30.0) + 3, 0, 63); +    int reg = uhd::clip(uhd::narrow_cast<int>(std::lround(gain * 60 / 30.0) + 3), 0, 63);      // calculate the actual gain value      if (reg < 4) @@ -526,7 +527,7 @@ static int gain_to_tx_vga_reg(double& gain)   */  static max2829_regs_t::tx_baseband_gain_t gain_to_tx_bb_reg(double& gain)  { -    int reg = uhd::clip(boost::math::iround(gain * 3 / 5.0), 0, 3); +    int reg = uhd::clip(uhd::narrow_cast<int>(std::lround<int>(gain * 3 / 5.0)), 0, 3);      switch (reg) {          case 0:              gain = 0; @@ -552,7 +553,7 @@ static max2829_regs_t::tx_baseband_gain_t gain_to_tx_bb_reg(double& gain)   */  static int gain_to_rx_vga_reg(double& gain)  { -    int reg = uhd::clip(boost::math::iround(gain / 2.0), 0, 31); +    int reg = uhd::clip(uhd::narrow_cast<int>(std::lround(gain / 2.0)), 0, 31);      gain    = double(reg * 2);      return reg;  } @@ -565,7 +566,7 @@ static int gain_to_rx_vga_reg(double& gain)   */  static int gain_to_rx_lna_reg(double& gain)  { -    int reg = uhd::clip(boost::math::iround(gain * 2 / 30.5) + 1, 0, 3); +    int reg = uhd::clip(uhd::narrow_cast<int>(std::lround(gain * 2 / 30.5)) + 1, 0, 3);      switch (reg) {          case 0:          case 1: @@ -620,7 +621,7 @@ double xcvr2450::set_rx_gain(double gain, const std::string& name)  static max2829_regs_t::tx_lpf_coarse_adj_t bandwidth_to_tx_lpf_coarse_reg(      double& bandwidth)  { -    int reg = uhd::clip(boost::math::iround((bandwidth - 6.0e6) / 6.0e6), 1, 3); +    int reg = uhd::clip(uhd::narrow_cast<int>(std::lround((bandwidth - 6.0e6)) / 6.0e6), 1, 3);      switch (reg) {          case 1: // bandwidth < 15MHz @@ -639,8 +640,10 @@ static max2829_regs_t::tx_lpf_coarse_adj_t bandwidth_to_tx_lpf_coarse_reg(  static max2829_regs_t::rx_lpf_fine_adj_t bandwidth_to_rx_lpf_fine_reg(      double& bandwidth, double requested_bandwidth)  { -    int reg = -        uhd::clip(boost::math::iround((requested_bandwidth / bandwidth) / 0.05), 18, 22); +    int reg = uhd::clip( +        uhd::narrow_cast<int>(std::lround((requested_bandwidth / bandwidth)) / 0.05), +        18, +        22);      switch (reg) {          case 18: // requested_bandwidth < 92.5% @@ -665,7 +668,8 @@ static max2829_regs_t::rx_lpf_fine_adj_t bandwidth_to_rx_lpf_fine_reg(  static max2829_regs_t::rx_lpf_coarse_adj_t bandwidth_to_rx_lpf_coarse_reg(      double& bandwidth)  { -    int reg = uhd::clip(boost::math::iround((bandwidth - 7.0e6) / 1.0e6), 0, 11); +    int reg = +        uhd::clip(uhd::narrow_cast<int>(std::lround((bandwidth - 7.0e6)) / 1.0e6), 0, 11);      switch (reg) {          case 0: // bandwidth < 7.5MHz diff --git a/host/lib/usrp/dboard/twinrx/twinrx_experts.cpp b/host/lib/usrp/dboard/twinrx/twinrx_experts.cpp index 8d3ba591b..58e22e089 100644 --- a/host/lib/usrp/dboard/twinrx/twinrx_experts.cpp +++ b/host/lib/usrp/dboard/twinrx/twinrx_experts.cpp @@ -13,7 +13,7 @@  #include <uhd/utils/log.hpp>  #include <uhd/utils/math.hpp>  #include <boost/assign/list_of.hpp> -#include <boost/math/special_functions/round.hpp> +#include <cmath>  using namespace uhd::experts;  using namespace uhd::math; @@ -271,7 +271,7 @@ void twinrx_chan_gain_expert::resolve()      // Compute minimum gain. The user-specified gain value will be interpreted as      // the gain applied on top of the minimum gain state.      // If antennas are shared or swapped, the switch has 6dB of loss -    size_t gain_index = std::min(static_cast<size_t>(boost::math::round(_gain.get())), +    size_t gain_index = std::min(static_cast<size_t>(std::lround(_gain.get())),          table.get_num_entries() - 1);      // Translate gain to an index in the gain table diff --git a/host/lib/usrp/usrp1/codec_ctrl.cpp b/host/lib/usrp/usrp1/codec_ctrl.cpp index ca5503132..413caaf67 100644 --- a/host/lib/usrp/usrp1/codec_ctrl.cpp +++ b/host/lib/usrp/usrp1/codec_ctrl.cpp @@ -13,11 +13,12 @@  #include <uhd/utils/byteswap.hpp>  #include <uhd/utils/log.hpp>  #include <uhd/utils/safe_call.hpp> -#include <stdint.h> +#include <uhdlib/utils/narrow.hpp> +#include <cstdint>  #include <boost/assign/list_of.hpp>  #include <boost/format.hpp> -#include <boost/math/special_functions/round.hpp>  #include <boost/math/special_functions/sign.hpp> +#include <cmath>  #include <iomanip>  #include <tuple> @@ -257,7 +258,8 @@ void usrp1_codec_ctrl_impl::write_aux_dac(aux_dac_t which, double volts)  {      // special case for aux dac d (aka sigma delta word)      if (which == AUX_DAC_D) { -        uint16_t dac_word = uhd::clip(boost::math::iround(volts * 0xfff / 3.3), 0, 0xfff); +        uint16_t dac_word = uhd::clip( +            uhd::narrow_cast<int>(std::lround(volts * 0xfff / 3.3)), 0, 0xfff);          _ad9862_regs.sig_delt_11_4 = uint8_t(dac_word >> 4);          _ad9862_regs.sig_delt_3_0  = uint8_t(dac_word & 0xf);          this->send_reg(42); @@ -266,7 +268,8 @@ void usrp1_codec_ctrl_impl::write_aux_dac(aux_dac_t which, double volts)      }      // calculate the dac word for aux dac a, b, c -    uint8_t dac_word = uhd::clip(boost::math::iround(volts * 0xff / 3.3), 0, 0xff); +    uint8_t dac_word = +        uhd::clip(uhd::narrow_cast<int>(std::lround(volts * 0xff / 3.3)), 0, 0xff);      // setup a lookup table for the aux dac params (reg ref, reg addr)      typedef std::tuple<uint8_t*, uint8_t> dac_params_t; @@ -356,7 +359,7 @@ double usrp1_codec_ctrl_impl::fine_tune(double codec_rate, double target_freq)      static const double scale_factor = std::pow(2.0, 24);      uint32_t freq_word = -        uint32_t(boost::math::round(std::abs((target_freq / codec_rate) * scale_factor))); +        uint32_t(std::lround(std::abs((target_freq / codec_rate) * scale_factor)));      double actual_freq = freq_word * codec_rate / scale_factor; diff --git a/host/lib/usrp/usrp1/io_impl.cpp b/host/lib/usrp/usrp1/io_impl.cpp index b93cfa094..5d7b4a77b 100644 --- a/host/lib/usrp/usrp1/io_impl.cpp +++ b/host/lib/usrp/usrp1/io_impl.cpp @@ -17,11 +17,11 @@  #include <uhd/utils/safe_call.hpp>  #include <uhd/utils/tasks.hpp>  #include <boost/format.hpp> -#include <boost/math/special_functions/round.hpp>  #include <boost/math/special_functions/sign.hpp>  #include <boost/thread/thread.hpp>  #include <atomic>  #include <chrono> +#include <cmath>  #include <functional>  #include <memory>  #include <thread> @@ -517,7 +517,7 @@ uhd::meta_range_t usrp1_impl::get_tx_dsp_host_rates(void)  double usrp1_impl::update_rx_samp_rate(size_t dspno, const double samp_rate)  {      const size_t div  = this->has_rx_halfband() ? 2 : 1; -    const size_t rate = boost::math::iround( +    const size_t rate = std::lround(          _master_clock_rate / this->get_rx_dsp_host_rates().clip(samp_rate, true));      if (rate < 8 and this->has_rx_halfband()) @@ -548,7 +548,7 @@ double usrp1_impl::update_rx_samp_rate(size_t dspno, const double samp_rate)  double usrp1_impl::update_tx_samp_rate(size_t dspno, const double samp_rate)  {      const size_t div  = this->has_tx_halfband() ? 4 : 2; // doubled for codec interp -    const size_t rate = boost::math::iround( +    const size_t rate = std::lround(          _master_clock_rate / this->get_tx_dsp_host_rates().clip(samp_rate, true));      if (dspno == 0) { // only care if dsp0 is set since its homogeneous @@ -591,7 +591,7 @@ double usrp1_impl::update_rx_dsp_freq(const size_t dspno, const double freq_)      UHD_ASSERT_THROW(std::abs(freq) <= _master_clock_rate / 2.0);      static const double scale_factor = std::pow(2.0, 32);      const int32_t freq_word = -        int32_t(boost::math::round((freq / _master_clock_rate) * scale_factor)); +        int32_t(std::lround((freq / _master_clock_rate) * scale_factor));      static const uint32_t dsp_index_to_reg_val[4] = {          FR_RX_FREQ_0, FR_RX_FREQ_1, FR_RX_FREQ_2, FR_RX_FREQ_3}; diff --git a/host/lib/usrp/usrp1/usrp1_impl.cpp b/host/lib/usrp/usrp1/usrp1_impl.cpp index 6ed1a6a69..d88b6af8e 100644 --- a/host/lib/usrp/usrp1/usrp1_impl.cpp +++ b/host/lib/usrp/usrp1/usrp1_impl.cpp @@ -16,8 +16,8 @@  #include <boost/filesystem.hpp>  #include <boost/format.hpp>  #include <boost/lexical_cast.hpp> -#include <boost/math/special_functions/round.hpp>  #include <chrono> +#include <cmath>  #include <cstdio>  #include <functional> @@ -533,8 +533,8 @@ void usrp1_impl::set_enb_rx_dc_offset(const std::string& db, const bool enb)  std::complex<double> usrp1_impl::set_rx_dc_offset(      const std::string& db, const std::complex<double>& offset)  { -    const int32_t i_off = boost::math::iround(offset.real() * (1ul << 31)); -    const int32_t q_off = boost::math::iround(offset.imag() * (1ul << 31)); +    const int32_t i_off = static_cast<int32_t>(std::lround(offset.real() * (1ul << 31))); +    const int32_t q_off = static_cast<int32_t>(std::lround(offset.imag() * (1ul << 31)));      if (db == "A") {          _iface->poke32(FR_ADC_OFFSET_0, i_off); diff --git a/host/lib/usrp/usrp2/clock_ctrl.cpp b/host/lib/usrp/usrp2/clock_ctrl.cpp index 324826dc0..8c5801bda 100644 --- a/host/lib/usrp/usrp2/clock_ctrl.cpp +++ b/host/lib/usrp/usrp2/clock_ctrl.cpp @@ -13,9 +13,8 @@  #include <uhd/utils/assert_has.hpp>  #include <uhd/utils/safe_call.hpp>  #include <uhdlib/utils/narrow.hpp> -#include <stdint.h> -#include <boost/math/special_functions/round.hpp> -#include <iostream> +#include <cmath> +#include <cstdint>  using namespace uhd; @@ -317,7 +316,7 @@ public:          // offset_ns = 0.34 + (1600 - i_ramp_ua)*1e-4 + ((caps-1)/ramp)*6          // delay_ns = offset_ns + range_ns * delay / 31 -        int delay_val = boost::math::iround(delay / 9.744e-9 * 31); +        int delay_val = static_cast<int>(std::lround(delay / 9.744e-9 * 31));          if (delay_val == 0) {              switch (clk_regs.exp) { diff --git a/host/lib/usrp/usrp2/dboard_iface.cpp b/host/lib/usrp/usrp2/dboard_iface.cpp index 649019a91..169139ba1 100644 --- a/host/lib/usrp/usrp2/dboard_iface.cpp +++ b/host/lib/usrp/usrp2/dboard_iface.cpp @@ -18,7 +18,7 @@  #include <uhdlib/usrp/cores/gpio_core_200.hpp>  #include <boost/asio.hpp> //htonl and ntohl  #include <boost/assign/list_of.hpp> -#include <boost/math/special_functions/round.hpp> +#include <cmath>  using namespace uhd;  using namespace uhd::usrp; @@ -300,7 +300,7 @@ void usrp2_dboard_iface::write_aux_dac(unit_t unit, aux_dac_t which, double valu      if (unit == UNIT_BOTH)          throw uhd::runtime_error("UNIT_BOTH not supported."); -    _dac_regs[unit].data = boost::math::iround(4095 * value / 3.3); +    _dac_regs[unit].data = static_cast<int>(std::lround(4095 * value / 3.3));      _dac_regs[unit].cmd  = ad5623_regs_t::CMD_WR_UP_DAC_CHAN_N;      typedef uhd::dict<aux_dac_t, ad5623_regs_t::addr_t> aux_dac_to_addr; diff --git a/host/lib/usrp/usrp2/usrp2_impl.cpp b/host/lib/usrp/usrp2/usrp2_impl.cpp index e82a9fa71..7bdce177b 100644 --- a/host/lib/usrp/usrp2/usrp2_impl.cpp +++ b/host/lib/usrp/usrp2/usrp2_impl.cpp @@ -18,9 +18,8 @@  #include <boost/asio.hpp>  #include <boost/asio/ip/address_v4.hpp>  #include <boost/format.hpp> -#include <boost/math/special_functions.hpp> -#include <functional>  #include <cmath> +#include <functional>  using namespace uhd;  using namespace uhd::usrp; diff --git a/host/lib/usrp/x300/x300_clock_ctrl.cpp b/host/lib/usrp/x300/x300_clock_ctrl.cpp index 7459e9069..b7b8f272c 100644 --- a/host/lib/usrp/x300/x300_clock_ctrl.cpp +++ b/host/lib/usrp/x300/x300_clock_ctrl.cpp @@ -12,7 +12,6 @@  #include <uhd/utils/safe_call.hpp>  #include <stdint.h>  #include <boost/format.hpp> -#include <boost/math/special_functions/round.hpp>  #include <cmath>  #include <cstdlib>  #include <stdexcept> @@ -315,14 +314,14 @@ public:              // difference using analog delay. Do the best we can.              adly_en    = true;              adly_value = static_cast<uint8_t>( -                boost::math::round((ADLY_MAX_NS - ADLY_MIN_NS) / ADLY_RES_NS)); +                std::lround((ADLY_MAX_NS - ADLY_MIN_NS) / ADLY_RES_NS));              coerced_delay += ADLY_MAX_NS;          } else if (leftover_delay >= ADLY_MIN_NS && leftover_delay <= ADLY_MAX_NS) {              // The leftover delay can be compensated by the analog delay up to the analog              // delay resolution              adly_en    = true;              adly_value = static_cast<uint8_t>( -                boost::math::round((leftover_delay - ADLY_MIN_NS) / ADLY_RES_NS)); +                std::lround((leftover_delay - ADLY_MIN_NS) / ADLY_RES_NS));              coerced_delay += ADLY_MIN_NS + (ADLY_RES_NS * adly_value);          } else if (leftover_delay >= (ADLY_MIN_NS - half_vco_period_ns)                     && leftover_delay < ADLY_MIN_NS) { @@ -330,7 +329,7 @@ public:              // we move the digital delay back by half a VCO cycle then it will be in the              // range of the analog delay. So do that!              adly_en       = true; -            adly_value    = static_cast<uint8_t>(boost::math::round( +            adly_value    = static_cast<uint8_t>(std::lround(                  (leftover_delay + half_vco_period_ns - ADLY_MIN_NS) / ADLY_RES_NS));              half_shift_en = 1;              coerced_delay += @@ -513,7 +512,7 @@ private:                  // better spur performance by balancing the predivider and the                  // divider.                  const int n = static_cast<int>( -                    boost::math::round((r * try_vco_freq) / (VCXO_PLL2_N * ref))); +                    std::lround((r * try_vco_freq) / (VCXO_PLL2_N * ref)));                  const double actual_mcr = (ref * VCXO_PLL2_N * n) / (vcodiv * r);                  const double error      = std::abs(actual_mcr - output_freq); diff --git a/host/lib/usrp/x300/x300_dboard_iface.cpp b/host/lib/usrp/x300/x300_dboard_iface.cpp index 36e430985..4c7a1d55b 100644 --- a/host/lib/usrp/x300/x300_dboard_iface.cpp +++ b/host/lib/usrp/x300/x300_dboard_iface.cpp @@ -9,7 +9,7 @@  #include "x300_regs.hpp"  #include <uhd/utils/safe_call.hpp>  #include <boost/assign/list_of.hpp> -#include <boost/math/special_functions/round.hpp> +#include <cmath>  using namespace uhd;  using namespace uhd::usrp; @@ -218,7 +218,7 @@ void x300_dboard_iface::write_aux_dac(unit_t unit, aux_dac_t which, double value      if (unit == UNIT_BOTH)          throw uhd::runtime_error("UNIT_BOTH not supported."); -    _dac_regs[unit].data = boost::math::iround(4095 * value / 3.3); +    _dac_regs[unit].data = static_cast<int>(std::lround(4095 * value / 3.3));      _dac_regs[unit].cmd  = ad5623_regs_t::CMD_WR_UP_DAC_CHAN_N;      typedef uhd::dict<aux_dac_t, ad5623_regs_t::addr_t> aux_dac_to_addr; | 
