HMLP: High-performance Machine Learning Primitives
math_utils.hpp
1 #ifndef _MATH_UTILS_
2 #define _MATH_UTILS_
3 
4 #include <pvfmm/common.hpp>
5 
6 #include <cmath>
7 #include <ostream>
8 
9 namespace pvfmm {
10 
11 template <class Real> inline Real const_pi() { return 3.1415926535897932384626433832795028841; }
12 
13 template <class Real> inline Real const_e() { return 2.7182818284590452353602874713526624977; }
14 
15 template <class Real> inline Real fabs(const Real f) { return ::fabs(f); }
16 
17 template <class Real> inline Real sqrt(const Real a) { return ::sqrt(a); }
18 
19 template <class Real> inline Real sin(const Real a) { return ::sin(a); }
20 
21 template <class Real> inline Real cos(const Real a) { return ::cos(a); }
22 
23 template <class Real> inline Real exp(const Real a) { return ::exp(a); }
24 
25 template <class Real> inline Real log(const Real a) { return ::log(a); }
26 
27 template <class Real> inline Real pow(const Real b, const Real e) { return ::pow(b, e); }
28 
29 template <Integer N, class T> constexpr T pow(const T& x) { return N > 1 ? x * pow<(N - 1) * (N > 1)>(x) : N < 0 ? T(1) / pow<(-N) * (N < 0)>(x) : N == 1 ? x : T(1); }
30 
31 } // end namespace
32 
33 #ifdef PVFMM_QUAD_T
34 
35 namespace pvfmm {
36 
37 typedef PVFMM_QUAD_T QuadReal;
38 
39 QuadReal atoquad(const char* str);
40 }
41 
42 std::ostream& operator<<(std::ostream& output, const pvfmm::QuadReal q_);
43 
44 #endif // PVFMM_QUAD_T
45 
46 #include <pvfmm/math_utils.txx>
47 
48 #endif //_MATH_UTILS_HPP_
Definition: cheb_utils.hpp:12