8 #ifndef INCLUDED_UHD_UTILS_MATH_HPP 9 #define INCLUDED_UHD_UTILS_MATH_HPP 13 #include <boost/numeric/conversion/bounds.hpp> 15 #if BOOST_VERSION >= 106700 16 # include <boost/integer/common_factor.hpp> 18 namespace _bmint = boost::integer;
20 # include <boost/math/common_factor.hpp> 21 namespace _bmint = boost::math;
49 static const float SINGLE_PRECISION_EPSILON = 1.19e-7f;
50 static const double DOUBLE_PRECISION_EPSILON = 2.22e-16;
52 namespace fp_compare {
95 template <
typename float_t>
98 template <
typename float_t>
101 template <
typename float_t>
104 template <
typename float_t>
107 template <
typename float_t>
110 template <
typename float_t>
116 template <
typename float_t>
118 template <
typename float_t>
120 template <
typename float_t>
121 UHD_INLINE bool operator<(fp_compare_epsilon<float_t> lhs,
double rhs);
122 template <
typename float_t>
123 UHD_INLINE bool operator<=(fp_compare_epsilon<float_t> lhs,
double rhs);
124 template <
typename float_t>
126 template <
typename float_t>
129 template <
typename float_t>
131 template <
typename float_t>
133 template <
typename float_t>
134 UHD_INLINE bool operator<(double lhs, fp_compare_epsilon<float_t> rhs);
135 template <
typename float_t>
136 UHD_INLINE bool operator<=(double lhs, fp_compare_epsilon<float_t> rhs);
137 template <
typename float_t>
139 template <
typename float_t>
151 static const float SINGLE_PRECISION_DELTA = 1e-3f;
152 static const double DOUBLE_PRECISION_DELTA = 1e-5;
155 static const double FREQ_COMPARISON_DELTA_HZ = 0.1;
158 namespace fp_compare {
177 UHD_INLINE fp_compare_delta(float_t value, float_t delta);
186 template <
typename float_t>
188 template <
typename float_t>
190 template <
typename float_t>
192 template <
typename float_t>
194 template <
typename float_t>
196 template <
typename float_t>
201 template <
typename float_t>
203 template <
typename float_t>
205 template <
typename float_t>
206 UHD_INLINE bool operator<(fp_compare_delta<float_t> lhs,
double rhs);
207 template <
typename float_t>
208 UHD_INLINE bool operator<=(fp_compare_delta<float_t> lhs,
double rhs);
209 template <
typename float_t>
211 template <
typename float_t>
214 template <
typename float_t>
216 template <
typename float_t>
218 template <
typename float_t>
219 UHD_INLINE bool operator<(double lhs, fp_compare_delta<float_t> rhs);
220 template <
typename float_t>
221 UHD_INLINE bool operator<=(double lhs, fp_compare_delta<float_t> rhs);
222 template <
typename float_t>
224 template <
typename float_t>
236 template <
typename IntegerType>
inline IntegerType
lcm(IntegerType x, IntegerType y)
239 return _bmint::lcm<IntegerType>(x, y);
243 template <
typename IntegerType>
inline IntegerType
gcd(IntegerType x, IntegerType y)
246 return _bmint::gcd<IntegerType>(x, y);
UHD_INLINE bool frequencies_are_equal(double lhs, double rhs)
Definition: math.hpp:229
UHD_INLINE bool operator<=(fp_compare_delta< float_t > lhs, fp_compare_delta< float_t > rhs)
Definition: fp_compare_delta.ipp:76
float_t _value
Definition: math.hpp:182
UHD_INLINE bool operator>=(fp_compare_delta< float_t > lhs, fp_compare_delta< float_t > rhs)
Definition: fp_compare_delta.ipp:87
IntegerType gcd(IntegerType x, IntegerType y)
Portable version of gcd() across Boost versions.
Definition: math.hpp:243
UHD_INLINE bool operator>(fp_compare_delta< float_t > lhs, fp_compare_delta< float_t > rhs)
Definition: fp_compare_delta.ipp:81
UHD_INLINE bool operator!=(fp_compare_delta< float_t > lhs, fp_compare_delta< float_t > rhs)
Definition: fp_compare_delta.ipp:65
float_t _delta
Definition: math.hpp:183
float_t _epsilon
Definition: math.hpp:77
Definition: build_info.hpp:13
UHD_INLINE bool operator<(fp_compare_delta< float_t > lhs, fp_compare_delta< float_t > rhs)
Definition: fp_compare_delta.ipp:70
#define UHD_INLINE
Definition: config.h:53
UHD_INLINE ~fp_compare_epsilon()
Definition: fp_compare_epsilon.ipp:44
float_t _value
Definition: math.hpp:76
UHD_INLINE void operator=(const fp_compare_epsilon ©)
Definition: fp_compare_epsilon.ipp:48
UHD_INLINE fp_compare_epsilon(float_t value)
UHD_INLINE bool operator==(fp_compare_delta< float_t > lhs, fp_compare_delta< float_t > rhs)
Definition: fp_compare_delta.ipp:59
IntegerType lcm(IntegerType x, IntegerType y)
Portable version of lcm() across Boost versions.
Definition: math.hpp:236