annotate DEPENDENCIES/generic/include/boost/math/special_functions/sinhc.hpp @ 133:4acb5d8d80b6 tip

Don't fail environmental check if README.md exists (but .txt and no-suffix don't)
author Chris Cannam
date Tue, 30 Jul 2019 12:25:44 +0100
parents c530137014c0
children
rev   line source
Chris@16 1 // boost sinhc.hpp header file
Chris@16 2
Chris@16 3 // (C) Copyright Hubert Holin 2001.
Chris@16 4 // Distributed under the Boost Software License, Version 1.0. (See
Chris@16 5 // accompanying file LICENSE_1_0.txt or copy at
Chris@16 6 // http://www.boost.org/LICENSE_1_0.txt)
Chris@16 7
Chris@16 8 // See http://www.boost.org for updates, documentation, and revision history.
Chris@16 9
Chris@16 10 #ifndef BOOST_SINHC_HPP
Chris@16 11 #define BOOST_SINHC_HPP
Chris@16 12
Chris@16 13
Chris@16 14 #ifdef _MSC_VER
Chris@16 15 #pragma once
Chris@16 16 #endif
Chris@16 17
Chris@16 18 #include <boost/math/tools/config.hpp>
Chris@16 19 #include <boost/math/tools/precision.hpp>
Chris@16 20 #include <boost/math/special_functions/math_fwd.hpp>
Chris@16 21 #include <boost/config/no_tr1/cmath.hpp>
Chris@16 22 #include <boost/limits.hpp>
Chris@16 23 #include <string>
Chris@16 24 #include <stdexcept>
Chris@16 25
Chris@16 26 #include <boost/config.hpp>
Chris@16 27
Chris@16 28
Chris@16 29 // These are the the "Hyperbolic Sinus Cardinal" functions.
Chris@16 30
Chris@16 31 namespace boost
Chris@16 32 {
Chris@16 33 namespace math
Chris@16 34 {
Chris@16 35 namespace detail
Chris@16 36 {
Chris@16 37 // This is the "Hyperbolic Sinus Cardinal" of index Pi.
Chris@16 38
Chris@16 39 template<typename T>
Chris@16 40 inline T sinhc_pi_imp(const T x)
Chris@16 41 {
Chris@16 42 #if defined(BOOST_NO_STDC_NAMESPACE) && !defined(__SUNPRO_CC)
Chris@16 43 using ::abs;
Chris@16 44 using ::sinh;
Chris@16 45 using ::sqrt;
Chris@16 46 #else /* BOOST_NO_STDC_NAMESPACE */
Chris@16 47 using ::std::abs;
Chris@16 48 using ::std::sinh;
Chris@16 49 using ::std::sqrt;
Chris@16 50 #endif /* BOOST_NO_STDC_NAMESPACE */
Chris@16 51
Chris@16 52 static T const taylor_0_bound = tools::epsilon<T>();
Chris@16 53 static T const taylor_2_bound = sqrt(taylor_0_bound);
Chris@16 54 static T const taylor_n_bound = sqrt(taylor_2_bound);
Chris@16 55
Chris@16 56 if (abs(x) >= taylor_n_bound)
Chris@16 57 {
Chris@16 58 return(sinh(x)/x);
Chris@16 59 }
Chris@16 60 else
Chris@16 61 {
Chris@16 62 // approximation by taylor series in x at 0 up to order 0
Chris@16 63 T result = static_cast<T>(1);
Chris@16 64
Chris@16 65 if (abs(x) >= taylor_0_bound)
Chris@16 66 {
Chris@16 67 T x2 = x*x;
Chris@16 68
Chris@16 69 // approximation by taylor series in x at 0 up to order 2
Chris@16 70 result += x2/static_cast<T>(6);
Chris@16 71
Chris@16 72 if (abs(x) >= taylor_2_bound)
Chris@16 73 {
Chris@16 74 // approximation by taylor series in x at 0 up to order 4
Chris@16 75 result += (x2*x2)/static_cast<T>(120);
Chris@16 76 }
Chris@16 77 }
Chris@16 78
Chris@16 79 return(result);
Chris@16 80 }
Chris@16 81 }
Chris@16 82
Chris@16 83 } // namespace detail
Chris@16 84
Chris@16 85 template <class T>
Chris@16 86 inline typename tools::promote_args<T>::type sinhc_pi(T x)
Chris@16 87 {
Chris@16 88 typedef typename tools::promote_args<T>::type result_type;
Chris@16 89 return detail::sinhc_pi_imp(static_cast<result_type>(x));
Chris@16 90 }
Chris@16 91
Chris@16 92 template <class T, class Policy>
Chris@16 93 inline typename tools::promote_args<T>::type sinhc_pi(T x, const Policy&)
Chris@16 94 {
Chris@16 95 return boost::math::sinhc_pi(x);
Chris@16 96 }
Chris@16 97
Chris@16 98 #ifdef BOOST_NO_TEMPLATE_TEMPLATES
Chris@16 99 #else /* BOOST_NO_TEMPLATE_TEMPLATES */
Chris@16 100 template<typename T, template<typename> class U>
Chris@16 101 inline U<T> sinhc_pi(const U<T> x)
Chris@16 102 {
Chris@16 103 #if defined(BOOST_FUNCTION_SCOPE_USING_DECLARATION_BREAKS_ADL) || defined(__GNUC__)
Chris@16 104 using namespace std;
Chris@16 105 #elif defined(BOOST_NO_STDC_NAMESPACE) && !defined(__SUNPRO_CC)
Chris@16 106 using ::abs;
Chris@16 107 using ::sinh;
Chris@16 108 using ::sqrt;
Chris@16 109 #else /* BOOST_NO_STDC_NAMESPACE */
Chris@16 110 using ::std::abs;
Chris@16 111 using ::std::sinh;
Chris@16 112 using ::std::sqrt;
Chris@16 113 #endif /* BOOST_NO_STDC_NAMESPACE */
Chris@16 114
Chris@16 115 using ::std::numeric_limits;
Chris@16 116
Chris@16 117 static T const taylor_0_bound = tools::epsilon<T>();
Chris@16 118 static T const taylor_2_bound = sqrt(taylor_0_bound);
Chris@16 119 static T const taylor_n_bound = sqrt(taylor_2_bound);
Chris@16 120
Chris@16 121 if (abs(x) >= taylor_n_bound)
Chris@16 122 {
Chris@16 123 return(sinh(x)/x);
Chris@16 124 }
Chris@16 125 else
Chris@16 126 {
Chris@16 127 // approximation by taylor series in x at 0 up to order 0
Chris@16 128 #ifdef __MWERKS__
Chris@16 129 U<T> result = static_cast<U<T> >(1);
Chris@16 130 #else
Chris@16 131 U<T> result = U<T>(1);
Chris@16 132 #endif
Chris@16 133
Chris@16 134 if (abs(x) >= taylor_0_bound)
Chris@16 135 {
Chris@16 136 U<T> x2 = x*x;
Chris@16 137
Chris@16 138 // approximation by taylor series in x at 0 up to order 2
Chris@16 139 result += x2/static_cast<T>(6);
Chris@16 140
Chris@16 141 if (abs(x) >= taylor_2_bound)
Chris@16 142 {
Chris@16 143 // approximation by taylor series in x at 0 up to order 4
Chris@16 144 result += (x2*x2)/static_cast<T>(120);
Chris@16 145 }
Chris@16 146 }
Chris@16 147
Chris@16 148 return(result);
Chris@16 149 }
Chris@16 150 }
Chris@16 151 #endif /* BOOST_NO_TEMPLATE_TEMPLATES */
Chris@16 152 }
Chris@16 153 }
Chris@16 154
Chris@16 155 #endif /* BOOST_SINHC_HPP */
Chris@16 156