math_utils.hpp 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. #ifndef _SCTL_MATH_UTILS_
  2. #define _SCTL_MATH_UTILS_
  3. #include SCTL_INCLUDE(common.hpp)
  4. #include <cmath>
  5. #include <ostream>
  6. namespace SCTL_NAMESPACE {
  7. template <class Real> Real atoreal(const char* str);
  8. template <class Real> inline Real const_pi() { return (Real)3.1415926535897932384626433832795028841L; }
  9. template <class Real> inline Real const_e() { return (Real)2.7182818284590452353602874713526624977L; }
  10. template <class Real> inline Real fabs(const Real a) { return (Real)::fabs(a); }
  11. template <class Real> inline Real sqrt(const Real a) { return (Real)::sqrt(a); }
  12. template <class Real> inline Real sin(const Real a) { return (Real)::sin(a); }
  13. template <class Real> inline Real cos(const Real a) { return (Real)::cos(a); }
  14. template <class Real> inline Real exp(const Real a) { return (Real)::exp(a); }
  15. template <class Real> inline Real log(const Real a) { return (Real)::log(a); }
  16. template <class Real, class ExpType> inline constexpr Real pow(const Real b, const ExpType e) { return (Real)std::pow(b, e); }
  17. template <Integer e, class ValueType> inline constexpr ValueType pow(ValueType b);
  18. template <class ValueType> inline constexpr ValueType pow(ValueType b, Integer e);
  19. } // end namespace
  20. #ifdef SCTL_QUAD_T
  21. namespace SCTL_NAMESPACE {
  22. typedef SCTL_QUAD_T QuadReal;
  23. inline std::ostream& operator<<(std::ostream& output, const QuadReal q_);
  24. }
  25. inline std::ostream& operator<<(std::ostream& output, const SCTL_QUAD_T q_);
  26. #endif // SCTL_QUAD_T
  27. #include SCTL_INCLUDE(math_utils.txx)
  28. #endif //_SCTL_MATH_UTILS_HPP_