13#include <boost/numeric/conversion/bounds.hpp>
15#if BOOST_VERSION >= 106700
16# include <boost/integer/common_factor.hpp>
18namespace _bmint = boost::integer;
20# include <boost/math/common_factor.hpp>
21namespace _bmint = boost::math;
33static const double PI = 3.14159265358979323846;
51static const float SINGLE_PRECISION_EPSILON = 1.19e-7f;
52static const double DOUBLE_PRECISION_EPSILON = 2.22e-16;
62static constexpr double FREQ_COMPARE_EPSILON = 1e-12;
79template <
typename float_t>
108template <
typename float_t>
111template <
typename float_t>
114template <
typename float_t>
117template <
typename float_t>
120template <
typename float_t>
123template <
typename float_t>
129template <
typename float_t>
131template <
typename float_t>
133template <
typename float_t>
135template <
typename float_t>
137template <
typename float_t>
139template <
typename float_t>
142template <
typename float_t>
144template <
typename float_t>
146template <
typename float_t>
148template <
typename float_t>
150template <
typename float_t>
152template <
typename float_t>
180static const float SINGLE_PRECISION_DELTA = 1e-3f;
181static const double DOUBLE_PRECISION_DELTA = 1e-5;
184static const double FREQ_COMPARISON_DELTA_HZ = 0.1;
187namespace fp_compare {
202template <
typename float_t>
216template <
typename float_t>
218template <
typename float_t>
220template <
typename float_t>
222template <
typename float_t>
224template <
typename float_t>
226template <
typename float_t>
231template <
typename float_t>
233template <
typename float_t>
235template <
typename float_t>
237template <
typename float_t>
239template <
typename float_t>
241template <
typename float_t>
244template <
typename float_t>
246template <
typename float_t>
248template <
typename float_t>
250template <
typename float_t>
252template <
typename float_t>
254template <
typename float_t>
267 return std::pow(10, (dB_val) / 10.0);
272 return 10 * std::log10(val);
277template <
typename IntegerType>
278inline IntegerType
lcm(IntegerType x, IntegerType y)
281 return _bmint::lcm<IntegerType>(x, y);
285template <
typename IntegerType>
286inline IntegerType
gcd(IntegerType x, IntegerType y)
289 return _bmint::gcd<IntegerType>(x, y);
304 return (T(0) < x) - (x < T(0));
319 double freq = std::fmod(requested_freq, rate);
320 if (std::abs(freq) > rate / 2.0)
UHD_INLINE fp_compare_delta(float_t value)
float_t _delta
Definition: math.hpp:213
UHD_INLINE void operator=(const fp_compare_delta ©)
Definition: fp_compare_delta.ipp:52
UHD_INLINE ~fp_compare_delta()
Definition: fp_compare_delta.ipp:48
float_t _value
Definition: math.hpp:212
float_t _epsilon
Definition: math.hpp:90
UHD_INLINE ~fp_compare_epsilon()
Definition: fp_compare_epsilon.ipp:44
UHD_INLINE void operator=(const fp_compare_epsilon ©)
Definition: fp_compare_epsilon.ipp:48
float_t _value
Definition: math.hpp:89
UHD_INLINE fp_compare_epsilon(float_t value)
An alias for fp_compare_epsilon, but with defaults for frequencies.
Definition: math.hpp:157
UHD_INLINE freq_compare_epsilon(const freq_compare_epsilon ©)
Definition: math.hpp:164
UHD_INLINE freq_compare_epsilon(double value)
Definition: math.hpp:159
#define UHD_INLINE
Definition: config.h:65
UHD_INLINE bool operator!=(fp_compare_delta< float_t > lhs, fp_compare_delta< float_t > rhs)
Definition: fp_compare_delta.ipp:64
UHD_INLINE bool operator<=(fp_compare_delta< float_t > lhs, fp_compare_delta< float_t > rhs)
Definition: fp_compare_delta.ipp:75
UHD_INLINE bool operator==(fp_compare_delta< float_t > lhs, fp_compare_delta< float_t > rhs)
Definition: fp_compare_delta.ipp:58
UHD_INLINE bool operator<(fp_compare_delta< float_t > lhs, fp_compare_delta< float_t > rhs)
Definition: fp_compare_delta.ipp:69
UHD_INLINE bool operator>(fp_compare_delta< float_t > lhs, fp_compare_delta< float_t > rhs)
Definition: fp_compare_delta.ipp:80
UHD_INLINE bool operator>=(fp_compare_delta< float_t > lhs, fp_compare_delta< float_t > rhs)
Definition: fp_compare_delta.ipp:86
IntegerType lcm(IntegerType x, IntegerType y)
Portable version of lcm() across Boost versions.
Definition: math.hpp:278
UHD_INLINE bool frequencies_are_equal(double lhs, double rhs)
Definition: math.hpp:259
double dB_to_lin(const double dB_val)
Definition: math.hpp:265
constexpr int sign(T x)
Returns the sign of x.
Definition: math.hpp:300
IntegerType gcd(IntegerType x, IntegerType y)
Portable version of gcd() across Boost versions.
Definition: math.hpp:286
double lin_to_dB(const double val)
Definition: math.hpp:270
double wrap_frequency(const double requested_freq, const double rate)
Return a wrapped frequency that is the equivalent frequency in the first.
Definition: math.hpp:317
Definition: build_info.hpp:12