File indexing completed on 2025-01-18 09:57:09
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 #ifndef EIGEN_BESSEL_FUNCTIONS_H
0011 #define EIGEN_BESSEL_FUNCTIONS_H
0012
0013 namespace Eigen {
0014 namespace internal {
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044 template <typename Scalar>
0045 struct bessel_i0e_retval {
0046 typedef Scalar type;
0047 };
0048
0049 template <typename T, typename ScalarType = typename unpacket_traits<T>::type>
0050 struct generic_i0e {
0051 EIGEN_DEVICE_FUNC
0052 static EIGEN_STRONG_INLINE T run(const T&) {
0053 EIGEN_STATIC_ASSERT((internal::is_same<T, T>::value == false),
0054 THIS_TYPE_IS_NOT_SUPPORTED);
0055 return ScalarType(0);
0056 }
0057 };
0058
0059 template <typename T>
0060 struct generic_i0e<T, float> {
0061 EIGEN_DEVICE_FUNC
0062 static EIGEN_STRONG_INLINE T run(const T& x) {
0063
0064
0065
0066
0067
0068
0069
0070
0071
0072
0073
0074
0075
0076
0077
0078
0079
0080
0081
0082
0083
0084
0085
0086
0087
0088
0089
0090
0091
0092
0093
0094
0095
0096 const float A[] = {-1.30002500998624804212E-8f, 6.04699502254191894932E-8f,
0097 -2.67079385394061173391E-7f, 1.11738753912010371815E-6f,
0098 -4.41673835845875056359E-6f, 1.64484480707288970893E-5f,
0099 -5.75419501008210370398E-5f, 1.88502885095841655729E-4f,
0100 -5.76375574538582365885E-4f, 1.63947561694133579842E-3f,
0101 -4.32430999505057594430E-3f, 1.05464603945949983183E-2f,
0102 -2.37374148058994688156E-2f, 4.93052842396707084878E-2f,
0103 -9.49010970480476444210E-2f, 1.71620901522208775349E-1f,
0104 -3.04682672343198398683E-1f, 6.76795274409476084995E-1f};
0105
0106 const float B[] = {3.39623202570838634515E-9f, 2.26666899049817806459E-8f,
0107 2.04891858946906374183E-7f, 2.89137052083475648297E-6f,
0108 6.88975834691682398426E-5f, 3.36911647825569408990E-3f,
0109 8.04490411014108831608E-1f};
0110 T y = pabs(x);
0111 T y_le_eight = internal::pchebevl<T, 18>::run(
0112 pmadd(pset1<T>(0.5f), y, pset1<T>(-2.0f)), A);
0113 T y_gt_eight = pmul(
0114 internal::pchebevl<T, 7>::run(
0115 psub(pdiv(pset1<T>(32.0f), y), pset1<T>(2.0f)), B),
0116 prsqrt(y));
0117
0118
0119
0120 return pselect(pcmp_le(y, pset1<T>(8.0f)), y_le_eight, y_gt_eight);
0121 }
0122 };
0123
0124 template <typename T>
0125 struct generic_i0e<T, double> {
0126 EIGEN_DEVICE_FUNC
0127 static EIGEN_STRONG_INLINE T run(const T& x) {
0128
0129
0130
0131
0132
0133
0134
0135
0136
0137
0138
0139
0140
0141
0142
0143
0144
0145
0146
0147
0148
0149
0150
0151
0152
0153
0154
0155
0156
0157
0158
0159
0160
0161 const double A[] = {-4.41534164647933937950E-18, 3.33079451882223809783E-17,
0162 -2.43127984654795469359E-16, 1.71539128555513303061E-15,
0163 -1.16853328779934516808E-14, 7.67618549860493561688E-14,
0164 -4.85644678311192946090E-13, 2.95505266312963983461E-12,
0165 -1.72682629144155570723E-11, 9.67580903537323691224E-11,
0166 -5.18979560163526290666E-10, 2.65982372468238665035E-9,
0167 -1.30002500998624804212E-8, 6.04699502254191894932E-8,
0168 -2.67079385394061173391E-7, 1.11738753912010371815E-6,
0169 -4.41673835845875056359E-6, 1.64484480707288970893E-5,
0170 -5.75419501008210370398E-5, 1.88502885095841655729E-4,
0171 -5.76375574538582365885E-4, 1.63947561694133579842E-3,
0172 -4.32430999505057594430E-3, 1.05464603945949983183E-2,
0173 -2.37374148058994688156E-2, 4.93052842396707084878E-2,
0174 -9.49010970480476444210E-2, 1.71620901522208775349E-1,
0175 -3.04682672343198398683E-1, 6.76795274409476084995E-1};
0176 const double B[] = {
0177 -7.23318048787475395456E-18, -4.83050448594418207126E-18,
0178 4.46562142029675999901E-17, 3.46122286769746109310E-17,
0179 -2.82762398051658348494E-16, -3.42548561967721913462E-16,
0180 1.77256013305652638360E-15, 3.81168066935262242075E-15,
0181 -9.55484669882830764870E-15, -4.15056934728722208663E-14,
0182 1.54008621752140982691E-14, 3.85277838274214270114E-13,
0183 7.18012445138366623367E-13, -1.79417853150680611778E-12,
0184 -1.32158118404477131188E-11, -3.14991652796324136454E-11,
0185 1.18891471078464383424E-11, 4.94060238822496958910E-10,
0186 3.39623202570838634515E-9, 2.26666899049817806459E-8,
0187 2.04891858946906374183E-7, 2.89137052083475648297E-6,
0188 6.88975834691682398426E-5, 3.36911647825569408990E-3,
0189 8.04490411014108831608E-1};
0190 T y = pabs(x);
0191 T y_le_eight = internal::pchebevl<T, 30>::run(
0192 pmadd(pset1<T>(0.5), y, pset1<T>(-2.0)), A);
0193 T y_gt_eight = pmul(
0194 internal::pchebevl<T, 25>::run(
0195 psub(pdiv(pset1<T>(32.0), y), pset1<T>(2.0)), B),
0196 prsqrt(y));
0197
0198
0199
0200 return pselect(pcmp_le(y, pset1<T>(8.0)), y_le_eight, y_gt_eight);
0201 }
0202 };
0203
0204 template <typename T>
0205 struct bessel_i0e_impl {
0206 EIGEN_DEVICE_FUNC
0207 static EIGEN_STRONG_INLINE T run(const T x) {
0208 return generic_i0e<T>::run(x);
0209 }
0210 };
0211
0212 template <typename Scalar>
0213 struct bessel_i0_retval {
0214 typedef Scalar type;
0215 };
0216
0217 template <typename T, typename ScalarType = typename unpacket_traits<T>::type>
0218 struct generic_i0 {
0219 EIGEN_DEVICE_FUNC
0220 static EIGEN_STRONG_INLINE T run(const T& x) {
0221 return pmul(
0222 pexp(pabs(x)),
0223 generic_i0e<T, ScalarType>::run(x));
0224 }
0225 };
0226
0227 template <typename T>
0228 struct bessel_i0_impl {
0229 EIGEN_DEVICE_FUNC
0230 static EIGEN_STRONG_INLINE T run(const T x) {
0231 return generic_i0<T>::run(x);
0232 }
0233 };
0234
0235 template <typename Scalar>
0236 struct bessel_i1e_retval {
0237 typedef Scalar type;
0238 };
0239
0240 template <typename T, typename ScalarType = typename unpacket_traits<T>::type >
0241 struct generic_i1e {
0242 EIGEN_DEVICE_FUNC
0243 static EIGEN_STRONG_INLINE T run(const T&) {
0244 EIGEN_STATIC_ASSERT((internal::is_same<T, T>::value == false),
0245 THIS_TYPE_IS_NOT_SUPPORTED);
0246 return ScalarType(0);
0247 }
0248 };
0249
0250 template <typename T>
0251 struct generic_i1e<T, float> {
0252 EIGEN_DEVICE_FUNC
0253 static EIGEN_STRONG_INLINE T run(const T& x) {
0254
0255
0256
0257
0258
0259
0260
0261
0262
0263
0264
0265
0266
0267
0268
0269
0270
0271
0272
0273
0274
0275
0276
0277
0278
0279
0280
0281
0282
0283
0284
0285
0286 const float A[] = {9.38153738649577178388E-9f, -4.44505912879632808065E-8f,
0287 2.00329475355213526229E-7f, -8.56872026469545474066E-7f,
0288 3.47025130813767847674E-6f, -1.32731636560394358279E-5f,
0289 4.78156510755005422638E-5f, -1.61760815825896745588E-4f,
0290 5.12285956168575772895E-4f, -1.51357245063125314899E-3f,
0291 4.15642294431288815669E-3f, -1.05640848946261981558E-2f,
0292 2.47264490306265168283E-2f, -5.29459812080949914269E-2f,
0293 1.02643658689847095384E-1f, -1.76416518357834055153E-1f,
0294 2.52587186443633654823E-1f};
0295
0296 const float B[] = {-3.83538038596423702205E-9f, -2.63146884688951950684E-8f,
0297 -2.51223623787020892529E-7f, -3.88256480887769039346E-6f,
0298 -1.10588938762623716291E-4f, -9.76109749136146840777E-3f,
0299 7.78576235018280120474E-1f};
0300
0301
0302 T y = pabs(x);
0303 T y_le_eight = pmul(y, internal::pchebevl<T, 17>::run(
0304 pmadd(pset1<T>(0.5f), y, pset1<T>(-2.0f)), A));
0305 T y_gt_eight = pmul(
0306 internal::pchebevl<T, 7>::run(
0307 psub(pdiv(pset1<T>(32.0f), y),
0308 pset1<T>(2.0f)), B),
0309 prsqrt(y));
0310
0311
0312
0313 y = pselect(pcmp_le(y, pset1<T>(8.0f)), y_le_eight, y_gt_eight);
0314 return pselect(pcmp_lt(x, pset1<T>(0.0f)), pnegate(y), y);
0315 }
0316 };
0317
0318 template <typename T>
0319 struct generic_i1e<T, double> {
0320 EIGEN_DEVICE_FUNC
0321 static EIGEN_STRONG_INLINE T run(const T& x) {
0322
0323
0324
0325
0326
0327
0328
0329
0330
0331
0332
0333
0334
0335
0336
0337
0338
0339
0340
0341
0342
0343
0344
0345
0346
0347
0348
0349
0350
0351
0352
0353
0354 const double A[] = {2.77791411276104639959E-18, -2.11142121435816608115E-17,
0355 1.55363195773620046921E-16, -1.10559694773538630805E-15,
0356 7.60068429473540693410E-15, -5.04218550472791168711E-14,
0357 3.22379336594557470981E-13, -1.98397439776494371520E-12,
0358 1.17361862988909016308E-11, -6.66348972350202774223E-11,
0359 3.62559028155211703701E-10, -1.88724975172282928790E-9,
0360 9.38153738649577178388E-9, -4.44505912879632808065E-8,
0361 2.00329475355213526229E-7, -8.56872026469545474066E-7,
0362 3.47025130813767847674E-6, -1.32731636560394358279E-5,
0363 4.78156510755005422638E-5, -1.61760815825896745588E-4,
0364 5.12285956168575772895E-4, -1.51357245063125314899E-3,
0365 4.15642294431288815669E-3, -1.05640848946261981558E-2,
0366 2.47264490306265168283E-2, -5.29459812080949914269E-2,
0367 1.02643658689847095384E-1, -1.76416518357834055153E-1,
0368 2.52587186443633654823E-1};
0369 const double B[] = {
0370 7.51729631084210481353E-18, 4.41434832307170791151E-18,
0371 -4.65030536848935832153E-17, -3.20952592199342395980E-17,
0372 2.96262899764595013876E-16, 3.30820231092092828324E-16,
0373 -1.88035477551078244854E-15, -3.81440307243700780478E-15,
0374 1.04202769841288027642E-14, 4.27244001671195135429E-14,
0375 -2.10154184277266431302E-14, -4.08355111109219731823E-13,
0376 -7.19855177624590851209E-13, 2.03562854414708950722E-12,
0377 1.41258074366137813316E-11, 3.25260358301548823856E-11,
0378 -1.89749581235054123450E-11, -5.58974346219658380687E-10,
0379 -3.83538038596423702205E-9, -2.63146884688951950684E-8,
0380 -2.51223623787020892529E-7, -3.88256480887769039346E-6,
0381 -1.10588938762623716291E-4, -9.76109749136146840777E-3,
0382 7.78576235018280120474E-1};
0383 T y = pabs(x);
0384 T y_le_eight = pmul(y, internal::pchebevl<T, 29>::run(
0385 pmadd(pset1<T>(0.5), y, pset1<T>(-2.0)), A));
0386 T y_gt_eight = pmul(
0387 internal::pchebevl<T, 25>::run(
0388 psub(pdiv(pset1<T>(32.0), y),
0389 pset1<T>(2.0)), B),
0390 prsqrt(y));
0391
0392
0393
0394 y = pselect(pcmp_le(y, pset1<T>(8.0)), y_le_eight, y_gt_eight);
0395 return pselect(pcmp_lt(x, pset1<T>(0.0)), pnegate(y), y);
0396 }
0397 };
0398
0399 template <typename T>
0400 struct bessel_i1e_impl {
0401 EIGEN_DEVICE_FUNC
0402 static EIGEN_STRONG_INLINE T run(const T x) {
0403 return generic_i1e<T>::run(x);
0404 }
0405 };
0406
0407 template <typename T>
0408 struct bessel_i1_retval {
0409 typedef T type;
0410 };
0411
0412 template <typename T, typename ScalarType = typename unpacket_traits<T>::type>
0413 struct generic_i1 {
0414 EIGEN_DEVICE_FUNC
0415 static EIGEN_STRONG_INLINE T run(const T& x) {
0416 return pmul(
0417 pexp(pabs(x)),
0418 generic_i1e<T, ScalarType>::run(x));
0419 }
0420 };
0421
0422 template <typename T>
0423 struct bessel_i1_impl {
0424 EIGEN_DEVICE_FUNC
0425 static EIGEN_STRONG_INLINE T run(const T x) {
0426 return generic_i1<T>::run(x);
0427 }
0428 };
0429
0430 template <typename T>
0431 struct bessel_k0e_retval {
0432 typedef T type;
0433 };
0434
0435 template <typename T, typename ScalarType = typename unpacket_traits<T>::type>
0436 struct generic_k0e {
0437 EIGEN_DEVICE_FUNC
0438 static EIGEN_STRONG_INLINE T run(const T&) {
0439 EIGEN_STATIC_ASSERT((internal::is_same<T, T>::value == false),
0440 THIS_TYPE_IS_NOT_SUPPORTED);
0441 return ScalarType(0);
0442 }
0443 };
0444
0445 template <typename T>
0446 struct generic_k0e<T, float> {
0447 EIGEN_DEVICE_FUNC
0448 static EIGEN_STRONG_INLINE T run(const T& x) {
0449
0450
0451
0452
0453
0454
0455
0456
0457
0458
0459
0460
0461
0462
0463
0464
0465
0466
0467
0468
0469
0470
0471
0472
0473
0474
0475
0476
0477
0478
0479 const float A[] = {1.90451637722020886025E-9f, 2.53479107902614945675E-7f,
0480 2.28621210311945178607E-5f, 1.26461541144692592338E-3f,
0481 3.59799365153615016266E-2f, 3.44289899924628486886E-1f,
0482 -5.35327393233902768720E-1f};
0483
0484 const float B[] = {-1.69753450938905987466E-9f, 8.57403401741422608519E-9f,
0485 -4.66048989768794782956E-8f, 2.76681363944501510342E-7f,
0486 -1.83175552271911948767E-6f, 1.39498137188764993662E-5f,
0487 -1.28495495816278026384E-4f, 1.56988388573005337491E-3f,
0488 -3.14481013119645005427E-2f, 2.44030308206595545468E0f};
0489 const T MAXNUM = pset1<T>(NumTraits<float>::infinity());
0490 const T two = pset1<T>(2.0);
0491 T x_le_two = internal::pchebevl<T, 7>::run(
0492 pmadd(x, x, pset1<T>(-2.0)), A);
0493 x_le_two = pmadd(
0494 generic_i0<T, float>::run(x), pnegate(
0495 plog(pmul(pset1<T>(0.5), x))), x_le_two);
0496 x_le_two = pmul(pexp(x), x_le_two);
0497 T x_gt_two = pmul(
0498 internal::pchebevl<T, 10>::run(
0499 psub(pdiv(pset1<T>(8.0), x), two), B),
0500 prsqrt(x));
0501 return pselect(
0502 pcmp_le(x, pset1<T>(0.0)),
0503 MAXNUM,
0504 pselect(pcmp_le(x, two), x_le_two, x_gt_two));
0505 }
0506 };
0507
0508 template <typename T>
0509 struct generic_k0e<T, double> {
0510 EIGEN_DEVICE_FUNC
0511 static EIGEN_STRONG_INLINE T run(const T& x) {
0512
0513
0514
0515
0516
0517
0518
0519
0520
0521
0522
0523
0524
0525
0526
0527
0528
0529
0530
0531
0532
0533
0534
0535
0536
0537
0538
0539
0540
0541
0542 const double A[] = {
0543 1.37446543561352307156E-16,
0544 4.25981614279661018399E-14,
0545 1.03496952576338420167E-11,
0546 1.90451637722020886025E-9,
0547 2.53479107902614945675E-7,
0548 2.28621210311945178607E-5,
0549 1.26461541144692592338E-3,
0550 3.59799365153615016266E-2,
0551 3.44289899924628486886E-1,
0552 -5.35327393233902768720E-1};
0553 const double B[] = {
0554 5.30043377268626276149E-18, -1.64758043015242134646E-17,
0555 5.21039150503902756861E-17, -1.67823109680541210385E-16,
0556 5.51205597852431940784E-16, -1.84859337734377901440E-15,
0557 6.34007647740507060557E-15, -2.22751332699166985548E-14,
0558 8.03289077536357521100E-14, -2.98009692317273043925E-13,
0559 1.14034058820847496303E-12, -4.51459788337394416547E-12,
0560 1.85594911495471785253E-11, -7.95748924447710747776E-11,
0561 3.57739728140030116597E-10, -1.69753450938905987466E-9,
0562 8.57403401741422608519E-9, -4.66048989768794782956E-8,
0563 2.76681363944501510342E-7, -1.83175552271911948767E-6,
0564 1.39498137188764993662E-5, -1.28495495816278026384E-4,
0565 1.56988388573005337491E-3, -3.14481013119645005427E-2,
0566 2.44030308206595545468E0
0567 };
0568 const T MAXNUM = pset1<T>(NumTraits<double>::infinity());
0569 const T two = pset1<T>(2.0);
0570 T x_le_two = internal::pchebevl<T, 10>::run(
0571 pmadd(x, x, pset1<T>(-2.0)), A);
0572 x_le_two = pmadd(
0573 generic_i0<T, double>::run(x), pmul(
0574 pset1<T>(-1.0), plog(pmul(pset1<T>(0.5), x))), x_le_two);
0575 x_le_two = pmul(pexp(x), x_le_two);
0576 x_le_two = pselect(pcmp_le(x, pset1<T>(0.0)), MAXNUM, x_le_two);
0577 T x_gt_two = pmul(
0578 internal::pchebevl<T, 25>::run(
0579 psub(pdiv(pset1<T>(8.0), x), two), B),
0580 prsqrt(x));
0581 return pselect(pcmp_le(x, two), x_le_two, x_gt_two);
0582 }
0583 };
0584
0585 template <typename T>
0586 struct bessel_k0e_impl {
0587 EIGEN_DEVICE_FUNC
0588 static EIGEN_STRONG_INLINE T run(const T x) {
0589 return generic_k0e<T>::run(x);
0590 }
0591 };
0592
0593 template <typename T>
0594 struct bessel_k0_retval {
0595 typedef T type;
0596 };
0597
0598 template <typename T, typename ScalarType = typename unpacket_traits<T>::type>
0599 struct generic_k0 {
0600 EIGEN_DEVICE_FUNC
0601 static EIGEN_STRONG_INLINE T run(const T&) {
0602 EIGEN_STATIC_ASSERT((internal::is_same<T, T>::value == false),
0603 THIS_TYPE_IS_NOT_SUPPORTED);
0604 return ScalarType(0);
0605 }
0606 };
0607
0608 template <typename T>
0609 struct generic_k0<T, float> {
0610 EIGEN_DEVICE_FUNC
0611 static EIGEN_STRONG_INLINE T run(const T& x) {
0612
0613
0614
0615
0616
0617
0618
0619
0620
0621
0622
0623
0624
0625
0626
0627
0628
0629
0630
0631
0632
0633
0634
0635
0636
0637
0638
0639
0640
0641
0642
0643
0644
0645
0646
0647
0648
0649
0650
0651 const float A[] = {1.90451637722020886025E-9f, 2.53479107902614945675E-7f,
0652 2.28621210311945178607E-5f, 1.26461541144692592338E-3f,
0653 3.59799365153615016266E-2f, 3.44289899924628486886E-1f,
0654 -5.35327393233902768720E-1f};
0655
0656 const float B[] = {-1.69753450938905987466E-9f, 8.57403401741422608519E-9f,
0657 -4.66048989768794782956E-8f, 2.76681363944501510342E-7f,
0658 -1.83175552271911948767E-6f, 1.39498137188764993662E-5f,
0659 -1.28495495816278026384E-4f, 1.56988388573005337491E-3f,
0660 -3.14481013119645005427E-2f, 2.44030308206595545468E0f};
0661 const T MAXNUM = pset1<T>(NumTraits<float>::infinity());
0662 const T two = pset1<T>(2.0);
0663 T x_le_two = internal::pchebevl<T, 7>::run(
0664 pmadd(x, x, pset1<T>(-2.0)), A);
0665 x_le_two = pmadd(
0666 generic_i0<T, float>::run(x), pnegate(
0667 plog(pmul(pset1<T>(0.5), x))), x_le_two);
0668 x_le_two = pselect(pcmp_le(x, pset1<T>(0.0)), MAXNUM, x_le_two);
0669 T x_gt_two = pmul(
0670 pmul(
0671 pexp(pnegate(x)),
0672 internal::pchebevl<T, 10>::run(
0673 psub(pdiv(pset1<T>(8.0), x), two), B)),
0674 prsqrt(x));
0675 return pselect(pcmp_le(x, two), x_le_two, x_gt_two);
0676 }
0677 };
0678
0679 template <typename T>
0680 struct generic_k0<T, double> {
0681 EIGEN_DEVICE_FUNC
0682 static EIGEN_STRONG_INLINE T run(const T& x) {
0683
0684
0685
0686
0687
0688
0689
0690
0691
0692
0693
0694
0695
0696
0697
0698
0699
0700
0701
0702
0703
0704
0705
0706
0707
0708
0709
0710
0711
0712
0713 const double A[] = {
0714 1.37446543561352307156E-16,
0715 4.25981614279661018399E-14,
0716 1.03496952576338420167E-11,
0717 1.90451637722020886025E-9,
0718 2.53479107902614945675E-7,
0719 2.28621210311945178607E-5,
0720 1.26461541144692592338E-3,
0721 3.59799365153615016266E-2,
0722 3.44289899924628486886E-1,
0723 -5.35327393233902768720E-1};
0724 const double B[] = {
0725 5.30043377268626276149E-18, -1.64758043015242134646E-17,
0726 5.21039150503902756861E-17, -1.67823109680541210385E-16,
0727 5.51205597852431940784E-16, -1.84859337734377901440E-15,
0728 6.34007647740507060557E-15, -2.22751332699166985548E-14,
0729 8.03289077536357521100E-14, -2.98009692317273043925E-13,
0730 1.14034058820847496303E-12, -4.51459788337394416547E-12,
0731 1.85594911495471785253E-11, -7.95748924447710747776E-11,
0732 3.57739728140030116597E-10, -1.69753450938905987466E-9,
0733 8.57403401741422608519E-9, -4.66048989768794782956E-8,
0734 2.76681363944501510342E-7, -1.83175552271911948767E-6,
0735 1.39498137188764993662E-5, -1.28495495816278026384E-4,
0736 1.56988388573005337491E-3, -3.14481013119645005427E-2,
0737 2.44030308206595545468E0
0738 };
0739 const T MAXNUM = pset1<T>(NumTraits<double>::infinity());
0740 const T two = pset1<T>(2.0);
0741 T x_le_two = internal::pchebevl<T, 10>::run(
0742 pmadd(x, x, pset1<T>(-2.0)), A);
0743 x_le_two = pmadd(
0744 generic_i0<T, double>::run(x), pnegate(
0745 plog(pmul(pset1<T>(0.5), x))), x_le_two);
0746 x_le_two = pselect(pcmp_le(x, pset1<T>(0.0)), MAXNUM, x_le_two);
0747 T x_gt_two = pmul(
0748 pmul(
0749 pexp(-x),
0750 internal::pchebevl<T, 25>::run(
0751 psub(pdiv(pset1<T>(8.0), x), two), B)),
0752 prsqrt(x));
0753 return pselect(pcmp_le(x, two), x_le_two, x_gt_two);
0754 }
0755 };
0756
0757 template <typename T>
0758 struct bessel_k0_impl {
0759 EIGEN_DEVICE_FUNC
0760 static EIGEN_STRONG_INLINE T run(const T x) {
0761 return generic_k0<T>::run(x);
0762 }
0763 };
0764
0765 template <typename T>
0766 struct bessel_k1e_retval {
0767 typedef T type;
0768 };
0769
0770 template <typename T, typename ScalarType = typename unpacket_traits<T>::type>
0771 struct generic_k1e {
0772 EIGEN_DEVICE_FUNC
0773 static EIGEN_STRONG_INLINE T run(const T&) {
0774 EIGEN_STATIC_ASSERT((internal::is_same<T, T>::value == false),
0775 THIS_TYPE_IS_NOT_SUPPORTED);
0776 return ScalarType(0);
0777 }
0778 };
0779
0780 template <typename T>
0781 struct generic_k1e<T, float> {
0782 EIGEN_DEVICE_FUNC
0783 static EIGEN_STRONG_INLINE T run(const T& x) {
0784
0785
0786
0787
0788
0789
0790
0791
0792
0793
0794
0795
0796
0797
0798
0799
0800
0801
0802
0803
0804
0805
0806
0807
0808
0809
0810
0811
0812
0813
0814
0815
0816
0817 const float A[] = {-2.21338763073472585583E-8f, -2.43340614156596823496E-6f,
0818 -1.73028895751305206302E-4f, -6.97572385963986435018E-3f,
0819 -1.22611180822657148235E-1f, -3.53155960776544875667E-1f,
0820 1.52530022733894777053E0f};
0821 const float B[] = {2.01504975519703286596E-9f, -1.03457624656780970260E-8f,
0822 5.74108412545004946722E-8f, -3.50196060308781257119E-7f,
0823 2.40648494783721712015E-6f, -1.93619797416608296024E-5f,
0824 1.95215518471351631108E-4f, -2.85781685962277938680E-3f,
0825 1.03923736576817238437E-1f, 2.72062619048444266945E0f};
0826 const T MAXNUM = pset1<T>(NumTraits<float>::infinity());
0827 const T two = pset1<T>(2.0);
0828 T x_le_two = pdiv(internal::pchebevl<T, 7>::run(
0829 pmadd(x, x, pset1<T>(-2.0)), A), x);
0830 x_le_two = pmadd(
0831 generic_i1<T, float>::run(x), plog(pmul(pset1<T>(0.5), x)), x_le_two);
0832 x_le_two = pmul(x_le_two, pexp(x));
0833 x_le_two = pselect(pcmp_le(x, pset1<T>(0.0)), MAXNUM, x_le_two);
0834 T x_gt_two = pmul(
0835 internal::pchebevl<T, 10>::run(
0836 psub(pdiv(pset1<T>(8.0), x), two), B),
0837 prsqrt(x));
0838 return pselect(pcmp_le(x, two), x_le_two, x_gt_two);
0839 }
0840 };
0841
0842 template <typename T>
0843 struct generic_k1e<T, double> {
0844 EIGEN_DEVICE_FUNC
0845 static EIGEN_STRONG_INLINE T run(const T& x) {
0846
0847
0848
0849
0850
0851
0852
0853
0854
0855
0856
0857
0858
0859
0860
0861
0862
0863
0864
0865
0866
0867
0868
0869
0870
0871
0872
0873
0874
0875
0876
0877
0878 const double A[] = {-7.02386347938628759343E-18, -2.42744985051936593393E-15,
0879 -6.66690169419932900609E-13, -1.41148839263352776110E-10,
0880 -2.21338763073472585583E-8, -2.43340614156596823496E-6,
0881 -1.73028895751305206302E-4, -6.97572385963986435018E-3,
0882 -1.22611180822657148235E-1, -3.53155960776544875667E-1,
0883 1.52530022733894777053E0};
0884 const double B[] = {-5.75674448366501715755E-18, 1.79405087314755922667E-17,
0885 -5.68946255844285935196E-17, 1.83809354436663880070E-16,
0886 -6.05704724837331885336E-16, 2.03870316562433424052E-15,
0887 -7.01983709041831346144E-15, 2.47715442448130437068E-14,
0888 -8.97670518232499435011E-14, 3.34841966607842919884E-13,
0889 -1.28917396095102890680E-12, 5.13963967348173025100E-12,
0890 -2.12996783842756842877E-11, 9.21831518760500529508E-11,
0891 -4.19035475934189648750E-10, 2.01504975519703286596E-9,
0892 -1.03457624656780970260E-8, 5.74108412545004946722E-8,
0893 -3.50196060308781257119E-7, 2.40648494783721712015E-6,
0894 -1.93619797416608296024E-5, 1.95215518471351631108E-4,
0895 -2.85781685962277938680E-3, 1.03923736576817238437E-1,
0896 2.72062619048444266945E0};
0897 const T MAXNUM = pset1<T>(NumTraits<double>::infinity());
0898 const T two = pset1<T>(2.0);
0899 T x_le_two = pdiv(internal::pchebevl<T, 11>::run(
0900 pmadd(x, x, pset1<T>(-2.0)), A), x);
0901 x_le_two = pmadd(
0902 generic_i1<T, double>::run(x), plog(pmul(pset1<T>(0.5), x)), x_le_two);
0903 x_le_two = pmul(x_le_two, pexp(x));
0904 x_le_two = pselect(pcmp_le(x, pset1<T>(0.0)), MAXNUM, x_le_two);
0905 T x_gt_two = pmul(
0906 internal::pchebevl<T, 25>::run(
0907 psub(pdiv(pset1<T>(8.0), x), two), B),
0908 prsqrt(x));
0909 return pselect(pcmp_le(x, two), x_le_two, x_gt_two);
0910 }
0911 };
0912
0913 template <typename T>
0914 struct bessel_k1e_impl {
0915 EIGEN_DEVICE_FUNC
0916 static EIGEN_STRONG_INLINE T run(const T x) {
0917 return generic_k1e<T>::run(x);
0918 }
0919 };
0920
0921 template <typename T>
0922 struct bessel_k1_retval {
0923 typedef T type;
0924 };
0925
0926 template <typename T, typename ScalarType = typename unpacket_traits<T>::type>
0927 struct generic_k1 {
0928 EIGEN_DEVICE_FUNC
0929 static EIGEN_STRONG_INLINE T run(const T&) {
0930 EIGEN_STATIC_ASSERT((internal::is_same<T, T>::value == false),
0931 THIS_TYPE_IS_NOT_SUPPORTED);
0932 return ScalarType(0);
0933 }
0934 };
0935
0936 template <typename T>
0937 struct generic_k1<T, float> {
0938 EIGEN_DEVICE_FUNC
0939 static EIGEN_STRONG_INLINE T run(const T& x) {
0940
0941
0942
0943
0944
0945
0946
0947
0948
0949
0950
0951
0952
0953
0954
0955
0956
0957
0958
0959
0960
0961
0962
0963
0964
0965
0966
0967
0968
0969
0970
0971
0972
0973
0974
0975
0976
0977 const float A[] = {-2.21338763073472585583E-8f, -2.43340614156596823496E-6f,
0978 -1.73028895751305206302E-4f, -6.97572385963986435018E-3f,
0979 -1.22611180822657148235E-1f, -3.53155960776544875667E-1f,
0980 1.52530022733894777053E0f};
0981 const float B[] = {2.01504975519703286596E-9f, -1.03457624656780970260E-8f,
0982 5.74108412545004946722E-8f, -3.50196060308781257119E-7f,
0983 2.40648494783721712015E-6f, -1.93619797416608296024E-5f,
0984 1.95215518471351631108E-4f, -2.85781685962277938680E-3f,
0985 1.03923736576817238437E-1f, 2.72062619048444266945E0f};
0986 const T MAXNUM = pset1<T>(NumTraits<float>::infinity());
0987 const T two = pset1<T>(2.0);
0988 T x_le_two = pdiv(internal::pchebevl<T, 7>::run(
0989 pmadd(x, x, pset1<T>(-2.0)), A), x);
0990 x_le_two = pmadd(
0991 generic_i1<T, float>::run(x), plog(pmul(pset1<T>(0.5), x)), x_le_two);
0992 x_le_two = pselect(pcmp_le(x, pset1<T>(0.0)), MAXNUM, x_le_two);
0993 T x_gt_two = pmul(
0994 pexp(pnegate(x)),
0995 pmul(
0996 internal::pchebevl<T, 10>::run(
0997 psub(pdiv(pset1<T>(8.0), x), two), B),
0998 prsqrt(x)));
0999 return pselect(pcmp_le(x, two), x_le_two, x_gt_two);
1000 }
1001 };
1002
1003 template <typename T>
1004 struct generic_k1<T, double> {
1005 EIGEN_DEVICE_FUNC
1006 static EIGEN_STRONG_INLINE T run(const T& x) {
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043 const double A[] = {-7.02386347938628759343E-18, -2.42744985051936593393E-15,
1044 -6.66690169419932900609E-13, -1.41148839263352776110E-10,
1045 -2.21338763073472585583E-8, -2.43340614156596823496E-6,
1046 -1.73028895751305206302E-4, -6.97572385963986435018E-3,
1047 -1.22611180822657148235E-1, -3.53155960776544875667E-1,
1048 1.52530022733894777053E0};
1049 const double B[] = {-5.75674448366501715755E-18, 1.79405087314755922667E-17,
1050 -5.68946255844285935196E-17, 1.83809354436663880070E-16,
1051 -6.05704724837331885336E-16, 2.03870316562433424052E-15,
1052 -7.01983709041831346144E-15, 2.47715442448130437068E-14,
1053 -8.97670518232499435011E-14, 3.34841966607842919884E-13,
1054 -1.28917396095102890680E-12, 5.13963967348173025100E-12,
1055 -2.12996783842756842877E-11, 9.21831518760500529508E-11,
1056 -4.19035475934189648750E-10, 2.01504975519703286596E-9,
1057 -1.03457624656780970260E-8, 5.74108412545004946722E-8,
1058 -3.50196060308781257119E-7, 2.40648494783721712015E-6,
1059 -1.93619797416608296024E-5, 1.95215518471351631108E-4,
1060 -2.85781685962277938680E-3, 1.03923736576817238437E-1,
1061 2.72062619048444266945E0};
1062 const T MAXNUM = pset1<T>(NumTraits<double>::infinity());
1063 const T two = pset1<T>(2.0);
1064 T x_le_two = pdiv(internal::pchebevl<T, 11>::run(
1065 pmadd(x, x, pset1<T>(-2.0)), A), x);
1066 x_le_two = pmadd(
1067 generic_i1<T, double>::run(x), plog(pmul(pset1<T>(0.5), x)), x_le_two);
1068 x_le_two = pselect(pcmp_le(x, pset1<T>(0.0)), MAXNUM, x_le_two);
1069 T x_gt_two = pmul(
1070 pexp(-x),
1071 pmul(
1072 internal::pchebevl<T, 25>::run(
1073 psub(pdiv(pset1<T>(8.0), x), two), B),
1074 prsqrt(x)));
1075 return pselect(pcmp_le(x, two), x_le_two, x_gt_two);
1076 }
1077 };
1078
1079 template <typename T>
1080 struct bessel_k1_impl {
1081 EIGEN_DEVICE_FUNC
1082 static EIGEN_STRONG_INLINE T run(const T x) {
1083 return generic_k1<T>::run(x);
1084 }
1085 };
1086
1087 template <typename T>
1088 struct bessel_j0_retval {
1089 typedef T type;
1090 };
1091
1092 template <typename T, typename ScalarType = typename unpacket_traits<T>::type>
1093 struct generic_j0 {
1094 EIGEN_DEVICE_FUNC
1095 static EIGEN_STRONG_INLINE T run(const T&) {
1096 EIGEN_STATIC_ASSERT((internal::is_same<T, T>::value == false),
1097 THIS_TYPE_IS_NOT_SUPPORTED);
1098 return ScalarType(0);
1099 }
1100 };
1101
1102 template <typename T>
1103 struct generic_j0<T, float> {
1104 EIGEN_DEVICE_FUNC
1105 static EIGEN_STRONG_INLINE T run(const T& x) {
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152 const float JP[] = {-6.068350350393235E-008f, 6.388945720783375E-006f,
1153 -3.969646342510940E-004f, 1.332913422519003E-002f,
1154 -1.729150680240724E-001f};
1155 const float MO[] = {-6.838999669318810E-002f, 1.864949361379502E-001f,
1156 -2.145007480346739E-001f, 1.197549369473540E-001f,
1157 -3.560281861530129E-003f, -4.969382655296620E-002f,
1158 -3.355424622293709E-006f, 7.978845717621440E-001f};
1159 const float PH[] = {3.242077816988247E+001f, -3.630592630518434E+001f,
1160 1.756221482109099E+001f, -4.974978466280903E+000f,
1161 1.001973420681837E+000f, -1.939906941791308E-001f,
1162 6.490598792654666E-002f, -1.249992184872738E-001f};
1163 const T DR1 = pset1<T>(5.78318596294678452118f);
1164 const T NEG_PIO4F = pset1<T>(-0.7853981633974483096f);
1165 T y = pabs(x);
1166 T z = pmul(y, y);
1167 T y_le_two = pselect(
1168 pcmp_lt(y, pset1<T>(1.0e-3f)),
1169 pmadd(z, pset1<T>(-0.25f), pset1<T>(1.0f)),
1170 pmul(psub(z, DR1), internal::ppolevl<T, 4>::run(z, JP)));
1171 T q = pdiv(pset1<T>(1.0f), y);
1172 T w = prsqrt(y);
1173 T p = pmul(w, internal::ppolevl<T, 7>::run(q, MO));
1174 w = pmul(q, q);
1175 T yn = pmadd(q, internal::ppolevl<T, 7>::run(w, PH), NEG_PIO4F);
1176 T y_gt_two = pmul(p, pcos(padd(yn, y)));
1177 return pselect(pcmp_le(y, pset1<T>(2.0)), y_le_two, y_gt_two);
1178 }
1179 };
1180
1181 template <typename T>
1182 struct generic_j0<T, double> {
1183 EIGEN_DEVICE_FUNC
1184 static EIGEN_STRONG_INLINE T run(const T& x) {
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228 const double PP[] = {7.96936729297347051624E-4, 8.28352392107440799803E-2,
1229 1.23953371646414299388E0, 5.44725003058768775090E0,
1230 8.74716500199817011941E0, 5.30324038235394892183E0,
1231 9.99999999999999997821E-1};
1232 const double PQ[] = {9.24408810558863637013E-4, 8.56288474354474431428E-2,
1233 1.25352743901058953537E0, 5.47097740330417105182E0,
1234 8.76190883237069594232E0, 5.30605288235394617618E0,
1235 1.00000000000000000218E0};
1236 const double QP[] = {-1.13663838898469149931E-2, -1.28252718670509318512E0,
1237 -1.95539544257735972385E1, -9.32060152123768231369E1,
1238 -1.77681167980488050595E2, -1.47077505154951170175E2,
1239 -5.14105326766599330220E1, -6.05014350600728481186E0};
1240 const double QQ[] = {1.00000000000000000000E0, 6.43178256118178023184E1,
1241 8.56430025976980587198E2, 3.88240183605401609683E3,
1242 7.24046774195652478189E3, 5.93072701187316984827E3,
1243 2.06209331660327847417E3, 2.42005740240291393179E2};
1244 const double RP[] = {-4.79443220978201773821E9, 1.95617491946556577543E12,
1245 -2.49248344360967716204E14, 9.70862251047306323952E15};
1246 const double RQ[] = {1.00000000000000000000E0, 4.99563147152651017219E2,
1247 1.73785401676374683123E5, 4.84409658339962045305E7,
1248 1.11855537045356834862E10, 2.11277520115489217587E12,
1249 3.10518229857422583814E14, 3.18121955943204943306E16,
1250 1.71086294081043136091E18};
1251 const T DR1 = pset1<T>(5.78318596294678452118E0);
1252 const T DR2 = pset1<T>(3.04712623436620863991E1);
1253 const T SQ2OPI = pset1<T>(7.9788456080286535587989E-1);
1254 const T NEG_PIO4 = pset1<T>(-0.7853981633974483096);
1255
1256 T y = pabs(x);
1257 T z = pmul(y, y);
1258 T y_le_five = pselect(
1259 pcmp_lt(y, pset1<T>(1.0e-5)),
1260 pmadd(z, pset1<T>(-0.25), pset1<T>(1.0)),
1261 pmul(pmul(psub(z, DR1), psub(z, DR2)),
1262 pdiv(internal::ppolevl<T, 3>::run(z, RP),
1263 internal::ppolevl<T, 8>::run(z, RQ))));
1264 T s = pdiv(pset1<T>(25.0), z);
1265 T p = pdiv(
1266 internal::ppolevl<T, 6>::run(s, PP),
1267 internal::ppolevl<T, 6>::run(s, PQ));
1268 T q = pdiv(
1269 internal::ppolevl<T, 7>::run(s, QP),
1270 internal::ppolevl<T, 7>::run(s, QQ));
1271 T yn = padd(y, NEG_PIO4);
1272 T w = pdiv(pset1<T>(-5.0), y);
1273 p = pmadd(p, pcos(yn), pmul(w, pmul(q, psin(yn))));
1274 T y_gt_five = pmul(p, pmul(SQ2OPI, prsqrt(y)));
1275 return pselect(pcmp_le(y, pset1<T>(5.0)), y_le_five, y_gt_five);
1276 }
1277 };
1278
1279 template <typename T>
1280 struct bessel_j0_impl {
1281 EIGEN_DEVICE_FUNC
1282 static EIGEN_STRONG_INLINE T run(const T x) {
1283 return generic_j0<T>::run(x);
1284 }
1285 };
1286
1287 template <typename T>
1288 struct bessel_y0_retval {
1289 typedef T type;
1290 };
1291
1292 template <typename T, typename ScalarType = typename unpacket_traits<T>::type>
1293 struct generic_y0 {
1294 EIGEN_DEVICE_FUNC
1295 static EIGEN_STRONG_INLINE T run(const T&) {
1296 EIGEN_STATIC_ASSERT((internal::is_same<T, T>::value == false),
1297 THIS_TYPE_IS_NOT_SUPPORTED);
1298 return ScalarType(0);
1299 }
1300 };
1301
1302 template <typename T>
1303 struct generic_y0<T, float> {
1304 EIGEN_DEVICE_FUNC
1305 static EIGEN_STRONG_INLINE T run(const T& x) {
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354 const float YP[] = {9.454583683980369E-008f, -9.413212653797057E-006f,
1355 5.344486707214273E-004f, -1.584289289821316E-002f,
1356 1.707584643733568E-001f};
1357 const float MO[] = {-6.838999669318810E-002f, 1.864949361379502E-001f,
1358 -2.145007480346739E-001f, 1.197549369473540E-001f,
1359 -3.560281861530129E-003f, -4.969382655296620E-002f,
1360 -3.355424622293709E-006f, 7.978845717621440E-001f};
1361 const float PH[] = {3.242077816988247E+001f, -3.630592630518434E+001f,
1362 1.756221482109099E+001f, -4.974978466280903E+000f,
1363 1.001973420681837E+000f, -1.939906941791308E-001f,
1364 6.490598792654666E-002f, -1.249992184872738E-001f};
1365 const T YZ1 = pset1<T>(0.43221455686510834878f);
1366 const T TWOOPI = pset1<T>(0.636619772367581343075535f);
1367 const T NEG_PIO4F = pset1<T>(-0.7853981633974483096f);
1368 const T NEG_MAXNUM = pset1<T>(-NumTraits<float>::infinity());
1369 T z = pmul(x, x);
1370 T x_le_two = pmul(TWOOPI, pmul(plog(x), generic_j0<T, float>::run(x)));
1371 x_le_two = pmadd(
1372 psub(z, YZ1), internal::ppolevl<T, 4>::run(z, YP), x_le_two);
1373 x_le_two = pselect(pcmp_le(x, pset1<T>(0.0)), NEG_MAXNUM, x_le_two);
1374 T q = pdiv(pset1<T>(1.0), x);
1375 T w = prsqrt(x);
1376 T p = pmul(w, internal::ppolevl<T, 7>::run(q, MO));
1377 T u = pmul(q, q);
1378 T xn = pmadd(q, internal::ppolevl<T, 7>::run(u, PH), NEG_PIO4F);
1379 T x_gt_two = pmul(p, psin(padd(xn, x)));
1380 return pselect(pcmp_le(x, pset1<T>(2.0)), x_le_two, x_gt_two);
1381 }
1382 };
1383
1384 template <typename T>
1385 struct generic_y0<T, double> {
1386 EIGEN_DEVICE_FUNC
1387 static EIGEN_STRONG_INLINE T run(const T& x) {
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427 const double PP[] = {7.96936729297347051624E-4, 8.28352392107440799803E-2,
1428 1.23953371646414299388E0, 5.44725003058768775090E0,
1429 8.74716500199817011941E0, 5.30324038235394892183E0,
1430 9.99999999999999997821E-1};
1431 const double PQ[] = {9.24408810558863637013E-4, 8.56288474354474431428E-2,
1432 1.25352743901058953537E0, 5.47097740330417105182E0,
1433 8.76190883237069594232E0, 5.30605288235394617618E0,
1434 1.00000000000000000218E0};
1435 const double QP[] = {-1.13663838898469149931E-2, -1.28252718670509318512E0,
1436 -1.95539544257735972385E1, -9.32060152123768231369E1,
1437 -1.77681167980488050595E2, -1.47077505154951170175E2,
1438 -5.14105326766599330220E1, -6.05014350600728481186E0};
1439 const double QQ[] = {1.00000000000000000000E0, 6.43178256118178023184E1,
1440 8.56430025976980587198E2, 3.88240183605401609683E3,
1441 7.24046774195652478189E3, 5.93072701187316984827E3,
1442 2.06209331660327847417E3, 2.42005740240291393179E2};
1443 const double YP[] = {1.55924367855235737965E4, -1.46639295903971606143E7,
1444 5.43526477051876500413E9, -9.82136065717911466409E11,
1445 8.75906394395366999549E13, -3.46628303384729719441E15,
1446 4.42733268572569800351E16, -1.84950800436986690637E16};
1447 const double YQ[] = {1.00000000000000000000E0, 1.04128353664259848412E3,
1448 6.26107330137134956842E5, 2.68919633393814121987E8,
1449 8.64002487103935000337E10, 2.02979612750105546709E13,
1450 3.17157752842975028269E15, 2.50596256172653059228E17};
1451 const T SQ2OPI = pset1<T>(7.9788456080286535587989E-1);
1452 const T TWOOPI = pset1<T>(0.636619772367581343075535);
1453 const T NEG_PIO4 = pset1<T>(-0.7853981633974483096);
1454 const T NEG_MAXNUM = pset1<T>(-NumTraits<double>::infinity());
1455
1456 T z = pmul(x, x);
1457 T x_le_five = pdiv(internal::ppolevl<T, 7>::run(z, YP),
1458 internal::ppolevl<T, 7>::run(z, YQ));
1459 x_le_five = pmadd(
1460 pmul(TWOOPI, plog(x)), generic_j0<T, double>::run(x), x_le_five);
1461 x_le_five = pselect(pcmp_le(x, pset1<T>(0.0)), NEG_MAXNUM, x_le_five);
1462 T s = pdiv(pset1<T>(25.0), z);
1463 T p = pdiv(
1464 internal::ppolevl<T, 6>::run(s, PP),
1465 internal::ppolevl<T, 6>::run(s, PQ));
1466 T q = pdiv(
1467 internal::ppolevl<T, 7>::run(s, QP),
1468 internal::ppolevl<T, 7>::run(s, QQ));
1469 T xn = padd(x, NEG_PIO4);
1470 T w = pdiv(pset1<T>(5.0), x);
1471 p = pmadd(p, psin(xn), pmul(w, pmul(q, pcos(xn))));
1472 T x_gt_five = pmul(p, pmul(SQ2OPI, prsqrt(x)));
1473 return pselect(pcmp_le(x, pset1<T>(5.0)), x_le_five, x_gt_five);
1474 }
1475 };
1476
1477 template <typename T>
1478 struct bessel_y0_impl {
1479 EIGEN_DEVICE_FUNC
1480 static EIGEN_STRONG_INLINE T run(const T x) {
1481 return generic_y0<T>::run(x);
1482 }
1483 };
1484
1485 template <typename T>
1486 struct bessel_j1_retval {
1487 typedef T type;
1488 };
1489
1490 template <typename T, typename ScalarType = typename unpacket_traits<T>::type>
1491 struct generic_j1 {
1492 EIGEN_DEVICE_FUNC
1493 static EIGEN_STRONG_INLINE T run(const T&) {
1494 EIGEN_STATIC_ASSERT((internal::is_same<T, T>::value == false),
1495 THIS_TYPE_IS_NOT_SUPPORTED);
1496 return ScalarType(0);
1497 }
1498 };
1499
1500 template <typename T>
1501 struct generic_j1<T, float> {
1502 EIGEN_DEVICE_FUNC
1503 static EIGEN_STRONG_INLINE T run(const T& x) {
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547 const float JP[] = {-4.878788132172128E-009f, 6.009061827883699E-007f,
1548 -4.541343896997497E-005f, 1.937383947804541E-003f,
1549 -3.405537384615824E-002f};
1550 const float MO1[] = {6.913942741265801E-002f, -2.284801500053359E-001f,
1551 3.138238455499697E-001f, -2.102302420403875E-001f,
1552 5.435364690523026E-003f, 1.493389585089498E-001f,
1553 4.976029650847191E-006f, 7.978845453073848E-001f};
1554 const float PH1[] = {-4.497014141919556E+001f, 5.073465654089319E+001f,
1555 -2.485774108720340E+001f, 7.222973196770240E+000f,
1556 -1.544842782180211E+000f, 3.503787691653334E-001f,
1557 -1.637986776941202E-001f, 3.749989509080821E-001f};
1558 const T Z1 = pset1<T>(1.46819706421238932572E1f);
1559 const T NEG_THPIO4F = pset1<T>(-2.35619449019234492885f);
1560
1561 T y = pabs(x);
1562 T z = pmul(y, y);
1563 T y_le_two = pmul(
1564 psub(z, Z1),
1565 pmul(x, internal::ppolevl<T, 4>::run(z, JP)));
1566 T q = pdiv(pset1<T>(1.0f), y);
1567 T w = prsqrt(y);
1568 T p = pmul(w, internal::ppolevl<T, 7>::run(q, MO1));
1569 w = pmul(q, q);
1570 T yn = pmadd(q, internal::ppolevl<T, 7>::run(w, PH1), NEG_THPIO4F);
1571 T y_gt_two = pmul(p, pcos(padd(yn, y)));
1572
1573
1574 y_gt_two = pselect(
1575 pcmp_lt(x, pset1<T>(0.0f)), pnegate(y_gt_two), y_gt_two);
1576 return pselect(pcmp_le(y, pset1<T>(2.0f)), y_le_two, y_gt_two);
1577 }
1578 };
1579
1580 template <typename T>
1581 struct generic_j1<T, double> {
1582 EIGEN_DEVICE_FUNC
1583 static EIGEN_STRONG_INLINE T run(const T& x) {
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617 const double PP[] = {7.62125616208173112003E-4, 7.31397056940917570436E-2,
1618 1.12719608129684925192E0, 5.11207951146807644818E0,
1619 8.42404590141772420927E0, 5.21451598682361504063E0,
1620 1.00000000000000000254E0};
1621 const double PQ[] = {5.71323128072548699714E-4, 6.88455908754495404082E-2,
1622 1.10514232634061696926E0, 5.07386386128601488557E0,
1623 8.39985554327604159757E0, 5.20982848682361821619E0,
1624 9.99999999999999997461E-1};
1625 const double QP[] = {5.10862594750176621635E-2, 4.98213872951233449420E0,
1626 7.58238284132545283818E1, 3.66779609360150777800E2,
1627 7.10856304998926107277E2, 5.97489612400613639965E2,
1628 2.11688757100572135698E2, 2.52070205858023719784E1};
1629 const double QQ[] = {1.00000000000000000000E0, 7.42373277035675149943E1,
1630 1.05644886038262816351E3, 4.98641058337653607651E3,
1631 9.56231892404756170795E3, 7.99704160447350683650E3,
1632 2.82619278517639096600E3, 3.36093607810698293419E2};
1633 const double RP[] = {-8.99971225705559398224E8, 4.52228297998194034323E11,
1634 -7.27494245221818276015E13, 3.68295732863852883286E15};
1635 const double RQ[] = {1.00000000000000000000E0, 6.20836478118054335476E2,
1636 2.56987256757748830383E5, 8.35146791431949253037E7,
1637 2.21511595479792499675E10, 4.74914122079991414898E12,
1638 7.84369607876235854894E14, 8.95222336184627338078E16,
1639 5.32278620332680085395E18};
1640 const T Z1 = pset1<T>(1.46819706421238932572E1);
1641 const T Z2 = pset1<T>(4.92184563216946036703E1);
1642 const T NEG_THPIO4 = pset1<T>(-2.35619449019234492885);
1643 const T SQ2OPI = pset1<T>(7.9788456080286535587989E-1);
1644 T y = pabs(x);
1645 T z = pmul(y, y);
1646 T y_le_five = pdiv(internal::ppolevl<T, 3>::run(z, RP),
1647 internal::ppolevl<T, 8>::run(z, RQ));
1648 y_le_five = pmul(pmul(pmul(y_le_five, x), psub(z, Z1)), psub(z, Z2));
1649 T s = pdiv(pset1<T>(25.0), z);
1650 T p = pdiv(
1651 internal::ppolevl<T, 6>::run(s, PP),
1652 internal::ppolevl<T, 6>::run(s, PQ));
1653 T q = pdiv(
1654 internal::ppolevl<T, 7>::run(s, QP),
1655 internal::ppolevl<T, 7>::run(s, QQ));
1656 T yn = padd(y, NEG_THPIO4);
1657 T w = pdiv(pset1<T>(-5.0), y);
1658 p = pmadd(p, pcos(yn), pmul(w, pmul(q, psin(yn))));
1659 T y_gt_five = pmul(p, pmul(SQ2OPI, prsqrt(y)));
1660
1661
1662 y_gt_five = pselect(
1663 pcmp_lt(x, pset1<T>(0.0)), pnegate(y_gt_five), y_gt_five);
1664 return pselect(pcmp_le(y, pset1<T>(5.0)), y_le_five, y_gt_five);
1665 }
1666 };
1667
1668 template <typename T>
1669 struct bessel_j1_impl {
1670 EIGEN_DEVICE_FUNC
1671 static EIGEN_STRONG_INLINE T run(const T x) {
1672 return generic_j1<T>::run(x);
1673 }
1674 };
1675
1676 template <typename T>
1677 struct bessel_y1_retval {
1678 typedef T type;
1679 };
1680
1681 template <typename T, typename ScalarType = typename unpacket_traits<T>::type>
1682 struct generic_y1 {
1683 EIGEN_DEVICE_FUNC
1684 static EIGEN_STRONG_INLINE T run(const T&) {
1685 EIGEN_STATIC_ASSERT((internal::is_same<T, T>::value == false),
1686 THIS_TYPE_IS_NOT_SUPPORTED);
1687 return ScalarType(0);
1688 }
1689 };
1690
1691 template <typename T>
1692 struct generic_y1<T, float> {
1693 EIGEN_DEVICE_FUNC
1694 static EIGEN_STRONG_INLINE T run(const T& x) {
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743 const float YP[] = {8.061978323326852E-009f, -9.496460629917016E-007f,
1744 6.719543806674249E-005f, -2.641785726447862E-003f,
1745 4.202369946500099E-002f};
1746 const float MO1[] = {6.913942741265801E-002f, -2.284801500053359E-001f,
1747 3.138238455499697E-001f, -2.102302420403875E-001f,
1748 5.435364690523026E-003f, 1.493389585089498E-001f,
1749 4.976029650847191E-006f, 7.978845453073848E-001f};
1750 const float PH1[] = {-4.497014141919556E+001f, 5.073465654089319E+001f,
1751 -2.485774108720340E+001f, 7.222973196770240E+000f,
1752 -1.544842782180211E+000f, 3.503787691653334E-001f,
1753 -1.637986776941202E-001f, 3.749989509080821E-001f};
1754 const T YO1 = pset1<T>(4.66539330185668857532f);
1755 const T NEG_THPIO4F = pset1<T>(-2.35619449019234492885f);
1756 const T TWOOPI = pset1<T>(0.636619772367581343075535f);
1757 const T NEG_MAXNUM = pset1<T>(-NumTraits<float>::infinity());
1758
1759 T z = pmul(x, x);
1760 T x_le_two = pmul(psub(z, YO1), internal::ppolevl<T, 4>::run(z, YP));
1761 x_le_two = pmadd(
1762 x_le_two, x,
1763 pmul(TWOOPI, pmadd(
1764 generic_j1<T, float>::run(x), plog(x),
1765 pdiv(pset1<T>(-1.0f), x))));
1766 x_le_two = pselect(pcmp_lt(x, pset1<T>(0.0f)), NEG_MAXNUM, x_le_two);
1767
1768 T q = pdiv(pset1<T>(1.0), x);
1769 T w = prsqrt(x);
1770 T p = pmul(w, internal::ppolevl<T, 7>::run(q, MO1));
1771 w = pmul(q, q);
1772 T xn = pmadd(q, internal::ppolevl<T, 7>::run(w, PH1), NEG_THPIO4F);
1773 T x_gt_two = pmul(p, psin(padd(xn, x)));
1774 return pselect(pcmp_le(x, pset1<T>(2.0)), x_le_two, x_gt_two);
1775 }
1776 };
1777
1778 template <typename T>
1779 struct generic_y1<T, double> {
1780 EIGEN_DEVICE_FUNC
1781 static EIGEN_STRONG_INLINE T run(const T& x) {
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818 const double PP[] = {7.62125616208173112003E-4, 7.31397056940917570436E-2,
1819 1.12719608129684925192E0, 5.11207951146807644818E0,
1820 8.42404590141772420927E0, 5.21451598682361504063E0,
1821 1.00000000000000000254E0};
1822 const double PQ[] = {5.71323128072548699714E-4, 6.88455908754495404082E-2,
1823 1.10514232634061696926E0, 5.07386386128601488557E0,
1824 8.39985554327604159757E0, 5.20982848682361821619E0,
1825 9.99999999999999997461E-1};
1826 const double QP[] = {5.10862594750176621635E-2, 4.98213872951233449420E0,
1827 7.58238284132545283818E1, 3.66779609360150777800E2,
1828 7.10856304998926107277E2, 5.97489612400613639965E2,
1829 2.11688757100572135698E2, 2.52070205858023719784E1};
1830 const double QQ[] = {1.00000000000000000000E0, 7.42373277035675149943E1,
1831 1.05644886038262816351E3, 4.98641058337653607651E3,
1832 9.56231892404756170795E3, 7.99704160447350683650E3,
1833 2.82619278517639096600E3, 3.36093607810698293419E2};
1834 const double YP[] = {1.26320474790178026440E9, -6.47355876379160291031E11,
1835 1.14509511541823727583E14, -8.12770255501325109621E15,
1836 2.02439475713594898196E17, -7.78877196265950026825E17};
1837 const double YQ[] = {1.00000000000000000000E0, 5.94301592346128195359E2,
1838 2.35564092943068577943E5, 7.34811944459721705660E7,
1839 1.87601316108706159478E10, 3.88231277496238566008E12,
1840 6.20557727146953693363E14, 6.87141087355300489866E16,
1841 3.97270608116560655612E18};
1842 const T SQ2OPI = pset1<T>(.79788456080286535588);
1843 const T NEG_THPIO4 = pset1<T>(-2.35619449019234492885);
1844 const T TWOOPI = pset1<T>(0.636619772367581343075535);
1845 const T NEG_MAXNUM = pset1<T>(-NumTraits<double>::infinity());
1846
1847 T z = pmul(x, x);
1848 T x_le_five = pdiv(internal::ppolevl<T, 5>::run(z, YP),
1849 internal::ppolevl<T, 8>::run(z, YQ));
1850 x_le_five = pmadd(
1851 x_le_five, x, pmul(
1852 TWOOPI, pmadd(generic_j1<T, double>::run(x), plog(x),
1853 pdiv(pset1<T>(-1.0), x))));
1854
1855 x_le_five = pselect(pcmp_le(x, pset1<T>(0.0)), NEG_MAXNUM, x_le_five);
1856 T s = pdiv(pset1<T>(25.0), z);
1857 T p = pdiv(
1858 internal::ppolevl<T, 6>::run(s, PP),
1859 internal::ppolevl<T, 6>::run(s, PQ));
1860 T q = pdiv(
1861 internal::ppolevl<T, 7>::run(s, QP),
1862 internal::ppolevl<T, 7>::run(s, QQ));
1863 T xn = padd(x, NEG_THPIO4);
1864 T w = pdiv(pset1<T>(5.0), x);
1865 p = pmadd(p, psin(xn), pmul(w, pmul(q, pcos(xn))));
1866 T x_gt_five = pmul(p, pmul(SQ2OPI, prsqrt(x)));
1867 return pselect(pcmp_le(x, pset1<T>(5.0)), x_le_five, x_gt_five);
1868 }
1869 };
1870
1871 template <typename T>
1872 struct bessel_y1_impl {
1873 EIGEN_DEVICE_FUNC
1874 static EIGEN_STRONG_INLINE T run(const T x) {
1875 return generic_y1<T>::run(x);
1876 }
1877 };
1878
1879 }
1880
1881 namespace numext {
1882
1883 template <typename Scalar>
1884 EIGEN_DEVICE_FUNC inline EIGEN_MATHFUNC_RETVAL(bessel_i0, Scalar)
1885 bessel_i0(const Scalar& x) {
1886 return EIGEN_MATHFUNC_IMPL(bessel_i0, Scalar)::run(x);
1887 }
1888
1889 template <typename Scalar>
1890 EIGEN_DEVICE_FUNC inline EIGEN_MATHFUNC_RETVAL(bessel_i0e, Scalar)
1891 bessel_i0e(const Scalar& x) {
1892 return EIGEN_MATHFUNC_IMPL(bessel_i0e, Scalar)::run(x);
1893 }
1894
1895 template <typename Scalar>
1896 EIGEN_DEVICE_FUNC inline EIGEN_MATHFUNC_RETVAL(bessel_i1, Scalar)
1897 bessel_i1(const Scalar& x) {
1898 return EIGEN_MATHFUNC_IMPL(bessel_i1, Scalar)::run(x);
1899 }
1900
1901 template <typename Scalar>
1902 EIGEN_DEVICE_FUNC inline EIGEN_MATHFUNC_RETVAL(bessel_i1e, Scalar)
1903 bessel_i1e(const Scalar& x) {
1904 return EIGEN_MATHFUNC_IMPL(bessel_i1e, Scalar)::run(x);
1905 }
1906
1907 template <typename Scalar>
1908 EIGEN_DEVICE_FUNC inline EIGEN_MATHFUNC_RETVAL(bessel_k0, Scalar)
1909 bessel_k0(const Scalar& x) {
1910 return EIGEN_MATHFUNC_IMPL(bessel_k0, Scalar)::run(x);
1911 }
1912
1913 template <typename Scalar>
1914 EIGEN_DEVICE_FUNC inline EIGEN_MATHFUNC_RETVAL(bessel_k0e, Scalar)
1915 bessel_k0e(const Scalar& x) {
1916 return EIGEN_MATHFUNC_IMPL(bessel_k0e, Scalar)::run(x);
1917 }
1918
1919 template <typename Scalar>
1920 EIGEN_DEVICE_FUNC inline EIGEN_MATHFUNC_RETVAL(bessel_k1, Scalar)
1921 bessel_k1(const Scalar& x) {
1922 return EIGEN_MATHFUNC_IMPL(bessel_k1, Scalar)::run(x);
1923 }
1924
1925 template <typename Scalar>
1926 EIGEN_DEVICE_FUNC inline EIGEN_MATHFUNC_RETVAL(bessel_k1e, Scalar)
1927 bessel_k1e(const Scalar& x) {
1928 return EIGEN_MATHFUNC_IMPL(bessel_k1e, Scalar)::run(x);
1929 }
1930
1931 template <typename Scalar>
1932 EIGEN_DEVICE_FUNC inline EIGEN_MATHFUNC_RETVAL(bessel_j0, Scalar)
1933 bessel_j0(const Scalar& x) {
1934 return EIGEN_MATHFUNC_IMPL(bessel_j0, Scalar)::run(x);
1935 }
1936
1937 template <typename Scalar>
1938 EIGEN_DEVICE_FUNC inline EIGEN_MATHFUNC_RETVAL(bessel_y0, Scalar)
1939 bessel_y0(const Scalar& x) {
1940 return EIGEN_MATHFUNC_IMPL(bessel_y0, Scalar)::run(x);
1941 }
1942
1943 template <typename Scalar>
1944 EIGEN_DEVICE_FUNC inline EIGEN_MATHFUNC_RETVAL(bessel_j1, Scalar)
1945 bessel_j1(const Scalar& x) {
1946 return EIGEN_MATHFUNC_IMPL(bessel_j1, Scalar)::run(x);
1947 }
1948
1949 template <typename Scalar>
1950 EIGEN_DEVICE_FUNC inline EIGEN_MATHFUNC_RETVAL(bessel_y1, Scalar)
1951 bessel_y1(const Scalar& x) {
1952 return EIGEN_MATHFUNC_IMPL(bessel_y1, Scalar)::run(x);
1953 }
1954
1955 }
1956
1957 }
1958
1959 #endif