#ifndef SPROUT_MATH_TANH_HPP #define SPROUT_MATH_TANH_HPP #include #include #include #include #include #include #include #include namespace sprout { namespace math { namespace detail { template inline SPROUT_CONSTEXPR T tanh_impl(T x) { return sprout::math::sinh(x) / sprout::math::cosh(x); } template< typename FloatType, typename sprout::enabler_if::value>::type = sprout::enabler > inline SPROUT_CONSTEXPR FloatType tanh(FloatType x) { return x == std::numeric_limits::infinity() ? FloatType(1) : x == -std::numeric_limits::infinity() ? FloatType(-1) #if SPROUT_USE_BUILTIN_CMATH_FUNCTION : std::tanh(x) #else : x == 0 ? x : static_cast(sprout::math::detail::tanh_impl(static_cast::type>(x))) #endif ; } template< typename IntType, typename sprout::enabler_if::value>::type = sprout::enabler > inline SPROUT_CONSTEXPR double tanh(IntType x) { return sprout::math::detail::tanh(static_cast(x)); } } // namespace detail using sprout::math::detail::tanh; } // namespace math using sprout::math::tanh; } // namespace sprout #endif // #ifndef SPROUT_MATH_TANH_HPP