math_utils.hpp 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /**
  2. * \file math_utils.hpp
  3. * \author Dhairya Malhotra, dhairya.malhotra@gmail.com
  4. * \date 7-16-2014
  5. * \brief This file contains wrappers for functions in math.h
  6. */
  7. #include <cmath>
  8. #include <ostream>
  9. #ifndef _MATH_UTILS_
  10. #define _MATH_UTILS_
  11. namespace pvfmm{
  12. template <class Real_t>
  13. inline Real_t const_pi(){return 3.1415926535897932384626433832795028841;}
  14. template <class Real_t>
  15. inline Real_t const_e (){return 2.7182818284590452353602874713526624977;}
  16. //template <class Real_t>
  17. //inline std::ostream& operator<<(std::ostream& output, const Real_t q_);
  18. template <class Real_t>
  19. inline Real_t fabs(const Real_t f){return ::fabs(f);}
  20. template <class Real_t>
  21. inline Real_t sqrt(const Real_t a){return ::sqrt(a);}
  22. template <class Real_t>
  23. inline Real_t sin(const Real_t a){return ::sin(a);}
  24. template <class Real_t>
  25. inline Real_t cos(const Real_t a){return ::cos(a);}
  26. template <class Real_t>
  27. inline Real_t exp(const Real_t a){return ::exp(a);}
  28. template <class Real_t>
  29. inline Real_t log(const Real_t a){return ::log(a);}
  30. template <class Real_t>
  31. inline Real_t pow(const Real_t b, const Real_t e){return ::pow(b,e);}
  32. }//end namespace
  33. #ifdef PVFMM_QUAD_T
  34. typedef PVFMM_QUAD_T QuadReal_t;
  35. namespace pvfmm{
  36. inline QuadReal_t atoquad(const char* str);
  37. }
  38. inline std::ostream& operator<<(std::ostream& output, const QuadReal_t q_);
  39. #endif //PVFMM_QUAD_T
  40. #endif //_MATH_UTILS_HPP_