Line data Source code
1 :
2 :
3 : #ifndef mx_precision_hpp
4 : #define mx_precision_hpp
5 :
6 : #include <type_traits>
7 :
8 : #ifdef MX_INCLUDE_BOOST
9 : #include <boost/math/tools/precision.hpp>
10 : #endif
11 :
12 : namespace mx
13 : {
14 : namespace math
15 : {
16 : namespace func
17 : {
18 :
19 : /// Get the sqrt(epsilon) where epsilon is machine precision
20 : /** Wrapper for boost function
21 : *
22 : * \todo this isn't, but should be constexpr -- need constr sqrt.
23 : *
24 : * \ingroup gen_math_precision
25 : */
26 : template <typename T>
27 0 : T root_epsilon()
28 : {
29 : #ifdef MX_INCLUDE_BOOST
30 : return boost::math::tools::root_epsilon<T>();
31 : #else
32 : static_assert(
33 : std::is_fundamental<T>::value || !std::is_fundamental<T>::value,
34 : "root_epsilon<T> not specialized for type T, and MX_INCLUDE_BOOST is not defined, so I can't just use boost." );
35 0 : return 0;
36 : #endif
37 : }
38 :
39 : template <>
40 : float root_epsilon<float>();
41 :
42 : template <>
43 : double root_epsilon<double>();
44 :
45 : } // namespace func
46 : } // namespace math
47 : } // namespace mx
48 :
49 : #endif // mx_precision_hpp
|