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