File indexing completed on 2025-01-18 09:40:01
0001
0002
0003
0004
0005
0006 #ifndef BOOST_MATH_BESSEL_Y1_HPP
0007 #define BOOST_MATH_BESSEL_Y1_HPP
0008
0009 #ifdef _MSC_VER
0010 #pragma once
0011 #pragma warning(push)
0012 #pragma warning(disable:4702)
0013 #endif
0014
0015 #include <boost/math/special_functions/detail/bessel_j1.hpp>
0016 #include <boost/math/constants/constants.hpp>
0017 #include <boost/math/tools/rational.hpp>
0018 #include <boost/math/tools/big_constant.hpp>
0019 #include <boost/math/policies/error_handling.hpp>
0020 #include <boost/math/tools/assert.hpp>
0021
0022 #if defined(__GNUC__) && defined(BOOST_MATH_USE_FLOAT128)
0023
0024
0025
0026
0027
0028
0029 #pragma GCC system_header
0030 #endif
0031
0032
0033
0034
0035
0036 namespace boost { namespace math { namespace detail{
0037
0038 template <typename T, typename Policy>
0039 T bessel_y1(T x, const Policy&);
0040
0041 template <class T, class Policy>
0042 struct bessel_y1_initializer
0043 {
0044 struct init
0045 {
0046 init()
0047 {
0048 do_init();
0049 }
0050 static void do_init()
0051 {
0052 bessel_y1(T(1), Policy());
0053 }
0054 void force_instantiate()const{}
0055 };
0056 static const init initializer;
0057 static void force_instantiate()
0058 {
0059 initializer.force_instantiate();
0060 }
0061 };
0062
0063 template <class T, class Policy>
0064 const typename bessel_y1_initializer<T, Policy>::init bessel_y1_initializer<T, Policy>::initializer;
0065
0066 template <typename T, typename Policy>
0067 T bessel_y1(T x, const Policy& pol)
0068 {
0069 bessel_y1_initializer<T, Policy>::force_instantiate();
0070
0071 static const T P1[] = {
0072 static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, 4.0535726612579544093e+13)),
0073 static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, 5.4708611716525426053e+12)),
0074 static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, -3.7595974497819597599e+11)),
0075 static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, 7.2144548214502560419e+09)),
0076 static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, -5.9157479997408395984e+07)),
0077 static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, 2.2157953222280260820e+05)),
0078 static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, -3.1714424660046133456e+02)),
0079 };
0080 static const T Q1[] = {
0081 static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, 3.0737873921079286084e+14)),
0082 static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, 4.1272286200406461981e+12)),
0083 static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, 2.7800352738690585613e+10)),
0084 static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, 1.2250435122182963220e+08)),
0085 static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, 3.8136470753052572164e+05)),
0086 static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, 8.2079908168393867438e+02)),
0087 static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, 1.0)),
0088 };
0089 static const T P2[] = {
0090 static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, 1.1514276357909013326e+19)),
0091 static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, -5.6808094574724204577e+18)),
0092 static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, -2.3638408497043134724e+16)),
0093 static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, 4.0686275289804744814e+15)),
0094 static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, -5.9530713129741981618e+13)),
0095 static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, 3.7453673962438488783e+11)),
0096 static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, -1.1957961912070617006e+09)),
0097 static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, 1.9153806858264202986e+06)),
0098 static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, -1.2337180442012953128e+03)),
0099 };
0100 static const T Q2[] = {
0101 static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, 5.3321844313316185697e+20)),
0102 static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, 5.6968198822857178911e+18)),
0103 static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, 3.0837179548112881950e+16)),
0104 static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, 1.1187010065856971027e+14)),
0105 static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, 3.0221766852960403645e+11)),
0106 static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, 6.3550318087088919566e+08)),
0107 static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, 1.0453748201934079734e+06)),
0108 static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, 1.2855164849321609336e+03)),
0109 static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, 1.0)),
0110 };
0111 static const T PC[] = {
0112 static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, -4.4357578167941278571e+06)),
0113 static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, -9.9422465050776411957e+06)),
0114 static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, -6.6033732483649391093e+06)),
0115 static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, -1.5235293511811373833e+06)),
0116 static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, -1.0982405543459346727e+05)),
0117 static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, -1.6116166443246101165e+03)),
0118 static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, 0.0)),
0119 };
0120 static const T QC[] = {
0121 static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, -4.4357578167941278568e+06)),
0122 static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, -9.9341243899345856590e+06)),
0123 static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, -6.5853394797230870728e+06)),
0124 static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, -1.5118095066341608816e+06)),
0125 static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, -1.0726385991103820119e+05)),
0126 static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, -1.4550094401904961825e+03)),
0127 static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, 1.0)),
0128 };
0129 static const T PS[] = {
0130 static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, 3.3220913409857223519e+04)),
0131 static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, 8.5145160675335701966e+04)),
0132 static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, 6.6178836581270835179e+04)),
0133 static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, 1.8494262873223866797e+04)),
0134 static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, 1.7063754290207680021e+03)),
0135 static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, 3.5265133846636032186e+01)),
0136 static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, 0.0)),
0137 };
0138 static const T QS[] = {
0139 static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, 7.0871281941028743574e+05)),
0140 static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, 1.8194580422439972989e+06)),
0141 static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, 1.4194606696037208929e+06)),
0142 static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, 4.0029443582266975117e+05)),
0143 static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, 3.7890229745772202641e+04)),
0144 static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, 8.6383677696049909675e+02)),
0145 static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, 1.0)),
0146 };
0147 static const T x1 = static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, 2.1971413260310170351e+00)),
0148 x2 = static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, 5.4296810407941351328e+00)),
0149 x11 = static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, 5.620e+02)),
0150 x12 = static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, 1.8288260310170351490e-03)),
0151 x21 = static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, 1.3900e+03)),
0152 x22 = static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, -6.4592058648672279948e-06))
0153 ;
0154 T value, factor, r, rc, rs;
0155
0156 BOOST_MATH_STD_USING
0157 using namespace boost::math::tools;
0158 using namespace boost::math::constants;
0159
0160 if (x <= 0)
0161 {
0162 return policies::raise_domain_error<T>("boost::math::bessel_y1<%1%>(%1%,%1%)",
0163 "Got x == %1%, but x must be > 0, complex result not supported.", x, pol);
0164 }
0165 if (x <= 4)
0166 {
0167 T y = x * x;
0168 T z = 2 * log(x/x1) * bessel_j1(x) / pi<T>();
0169 r = evaluate_rational(P1, Q1, y);
0170 factor = (x + x1) * ((x - x11/256) - x12) / x;
0171 value = z + factor * r;
0172 }
0173 else if (x <= 8)
0174 {
0175 T y = x * x;
0176 T z = 2 * log(x/x2) * bessel_j1(x) / pi<T>();
0177 r = evaluate_rational(P2, Q2, y);
0178 factor = (x + x2) * ((x - x21/256) - x22) / x;
0179 value = z + factor * r;
0180 }
0181 else
0182 {
0183 T y = 8 / x;
0184 T y2 = y * y;
0185 rc = evaluate_rational(PC, QC, y2);
0186 rs = evaluate_rational(PS, QS, y2);
0187 factor = 1 / (sqrt(x) * root_pi<T>());
0188
0189
0190
0191
0192
0193
0194
0195
0196
0197 T sx = sin(x);
0198 T cx = cos(x);
0199 value = factor * (y * rs * (sx - cx) - rc * (sx + cx));
0200 }
0201
0202 return value;
0203 }
0204
0205 }}}
0206
0207 #ifdef _MSC_VER
0208 #pragma warning(pop)
0209 #endif
0210
0211 #endif
0212