32 #ifndef VSMC_CXX11_CMATH_HPP
33 #define VSMC_CXX11_CMATH_HPP
38 #if VSMC_HAS_CXX11LIB_CMATH
40 namespace vsmc {
namespace cxx11 {
58 #elif VSMC_HAS_C99LIB_MATH
60 #define VSMC_DEFINE_C99_MATH_SPECIAL(name) \
61 inline float (name) (float x) {return ::name##f(x);} \
62 inline double (name) (double x) {return ::name(x);} \
63 inline long double (name) (long double x) {return ::name##l(x);} \
64 template <typename T> inline double (name) (T x) \
65 {return ::name(static_cast<double>(x));}
67 namespace vsmc {
namespace cxx11 {
69 inline float (hypot) (
float x,
float y) {return ::hypotf(x, y);}
70 inline double (hypot) (
float x,
double y) {return ::hypot (x, y);}
71 inline long double (hypot) (
float x,
long double y) {return ::hypotl(x, y);}
72 inline double (hypot) (
double x,
float y) {return ::hypot (x, y);}
73 inline double (hypot) (
double x,
double y) {return ::hypot (x, y);}
74 inline long double (hypot) (
double x,
long double y) {return ::hypotl(x, y);}
75 inline long double (hypot) (
long double x,
float y) {return ::hypotl(x, y);}
76 inline long double (hypot) (
long double x,
double y) {return ::hypotl(x, y);}
77 inline long double (hypot) (
long double x,
long double y) {return ::hypotl(x, y);}
78 template <
typename T1,
typename T2>
inline double (hypot) (T1 x, T2 y)
79 {return ::hypot(static_cast<double>(x), static_cast<double>(y));}
81 VSMC_DEFINE_C99_MATH_SPECIAL(exp2)
82 VSMC_DEFINE_C99_MATH_SPECIAL(log2)
83 VSMC_DEFINE_C99_MATH_SPECIAL(expm1)
84 VSMC_DEFINE_C99_MATH_SPECIAL(log1p)
85 VSMC_DEFINE_C99_MATH_SPECIAL(cbrt)
86 VSMC_DEFINE_C99_MATH_SPECIAL(asinh)
87 VSMC_DEFINE_C99_MATH_SPECIAL(acosh)
88 VSMC_DEFINE_C99_MATH_SPECIAL(atanh)
89 VSMC_DEFINE_C99_MATH_SPECIAL(erf)
90 VSMC_DEFINE_C99_MATH_SPECIAL(erfc)
91 VSMC_DEFINE_C99_MATH_SPECIAL(lgamma)
92 VSMC_DEFINE_C99_MATH_SPECIAL(tgamma)
96 #else // VSMC_HAS_CXX11LIB_CMATH
99 #include <boost/math/special_functions.hpp>
101 namespace vsmc {
namespace cxx11 {
103 inline float (exp2) (
float x)
105 inline double (exp2) (
double x)
107 inline long double (exp2) (
long double x)
109 template <
typename T>
inline double (exp2) (T x)
112 inline float (log2) (
float x)
114 inline double (log2) (
double x)
116 inline long double (log2) (
long double x)
118 template <
typename T>
inline double (log2) (T x)
121 using ::boost::math::expm1;
122 using ::boost::math::log1p;
123 using ::boost::math::cbrt;
124 using ::boost::math::hypot;
125 using ::boost::math::asinh;
126 using ::boost::math::acosh;
127 using ::boost::math::atanh;
128 using ::boost::math::erf;
129 using ::boost::math::erfc;
130 using ::boost::math::lgamma;
131 using ::boost::math::tgamma;
135 #endif // VSMC_HAS_CXX11LIB_CMATH
137 #endif // VSMC_CXX11_CMATH_HPP
long double ln_2< long double >()
double ln_inv_2< double >()
float ln_inv_2< float >()
long double ln_inv_2< long double >()