File indexing completed on 2025-01-18 09:40:00
0001
0002
0003
0004
0005
0006
0007 #ifndef BOOST_MATH_BESSEL_K1_HPP
0008 #define BOOST_MATH_BESSEL_K1_HPP
0009
0010 #ifdef _MSC_VER
0011 #pragma once
0012 #pragma warning(push)
0013 #pragma warning(disable:4702)
0014 #endif
0015
0016 #include <boost/math/tools/rational.hpp>
0017 #include <boost/math/tools/big_constant.hpp>
0018 #include <boost/math/policies/error_handling.hpp>
0019 #include <boost/math/tools/assert.hpp>
0020
0021 #if defined(__GNUC__) && defined(BOOST_MATH_USE_FLOAT128)
0022
0023
0024
0025
0026
0027
0028 #pragma GCC system_header
0029 #endif
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044 namespace boost { namespace math { namespace detail{
0045
0046 template <typename T>
0047 T bessel_k1(const T&);
0048
0049 template <class T, class tag>
0050 struct bessel_k1_initializer
0051 {
0052 struct init
0053 {
0054 init()
0055 {
0056 do_init(tag());
0057 }
0058 static void do_init(const std::integral_constant<int, 113>&)
0059 {
0060 bessel_k1(T(0.5));
0061 bessel_k1(T(2));
0062 bessel_k1(T(6));
0063 }
0064 static void do_init(const std::integral_constant<int, 64>&)
0065 {
0066 bessel_k1(T(0.5));
0067 bessel_k1(T(6));
0068 }
0069 template <class U>
0070 static void do_init(const U&) {}
0071 void force_instantiate()const {}
0072 };
0073 static const init initializer;
0074 static void force_instantiate()
0075 {
0076 initializer.force_instantiate();
0077 }
0078 };
0079
0080 template <class T, class tag>
0081 const typename bessel_k1_initializer<T, tag>::init bessel_k1_initializer<T, tag>::initializer;
0082
0083
0084 template <typename T, int N>
0085 inline T bessel_k1_imp(const T&, const std::integral_constant<int, N>&)
0086 {
0087 BOOST_MATH_ASSERT(0);
0088 return 0;
0089 }
0090
0091 template <typename T>
0092 T bessel_k1_imp(const T& x, const std::integral_constant<int, 24>&)
0093 {
0094 BOOST_MATH_STD_USING
0095 if(x <= 1)
0096 {
0097
0098
0099
0100
0101 static const T Y = 8.695471287e-02f;
0102 static const T P[] =
0103 {
0104 -3.621379531e-03f,
0105 7.131781976e-03f,
0106 -1.535278300e-05f
0107 };
0108 static const T Q[] =
0109 {
0110 1.000000000e+00f,
0111 -5.173102701e-02f,
0112 9.203530671e-04f
0113 };
0114
0115 T a = x * x / 4;
0116 a = ((tools::evaluate_rational(P, Q, a) + Y) * a * a + a / 2 + 1) * x / 2;
0117
0118
0119
0120
0121 static const T P2[] =
0122 {
0123 -3.079657469e-01f,
0124 -8.537108913e-02f,
0125 -4.640275408e-03f,
0126 -1.156442414e-04f
0127 };
0128
0129 return tools::evaluate_polynomial(P2, T(x * x)) * x + 1 / x + log(x) * a;
0130 }
0131 else
0132 {
0133
0134
0135
0136
0137 static const T Y = 1.450342178f;
0138 static const T P[] =
0139 {
0140 -1.970280088e-01f,
0141 2.188747807e-02f,
0142 7.270394756e-01f,
0143 2.490678196e-01f
0144 };
0145 static const T Q[] =
0146 {
0147 1.000000000e+00f,
0148 2.274292882e+00f,
0149 9.904984851e-01f,
0150 4.585534549e-02f
0151 };
0152 if(x < tools::log_max_value<T>())
0153 return ((tools::evaluate_rational(P, Q, T(1 / x)) + Y) * exp(-x) / sqrt(x));
0154 else
0155 {
0156 T ex = exp(-x / 2);
0157 return ((tools::evaluate_rational(P, Q, T(1 / x)) + Y) * ex / sqrt(x)) * ex;
0158 }
0159 }
0160 }
0161
0162 template <typename T>
0163 T bessel_k1_imp(const T& x, const std::integral_constant<int, 53>&)
0164 {
0165 BOOST_MATH_STD_USING
0166 if(x <= 1)
0167 {
0168
0169
0170
0171
0172 static const T Y = 8.69547128677368164e-02f;
0173 static const T P[] =
0174 {
0175 -3.62137953440350228e-03,
0176 7.11842087490330300e-03,
0177 1.00302560256614306e-05,
0178 1.77231085381040811e-06
0179 };
0180 static const T Q[] =
0181 {
0182 1.00000000000000000e+00,
0183 -4.80414794429043831e-02,
0184 9.85972641934416525e-04,
0185 -8.91196859397070326e-06
0186 };
0187
0188 T a = x * x / 4;
0189 a = ((tools::evaluate_rational(P, Q, a) + Y) * a * a + a / 2 + 1) * x / 2;
0190
0191
0192
0193
0194
0195
0196 static const T P2[] =
0197 {
0198 -3.07965757829206184e-01,
0199 -7.80929703673074907e-02,
0200 -2.70619343754051620e-03,
0201 -2.49549522229072008e-05
0202 };
0203 static const T Q2[] =
0204 {
0205 1.00000000000000000e+00,
0206 -2.36316836412163098e-02,
0207 2.64524577525962719e-04,
0208 -1.49749618004162787e-06
0209 };
0210
0211 return tools::evaluate_rational(P2, Q2, T(x * x)) * x + 1 / x + log(x) * a;
0212 }
0213 else
0214 {
0215
0216
0217
0218
0219
0220 static const T Y = 1.45034217834472656f;
0221 static const T P[] =
0222 {
0223 -1.97028041029226295e-01,
0224 -2.32408961548087617e+00,
0225 -7.98269784507699938e+00,
0226 -2.39968410774221632e+00,
0227 3.28314043780858713e+01,
0228 5.67713761158496058e+01,
0229 3.30907788466509823e+01,
0230 6.62582288933739787e+00,
0231 3.08851840645286691e-01
0232 };
0233 static const T Q[] =
0234 {
0235 1.00000000000000000e+00,
0236 1.41811409298826118e+01,
0237 7.35979466317556420e+01,
0238 1.77821793937080859e+02,
0239 2.11014501598705982e+02,
0240 1.19425262951064454e+02,
0241 2.88448064302447607e+01,
0242 2.27912927104139732e+00,
0243 2.50358186953478678e-02
0244 };
0245 if(x < tools::log_max_value<T>())
0246 return ((tools::evaluate_rational(P, Q, T(1 / x)) + Y) * exp(-x) / sqrt(x));
0247 else
0248 {
0249 T ex = exp(-x / 2);
0250 return ((tools::evaluate_rational(P, Q, T(1 / x)) + Y) * ex / sqrt(x)) * ex;
0251 }
0252 }
0253 }
0254
0255 template <typename T>
0256 T bessel_k1_imp(const T& x, const std::integral_constant<int, 64>&)
0257 {
0258 BOOST_MATH_STD_USING
0259 if(x <= 1)
0260 {
0261
0262
0263
0264
0265 static const T Y = 8.695471286773681640625e-02f;
0266 static const T P[] =
0267 {
0268 BOOST_MATH_BIG_CONSTANT(T, 64, -3.621379534403483072861e-03),
0269 BOOST_MATH_BIG_CONSTANT(T, 64, 7.102135866103952705932e-03),
0270 BOOST_MATH_BIG_CONSTANT(T, 64, 4.167545240236717601167e-05),
0271 BOOST_MATH_BIG_CONSTANT(T, 64, 2.537484002571894870830e-06),
0272 BOOST_MATH_BIG_CONSTANT(T, 64, 6.603228256820000135990e-09)
0273 };
0274 static const T Q[] =
0275 {
0276 BOOST_MATH_BIG_CONSTANT(T, 64, 1.000000000000000000000e+00),
0277 BOOST_MATH_BIG_CONSTANT(T, 64, -4.354457194045068370363e-02),
0278 BOOST_MATH_BIG_CONSTANT(T, 64, 8.709137201220209072820e-04),
0279 BOOST_MATH_BIG_CONSTANT(T, 64, -9.676151796359590545143e-06),
0280 BOOST_MATH_BIG_CONSTANT(T, 64, 5.162715192766245311659e-08)
0281 };
0282
0283 T a = x * x / 4;
0284 a = ((tools::evaluate_rational(P, Q, a) + Y) * a * a + a / 2 + 1) * x / 2;
0285
0286
0287
0288
0289
0290 static const T P2[] =
0291 {
0292 BOOST_MATH_BIG_CONSTANT(T, 64, -3.079657578292062244054e-01),
0293 BOOST_MATH_BIG_CONSTANT(T, 64, -7.963049154965966503231e-02),
0294 BOOST_MATH_BIG_CONSTANT(T, 64, -3.103277523735639924895e-03),
0295 BOOST_MATH_BIG_CONSTANT(T, 64, -4.023052834702215699504e-05),
0296 BOOST_MATH_BIG_CONSTANT(T, 64, -1.719459155018493821839e-07)
0297 };
0298 static const T Q2[] =
0299 {
0300 BOOST_MATH_BIG_CONSTANT(T, 64, 1.000000000000000000000e+00),
0301 BOOST_MATH_BIG_CONSTANT(T, 64, -1.863917670410152669768e-02),
0302 BOOST_MATH_BIG_CONSTANT(T, 64, 1.699367098849735298090e-04),
0303 BOOST_MATH_BIG_CONSTANT(T, 64, -9.309358790546076298429e-07),
0304 BOOST_MATH_BIG_CONSTANT(T, 64, 2.708893480271612711933e-09)
0305 };
0306
0307 return tools::evaluate_rational(P2, Q2, T(x * x)) * x + 1 / x + log(x) * a;
0308 }
0309 else
0310 {
0311
0312
0313
0314
0315 static const T Y = 1.450342178344726562500e+00f;
0316 static const T P[] =
0317 {
0318 BOOST_MATH_BIG_CONSTANT(T, 64, -1.970280410292263112917e-01),
0319 BOOST_MATH_BIG_CONSTANT(T, 64, -4.058564803062959169322e+00),
0320 BOOST_MATH_BIG_CONSTANT(T, 64, -3.036658174194917777473e+01),
0321 BOOST_MATH_BIG_CONSTANT(T, 64, -9.576825392332820142173e+01),
0322 BOOST_MATH_BIG_CONSTANT(T, 64, -6.706969489248020941949e+01),
0323 BOOST_MATH_BIG_CONSTANT(T, 64, 3.264572499406168221382e+02),
0324 BOOST_MATH_BIG_CONSTANT(T, 64, 8.584972047303151034100e+02),
0325 BOOST_MATH_BIG_CONSTANT(T, 64, 8.422082733280017909550e+02),
0326 BOOST_MATH_BIG_CONSTANT(T, 64, 3.738005441471368178383e+02),
0327 BOOST_MATH_BIG_CONSTANT(T, 64, 7.016938390144121276609e+01),
0328 BOOST_MATH_BIG_CONSTANT(T, 64, 4.319614662598089438939e+00),
0329 BOOST_MATH_BIG_CONSTANT(T, 64, 3.710715864316521856193e-02)
0330 };
0331 static const T Q[] =
0332 {
0333 BOOST_MATH_BIG_CONSTANT(T, 64, 1.000000000000000000000e+00),
0334 BOOST_MATH_BIG_CONSTANT(T, 64, 2.298433045824439052398e+01),
0335 BOOST_MATH_BIG_CONSTANT(T, 64, 2.082047745067709230037e+02),
0336 BOOST_MATH_BIG_CONSTANT(T, 64, 9.662367854250262046592e+02),
0337 BOOST_MATH_BIG_CONSTANT(T, 64, 2.504148628460454004686e+03),
0338 BOOST_MATH_BIG_CONSTANT(T, 64, 3.712730364911389908905e+03),
0339 BOOST_MATH_BIG_CONSTANT(T, 64, 3.108002081150068641112e+03),
0340 BOOST_MATH_BIG_CONSTANT(T, 64, 1.400149940532448553143e+03),
0341 BOOST_MATH_BIG_CONSTANT(T, 64, 3.083303048095846226299e+02),
0342 BOOST_MATH_BIG_CONSTANT(T, 64, 2.748706060530351833346e+01),
0343 BOOST_MATH_BIG_CONSTANT(T, 64, 6.321900849331506946977e-01),
0344 };
0345 if(x < tools::log_max_value<T>())
0346 return ((tools::evaluate_polynomial(P, T(1 / x)) / tools::evaluate_polynomial(Q, T(1 / x)) + Y) * exp(-x) / sqrt(x));
0347 else
0348 {
0349 T ex = exp(-x / 2);
0350 return ((tools::evaluate_polynomial(P, T(1 / x)) / tools::evaluate_polynomial(Q, T(1 / x)) + Y) * ex / sqrt(x)) * ex;
0351 }
0352 }
0353 }
0354
0355 template <typename T>
0356 T bessel_k1_imp(const T& x, const std::integral_constant<int, 113>&)
0357 {
0358 BOOST_MATH_STD_USING
0359 if(x <= 1)
0360 {
0361
0362
0363
0364
0365 static const T Y = 8.695471286773681640625000000000000000e-02f;
0366 static const T P[] =
0367 {
0368 BOOST_MATH_BIG_CONSTANT(T, 113, -3.621379534403483072916666666666595475e-03),
0369 BOOST_MATH_BIG_CONSTANT(T, 113, 7.074117676930975433219826471336547627e-03),
0370 BOOST_MATH_BIG_CONSTANT(T, 113, 9.631337631362776369069668419033041661e-05),
0371 BOOST_MATH_BIG_CONSTANT(T, 113, 3.468935967870048731821071646104412775e-06),
0372 BOOST_MATH_BIG_CONSTANT(T, 113, 2.956705020559599861444492614737168261e-08),
0373 BOOST_MATH_BIG_CONSTANT(T, 113, 2.347140307321161346703214099534250263e-10),
0374 BOOST_MATH_BIG_CONSTANT(T, 113, 5.569608494081482873946791086435679661e-13)
0375 };
0376 static const T Q[] =
0377 {
0378 BOOST_MATH_BIG_CONSTANT(T, 113, 1.000000000000000000000000000000000000e+00),
0379 BOOST_MATH_BIG_CONSTANT(T, 113, -3.580768910152105375615558920428350204e-02),
0380 BOOST_MATH_BIG_CONSTANT(T, 113, 6.197467671701485365363068445534557369e-04),
0381 BOOST_MATH_BIG_CONSTANT(T, 113, -6.707466533308630411966030561446666237e-06),
0382 BOOST_MATH_BIG_CONSTANT(T, 113, 4.846687802282250112624373388491123527e-08),
0383 BOOST_MATH_BIG_CONSTANT(T, 113, -2.248493131151981569517383040323900343e-10),
0384 BOOST_MATH_BIG_CONSTANT(T, 113, 5.319279786372775264555728921709381080e-13)
0385 };
0386
0387 T a = x * x / 4;
0388 a = ((tools::evaluate_rational(P, Q, a) + Y) * a * a + a / 2 + 1) * x / 2;
0389
0390
0391
0392
0393
0394 static const T P2[] =
0395 {
0396 BOOST_MATH_BIG_CONSTANT(T, 113, -3.079657578292062244053600156878870690e-01),
0397 BOOST_MATH_BIG_CONSTANT(T, 113, -8.133183745732467770755578848987414875e-02),
0398 BOOST_MATH_BIG_CONSTANT(T, 113, -3.548968792764174773125420229299431951e-03),
0399 BOOST_MATH_BIG_CONSTANT(T, 113, -5.886125468718182876076972186152445490e-05),
0400 BOOST_MATH_BIG_CONSTANT(T, 113, -4.506712111733707245745396404449639865e-07),
0401 BOOST_MATH_BIG_CONSTANT(T, 113, -1.632502325880313239698965376754406011e-09),
0402 BOOST_MATH_BIG_CONSTANT(T, 113, -2.311973065898784812266544485665624227e-12)
0403 };
0404 static const T Q2[] =
0405 {
0406 BOOST_MATH_BIG_CONSTANT(T, 113, 1.000000000000000000000000000000000000e+00),
0407 BOOST_MATH_BIG_CONSTANT(T, 113, -1.311471216733781016657962995723287450e-02),
0408 BOOST_MATH_BIG_CONSTANT(T, 113, 8.571876054797365417068164018709472969e-05),
0409 BOOST_MATH_BIG_CONSTANT(T, 113, -3.630181215268238731442496851497901293e-07),
0410 BOOST_MATH_BIG_CONSTANT(T, 113, 1.070176111227805048604885986867484807e-09),
0411 BOOST_MATH_BIG_CONSTANT(T, 113, -2.129046580769872602793220056461084761e-12),
0412 BOOST_MATH_BIG_CONSTANT(T, 113, 2.294906469421390890762001971790074432e-15)
0413 };
0414
0415 return tools::evaluate_rational(P2, Q2, T(x * x)) * x + 1 / x + log(x) * a;
0416 }
0417 else if(x < 4)
0418 {
0419
0420
0421 static const T Y = 1.5023040771484375f;
0422 static const T P[] =
0423 {
0424 BOOST_MATH_BIG_CONSTANT(T, 113, -2.489899398329369710528254347931380044e-01),
0425 BOOST_MATH_BIG_CONSTANT(T, 113, -6.819080211203854781858815596508456873e+00),
0426 BOOST_MATH_BIG_CONSTANT(T, 113, -7.599915699069767382647695624952723034e+01),
0427 BOOST_MATH_BIG_CONSTANT(T, 113, -4.450211910821295507926582231071300718e+02),
0428 BOOST_MATH_BIG_CONSTANT(T, 113, -1.451374687870925175794150513723956533e+03),
0429 BOOST_MATH_BIG_CONSTANT(T, 113, -2.405805746895098802803503988539098226e+03),
0430 BOOST_MATH_BIG_CONSTANT(T, 113, -5.638808326778389656403861103277220518e+02),
0431 BOOST_MATH_BIG_CONSTANT(T, 113, 5.513958744081268456191778822780865708e+03),
0432 BOOST_MATH_BIG_CONSTANT(T, 113, 1.121301640926540743072258116122834804e+04),
0433 BOOST_MATH_BIG_CONSTANT(T, 113, 1.080094900175649541266613109971296190e+04),
0434 BOOST_MATH_BIG_CONSTANT(T, 113, 5.896531083639613332407534434915552429e+03),
0435 BOOST_MATH_BIG_CONSTANT(T, 113, 1.856602122319645694042555107114028437e+03),
0436 BOOST_MATH_BIG_CONSTANT(T, 113, 3.237121918853145421414003823957537419e+02),
0437 BOOST_MATH_BIG_CONSTANT(T, 113, 2.842072954561323076230238664623893504e+01),
0438 BOOST_MATH_BIG_CONSTANT(T, 113, 1.039705646510167437971862966128055524e+00),
0439 BOOST_MATH_BIG_CONSTANT(T, 113, 1.008418100718254816100425022904039530e-02)
0440 };
0441 static const T Q[] =
0442 {
0443 BOOST_MATH_BIG_CONSTANT(T, 113, 1.000000000000000000000000000000000000e+00),
0444 BOOST_MATH_BIG_CONSTANT(T, 113, 2.927456835239137986889227412815459529e+01),
0445 BOOST_MATH_BIG_CONSTANT(T, 113, 3.598985593265577043711382994516531273e+02),
0446 BOOST_MATH_BIG_CONSTANT(T, 113, 2.449897377085510281395819892689690579e+03),
0447 BOOST_MATH_BIG_CONSTANT(T, 113, 1.025555887684561913263090023158085327e+04),
0448 BOOST_MATH_BIG_CONSTANT(T, 113, 2.774140447181062463181892531100679195e+04),
0449 BOOST_MATH_BIG_CONSTANT(T, 113, 4.962055507843204417243602332246120418e+04),
0450 BOOST_MATH_BIG_CONSTANT(T, 113, 5.908269326976180183216954452196772931e+04),
0451 BOOST_MATH_BIG_CONSTANT(T, 113, 4.655160454422016855911700790722577942e+04),
0452 BOOST_MATH_BIG_CONSTANT(T, 113, 2.383586885019548163464418964577684608e+04),
0453 BOOST_MATH_BIG_CONSTANT(T, 113, 7.679920375586960324298491662159976419e+03),
0454 BOOST_MATH_BIG_CONSTANT(T, 113, 1.478586421028842906987799049804565008e+03),
0455 BOOST_MATH_BIG_CONSTANT(T, 113, 1.565384974896746094224942654383537090e+02),
0456 BOOST_MATH_BIG_CONSTANT(T, 113, 7.902617937084010911005732488607114511e+00),
0457 BOOST_MATH_BIG_CONSTANT(T, 113, 1.429293010387921526110949911029094926e-01),
0458 BOOST_MATH_BIG_CONSTANT(T, 113, 3.880342607911083143560111853491047663e-04)
0459 };
0460 return ((tools::evaluate_polynomial(P, T(1 / x)) / tools::evaluate_polynomial(Q, T(1 / x)) + Y) * exp(-x) / sqrt(x));
0461 }
0462 else
0463 {
0464
0465
0466
0467
0468 static const T Y = 1.308816909790039062500000000000000000f;
0469 static const T P[] =
0470 {
0471 BOOST_MATH_BIG_CONSTANT(T, 113, -5.550277247453881129211735759447737350e-02),
0472 BOOST_MATH_BIG_CONSTANT(T, 113, -3.485883080219574328217554864956175929e+00),
0473 BOOST_MATH_BIG_CONSTANT(T, 113, -8.903760658131484239300875153154881958e+01),
0474 BOOST_MATH_BIG_CONSTANT(T, 113, -1.144813672213626237418235110712293337e+03),
0475 BOOST_MATH_BIG_CONSTANT(T, 113, -6.498400501156131446691826557494158173e+03),
0476 BOOST_MATH_BIG_CONSTANT(T, 113, 1.573531831870363502604119835922166116e+04),
0477 BOOST_MATH_BIG_CONSTANT(T, 113, 5.417416550054632009958262596048841154e+05),
0478 BOOST_MATH_BIG_CONSTANT(T, 113, 4.271266450613557412825896604269130661e+06),
0479 BOOST_MATH_BIG_CONSTANT(T, 113, 1.898386013314389952534433455681107783e+07),
0480 BOOST_MATH_BIG_CONSTANT(T, 113, 5.353798784656436259250791761023512750e+07),
0481 BOOST_MATH_BIG_CONSTANT(T, 113, 9.839619195427352438957774052763490067e+07),
0482 BOOST_MATH_BIG_CONSTANT(T, 113, 1.169246368651532232388152442538005637e+08),
0483 BOOST_MATH_BIG_CONSTANT(T, 113, 8.696368884166831199967845883371116431e+07),
0484 BOOST_MATH_BIG_CONSTANT(T, 113, 3.810226630422736458064005843327500169e+07),
0485 BOOST_MATH_BIG_CONSTANT(T, 113, 8.854996610560406127438950635716757614e+06),
0486 BOOST_MATH_BIG_CONSTANT(T, 113, 8.981057433937398731355768088809437625e+05),
0487 BOOST_MATH_BIG_CONSTANT(T, 113, 2.519440069856232098711793483639792952e+04)
0488 };
0489 static const T Q[] =
0490 {
0491 BOOST_MATH_BIG_CONSTANT(T, 113, 1.000000000000000000000000000000000000e+00),
0492 BOOST_MATH_BIG_CONSTANT(T, 113, 7.127348248283623146544565916604103560e+01),
0493 BOOST_MATH_BIG_CONSTANT(T, 113, 2.205092684176906740104488180754982065e+03),
0494 BOOST_MATH_BIG_CONSTANT(T, 113, 3.911249195069050636298346469740075758e+04),
0495 BOOST_MATH_BIG_CONSTANT(T, 113, 4.426103406579046249654548481377792614e+05),
0496 BOOST_MATH_BIG_CONSTANT(T, 113, 3.365861555422488771286500241966208541e+06),
0497 BOOST_MATH_BIG_CONSTANT(T, 113, 1.765377714160383676864913709252529840e+07),
0498 BOOST_MATH_BIG_CONSTANT(T, 113, 6.453822726931857253365138260720815246e+07),
0499 BOOST_MATH_BIG_CONSTANT(T, 113, 1.643207885048369990391975749439783892e+08),
0500 BOOST_MATH_BIG_CONSTANT(T, 113, 2.882540678243694621895816336640877878e+08),
0501 BOOST_MATH_BIG_CONSTANT(T, 113, 3.410120808992380266174106812005338148e+08),
0502 BOOST_MATH_BIG_CONSTANT(T, 113, 2.628138016559335882019310900426773027e+08),
0503 BOOST_MATH_BIG_CONSTANT(T, 113, 1.250794693811010646965360198541047961e+08),
0504 BOOST_MATH_BIG_CONSTANT(T, 113, 3.378723408195485594610593014072950078e+07),
0505 BOOST_MATH_BIG_CONSTANT(T, 113, 4.488253856312453816451380319061865560e+06),
0506 BOOST_MATH_BIG_CONSTANT(T, 113, 2.202167197882689873967723350537104582e+05),
0507 BOOST_MATH_BIG_CONSTANT(T, 113, 1.673233230356966539460728211412989843e+03)
0508 };
0509 if(x < tools::log_max_value<T>())
0510 return ((tools::evaluate_polynomial(P, T(1 / x)) / tools::evaluate_polynomial(Q, T(1 / x)) + Y) * exp(-x) / sqrt(x));
0511 else
0512 {
0513 T ex = exp(-x / 2);
0514 return ((tools::evaluate_polynomial(P, T(1 / x)) / tools::evaluate_polynomial(Q, T(1 / x)) + Y) * ex / sqrt(x)) * ex;
0515 }
0516 }
0517 }
0518
0519 template <typename T>
0520 T bessel_k1_imp(const T& x, const std::integral_constant<int, 0>&)
0521 {
0522 if(boost::math::tools::digits<T>() <= 24)
0523 return bessel_k1_imp(x, std::integral_constant<int, 24>());
0524 else if(boost::math::tools::digits<T>() <= 53)
0525 return bessel_k1_imp(x, std::integral_constant<int, 53>());
0526 else if(boost::math::tools::digits<T>() <= 64)
0527 return bessel_k1_imp(x, std::integral_constant<int, 64>());
0528 else if(boost::math::tools::digits<T>() <= 113)
0529 return bessel_k1_imp(x, std::integral_constant<int, 113>());
0530 BOOST_MATH_ASSERT(0);
0531 return 0;
0532 }
0533
0534 template <typename T>
0535 inline T bessel_k1(const T& x)
0536 {
0537 typedef std::integral_constant<int,
0538 ((std::numeric_limits<T>::digits == 0) || (std::numeric_limits<T>::radix != 2)) ?
0539 0 :
0540 std::numeric_limits<T>::digits <= 24 ?
0541 24 :
0542 std::numeric_limits<T>::digits <= 53 ?
0543 53 :
0544 std::numeric_limits<T>::digits <= 64 ?
0545 64 :
0546 std::numeric_limits<T>::digits <= 113 ?
0547 113 : -1
0548 > tag_type;
0549
0550 bessel_k1_initializer<T, tag_type>::force_instantiate();
0551 return bessel_k1_imp(x, tag_type());
0552 }
0553
0554 }}}
0555
0556 #ifdef _MSC_VER
0557 #pragma warning(pop)
0558 #endif
0559
0560 #endif
0561