File indexing completed on 2025-01-18 09:40:23
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 #ifndef BOOST_SINHC_HPP
0011 #define BOOST_SINHC_HPP
0012
0013
0014 #ifdef _MSC_VER
0015 #pragma once
0016 #endif
0017
0018 #include <boost/math/tools/precision.hpp>
0019 #include <boost/math/special_functions/math_fwd.hpp>
0020 #include <limits>
0021 #include <string>
0022 #include <stdexcept>
0023 #include <cmath>
0024
0025
0026
0027 namespace boost
0028 {
0029 namespace math
0030 {
0031 namespace detail
0032 {
0033
0034
0035 template<typename T>
0036 inline T sinhc_pi_imp(const T x)
0037 {
0038 using ::std::abs;
0039 using ::std::sinh;
0040 using ::std::sqrt;
0041
0042 static T const taylor_0_bound = tools::epsilon<T>();
0043 static T const taylor_2_bound = sqrt(taylor_0_bound);
0044 static T const taylor_n_bound = sqrt(taylor_2_bound);
0045
0046 if (abs(x) >= taylor_n_bound)
0047 {
0048 return(sinh(x)/x);
0049 }
0050 else
0051 {
0052
0053 T result = static_cast<T>(1);
0054
0055 if (abs(x) >= taylor_0_bound)
0056 {
0057 T x2 = x*x;
0058
0059
0060 result += x2/static_cast<T>(6);
0061
0062 if (abs(x) >= taylor_2_bound)
0063 {
0064
0065 result += (x2*x2)/static_cast<T>(120);
0066 }
0067 }
0068
0069 return(result);
0070 }
0071 }
0072
0073 }
0074
0075 template <class T>
0076 inline typename tools::promote_args<T>::type sinhc_pi(T x)
0077 {
0078 typedef typename tools::promote_args<T>::type result_type;
0079 return detail::sinhc_pi_imp(static_cast<result_type>(x));
0080 }
0081
0082 template <class T, class Policy>
0083 inline typename tools::promote_args<T>::type sinhc_pi(T x, const Policy&)
0084 {
0085 return boost::math::sinhc_pi(x);
0086 }
0087
0088 template<typename T, template<typename> class U>
0089 inline U<T> sinhc_pi(const U<T> x)
0090 {
0091 using std::abs;
0092 using std::sinh;
0093 using std::sqrt;
0094
0095 using ::std::numeric_limits;
0096
0097 static T const taylor_0_bound = tools::epsilon<T>();
0098 static T const taylor_2_bound = sqrt(taylor_0_bound);
0099 static T const taylor_n_bound = sqrt(taylor_2_bound);
0100
0101 if (abs(x) >= taylor_n_bound)
0102 {
0103 return(sinh(x)/x);
0104 }
0105 else
0106 {
0107
0108 #ifdef __MWERKS__
0109 U<T> result = static_cast<U<T> >(1);
0110 #else
0111 U<T> result = U<T>(1);
0112 #endif
0113
0114 if (abs(x) >= taylor_0_bound)
0115 {
0116 U<T> x2 = x*x;
0117
0118
0119 result += x2/static_cast<T>(6);
0120
0121 if (abs(x) >= taylor_2_bound)
0122 {
0123
0124 result += (x2*x2)/static_cast<T>(120);
0125 }
0126 }
0127
0128 return(result);
0129 }
0130 }
0131 }
0132 }
0133
0134 #endif
0135