[230f479] | 1 | /* j0.c |
---|
| 2 | * |
---|
| 3 | * Bessel function of order zero |
---|
| 4 | * |
---|
| 5 | * |
---|
| 6 | * |
---|
| 7 | * SYNOPSIS: |
---|
| 8 | * |
---|
| 9 | * double x, y, j0(); |
---|
| 10 | * |
---|
| 11 | * y = j0( x ); |
---|
| 12 | * |
---|
| 13 | * |
---|
| 14 | * |
---|
| 15 | * DESCRIPTION: |
---|
| 16 | * |
---|
| 17 | * Returns Bessel function of order zero of the argument. |
---|
| 18 | * |
---|
| 19 | * The domain is divided into the intervals [0, 5] and |
---|
| 20 | * (5, infinity). In the first interval the following rational |
---|
| 21 | * approximation is used: |
---|
| 22 | * |
---|
| 23 | * |
---|
| 24 | * 2 2 |
---|
| 25 | * (w - r ) (w - r ) P (w) / Q (w) |
---|
| 26 | * 1 2 3 8 |
---|
| 27 | * |
---|
| 28 | * 2 |
---|
| 29 | * where w = x and the two r's are zeros of the function. |
---|
| 30 | * |
---|
| 31 | * In the second interval, the Hankel asymptotic expansion |
---|
| 32 | * is employed with two rational functions of degree 6/6 |
---|
| 33 | * and 7/7. |
---|
| 34 | * |
---|
| 35 | * |
---|
| 36 | * |
---|
| 37 | * ACCURACY: |
---|
| 38 | * |
---|
| 39 | * Absolute error: |
---|
| 40 | * arithmetic domain # trials peak rms |
---|
| 41 | * DEC 0, 30 10000 4.4e-17 6.3e-18 |
---|
| 42 | * IEEE 0, 30 60000 4.2e-16 1.1e-16 |
---|
| 43 | * |
---|
| 44 | */ |
---|
| 45 | /* y0.c |
---|
| 46 | * |
---|
| 47 | * Bessel function of the second kind, order zero |
---|
| 48 | * |
---|
| 49 | * |
---|
| 50 | * |
---|
| 51 | * SYNOPSIS: |
---|
| 52 | * |
---|
| 53 | * double x, y, y0(); |
---|
| 54 | * |
---|
| 55 | * y = y0( x ); |
---|
| 56 | * |
---|
| 57 | * |
---|
| 58 | * |
---|
| 59 | * DESCRIPTION: |
---|
| 60 | * |
---|
| 61 | * Returns Bessel function of the second kind, of order |
---|
| 62 | * zero, of the argument. |
---|
| 63 | * |
---|
| 64 | * The domain is divided into the intervals [0, 5] and |
---|
| 65 | * (5, infinity). In the first interval a rational approximation |
---|
| 66 | * R(x) is employed to compute |
---|
| 67 | * y0(x) = R(x) + 2 * log(x) * j0(x) / PI. |
---|
| 68 | * Thus a call to j0() is required. |
---|
| 69 | * |
---|
| 70 | * In the second interval, the Hankel asymptotic expansion |
---|
| 71 | * is employed with two rational functions of degree 6/6 |
---|
| 72 | * and 7/7. |
---|
| 73 | * |
---|
| 74 | * |
---|
| 75 | * |
---|
| 76 | * ACCURACY: |
---|
| 77 | * |
---|
| 78 | * Absolute error, when y0(x) < 1; else relative error: |
---|
| 79 | * |
---|
| 80 | * arithmetic domain # trials peak rms |
---|
| 81 | * DEC 0, 30 9400 7.0e-17 7.9e-18 |
---|
| 82 | * IEEE 0, 30 30000 1.3e-15 1.6e-16 |
---|
| 83 | * |
---|
| 84 | */ |
---|
| 85 | |
---|
| 86 | /* |
---|
| 87 | Cephes Math Library Release 2.8: June, 2000 |
---|
| 88 | Copyright 1984, 1987, 1989, 2000 by Stephen L. Moshier |
---|
| 89 | */ |
---|
| 90 | |
---|
| 91 | /* Note: all coefficients satisfy the relative error criterion |
---|
| 92 | * except YP, YQ which are designed for absolute error. */ |
---|
| 93 | |
---|
| 94 | #include "mconf.h" |
---|
| 95 | |
---|
| 96 | #ifdef UNK |
---|
| 97 | static double PP[7] = { |
---|
| 98 | 7.96936729297347051624E-4, |
---|
| 99 | 8.28352392107440799803E-2, |
---|
| 100 | 1.23953371646414299388E0, |
---|
| 101 | 5.44725003058768775090E0, |
---|
| 102 | 8.74716500199817011941E0, |
---|
| 103 | 5.30324038235394892183E0, |
---|
| 104 | 9.99999999999999997821E-1, |
---|
| 105 | }; |
---|
| 106 | static double PQ[7] = { |
---|
| 107 | 9.24408810558863637013E-4, |
---|
| 108 | 8.56288474354474431428E-2, |
---|
| 109 | 1.25352743901058953537E0, |
---|
| 110 | 5.47097740330417105182E0, |
---|
| 111 | 8.76190883237069594232E0, |
---|
| 112 | 5.30605288235394617618E0, |
---|
| 113 | 1.00000000000000000218E0, |
---|
| 114 | }; |
---|
| 115 | #endif |
---|
| 116 | #ifdef DEC |
---|
| 117 | static unsigned short PP[28] = { |
---|
| 118 | 0035520,0164604,0140733,0054470, |
---|
| 119 | 0037251,0122605,0115356,0107170, |
---|
| 120 | 0040236,0124412,0071500,0056303, |
---|
| 121 | 0040656,0047737,0045720,0045263, |
---|
| 122 | 0041013,0172143,0045004,0142103, |
---|
| 123 | 0040651,0132045,0026241,0026406, |
---|
| 124 | 0040200,0000000,0000000,0000000, |
---|
| 125 | }; |
---|
| 126 | static unsigned short PQ[28] = { |
---|
| 127 | 0035562,0052006,0070034,0134666, |
---|
| 128 | 0037257,0057055,0055242,0123424, |
---|
| 129 | 0040240,0071626,0046630,0032371, |
---|
| 130 | 0040657,0011077,0032013,0012731, |
---|
| 131 | 0041014,0030307,0050331,0006414, |
---|
| 132 | 0040651,0145457,0065021,0150304, |
---|
| 133 | 0040200,0000000,0000000,0000000, |
---|
| 134 | }; |
---|
| 135 | #endif |
---|
| 136 | #ifdef IBMPC |
---|
| 137 | static unsigned short PP[28] = { |
---|
| 138 | 0x6b27,0x983b,0x1d30,0x3f4a, |
---|
| 139 | 0xd1cf,0xb35d,0x34b0,0x3fb5, |
---|
| 140 | 0x0b98,0x4e68,0xd521,0x3ff3, |
---|
| 141 | 0x0956,0xe97a,0xc9fb,0x4015, |
---|
| 142 | 0x9888,0x6940,0x7e8c,0x4021, |
---|
| 143 | 0x25a1,0xa594,0x3684,0x4015, |
---|
| 144 | 0x0000,0x0000,0x0000,0x3ff0, |
---|
| 145 | }; |
---|
| 146 | static unsigned short PQ[28] = { |
---|
| 147 | 0x9737,0xce03,0x4a80,0x3f4e, |
---|
| 148 | 0x54e3,0xab54,0xebc5,0x3fb5, |
---|
| 149 | 0x069f,0xc9b3,0x0e72,0x3ff4, |
---|
| 150 | 0x62bb,0xe681,0xe247,0x4015, |
---|
| 151 | 0x21a1,0xea1b,0x8618,0x4021, |
---|
| 152 | 0x3a19,0xed42,0x3965,0x4015, |
---|
| 153 | 0x0000,0x0000,0x0000,0x3ff0, |
---|
| 154 | }; |
---|
| 155 | #endif |
---|
| 156 | #ifdef MIEEE |
---|
| 157 | static unsigned short PP[28] = { |
---|
| 158 | 0x3f4a,0x1d30,0x983b,0x6b27, |
---|
| 159 | 0x3fb5,0x34b0,0xb35d,0xd1cf, |
---|
| 160 | 0x3ff3,0xd521,0x4e68,0x0b98, |
---|
| 161 | 0x4015,0xc9fb,0xe97a,0x0956, |
---|
| 162 | 0x4021,0x7e8c,0x6940,0x9888, |
---|
| 163 | 0x4015,0x3684,0xa594,0x25a1, |
---|
| 164 | 0x3ff0,0x0000,0x0000,0x0000, |
---|
| 165 | }; |
---|
| 166 | static unsigned short PQ[28] = { |
---|
| 167 | 0x3f4e,0x4a80,0xce03,0x9737, |
---|
| 168 | 0x3fb5,0xebc5,0xab54,0x54e3, |
---|
| 169 | 0x3ff4,0x0e72,0xc9b3,0x069f, |
---|
| 170 | 0x4015,0xe247,0xe681,0x62bb, |
---|
| 171 | 0x4021,0x8618,0xea1b,0x21a1, |
---|
| 172 | 0x4015,0x3965,0xed42,0x3a19, |
---|
| 173 | 0x3ff0,0x0000,0x0000,0x0000, |
---|
| 174 | }; |
---|
| 175 | #endif |
---|
| 176 | |
---|
| 177 | #ifdef UNK |
---|
| 178 | static double QP[8] = { |
---|
| 179 | -1.13663838898469149931E-2, |
---|
| 180 | -1.28252718670509318512E0, |
---|
| 181 | -1.95539544257735972385E1, |
---|
| 182 | -9.32060152123768231369E1, |
---|
| 183 | -1.77681167980488050595E2, |
---|
| 184 | -1.47077505154951170175E2, |
---|
| 185 | -5.14105326766599330220E1, |
---|
| 186 | -6.05014350600728481186E0, |
---|
| 187 | }; |
---|
| 188 | static double QQ[7] = { |
---|
| 189 | /* 1.00000000000000000000E0,*/ |
---|
| 190 | 6.43178256118178023184E1, |
---|
| 191 | 8.56430025976980587198E2, |
---|
| 192 | 3.88240183605401609683E3, |
---|
| 193 | 7.24046774195652478189E3, |
---|
| 194 | 5.93072701187316984827E3, |
---|
| 195 | 2.06209331660327847417E3, |
---|
| 196 | 2.42005740240291393179E2, |
---|
| 197 | }; |
---|
| 198 | #endif |
---|
| 199 | #ifdef DEC |
---|
| 200 | static unsigned short QP[32] = { |
---|
| 201 | 0136472,0035021,0142451,0141115, |
---|
| 202 | 0140244,0024731,0150620,0105642, |
---|
| 203 | 0141234,0067177,0124161,0060141, |
---|
| 204 | 0141672,0064572,0151557,0043036, |
---|
| 205 | 0142061,0127141,0003127,0043517, |
---|
| 206 | 0142023,0011727,0060271,0144544, |
---|
| 207 | 0141515,0122142,0126620,0143150, |
---|
| 208 | 0140701,0115306,0106715,0007344, |
---|
| 209 | }; |
---|
| 210 | static unsigned short QQ[28] = { |
---|
| 211 | /*0040200,0000000,0000000,0000000,*/ |
---|
| 212 | 0041600,0121272,0004741,0026544, |
---|
| 213 | 0042526,0015605,0105654,0161771, |
---|
| 214 | 0043162,0123155,0165644,0062645, |
---|
| 215 | 0043342,0041675,0167576,0130756, |
---|
| 216 | 0043271,0052720,0165631,0154214, |
---|
| 217 | 0043000,0160576,0034614,0172024, |
---|
| 218 | 0042162,0000570,0030500,0051235, |
---|
| 219 | }; |
---|
| 220 | #endif |
---|
| 221 | #ifdef IBMPC |
---|
| 222 | static unsigned short QP[32] = { |
---|
| 223 | 0x384a,0x38a5,0x4742,0xbf87, |
---|
| 224 | 0x1174,0x3a32,0x853b,0xbff4, |
---|
| 225 | 0x2c0c,0xf50e,0x8dcf,0xc033, |
---|
| 226 | 0xe8c4,0x5a6d,0x4d2f,0xc057, |
---|
| 227 | 0xe8ea,0x20ca,0x35cc,0xc066, |
---|
| 228 | 0x392d,0xec17,0x627a,0xc062, |
---|
| 229 | 0x18cd,0x55b2,0xb48c,0xc049, |
---|
| 230 | 0xa1dd,0xd1b9,0x3358,0xc018, |
---|
| 231 | }; |
---|
| 232 | static unsigned short QQ[28] = { |
---|
| 233 | /*0x0000,0x0000,0x0000,0x3ff0,*/ |
---|
| 234 | 0x25ac,0x413c,0x1457,0x4050, |
---|
| 235 | 0x9c7f,0xb175,0xc370,0x408a, |
---|
| 236 | 0x8cb5,0xbd74,0x54cd,0x40ae, |
---|
| 237 | 0xd63e,0xbdef,0x4877,0x40bc, |
---|
| 238 | 0x3b11,0x1d73,0x2aba,0x40b7, |
---|
| 239 | 0x9e82,0xc731,0x1c2f,0x40a0, |
---|
| 240 | 0x0a54,0x0628,0x402f,0x406e, |
---|
| 241 | }; |
---|
| 242 | #endif |
---|
| 243 | #ifdef MIEEE |
---|
| 244 | static unsigned short QP[32] = { |
---|
| 245 | 0xbf87,0x4742,0x38a5,0x384a, |
---|
| 246 | 0xbff4,0x853b,0x3a32,0x1174, |
---|
| 247 | 0xc033,0x8dcf,0xf50e,0x2c0c, |
---|
| 248 | 0xc057,0x4d2f,0x5a6d,0xe8c4, |
---|
| 249 | 0xc066,0x35cc,0x20ca,0xe8ea, |
---|
| 250 | 0xc062,0x627a,0xec17,0x392d, |
---|
| 251 | 0xc049,0xb48c,0x55b2,0x18cd, |
---|
| 252 | 0xc018,0x3358,0xd1b9,0xa1dd, |
---|
| 253 | }; |
---|
| 254 | static unsigned short QQ[28] = { |
---|
| 255 | /*0x3ff0,0x0000,0x0000,0x0000,*/ |
---|
| 256 | 0x4050,0x1457,0x413c,0x25ac, |
---|
| 257 | 0x408a,0xc370,0xb175,0x9c7f, |
---|
| 258 | 0x40ae,0x54cd,0xbd74,0x8cb5, |
---|
| 259 | 0x40bc,0x4877,0xbdef,0xd63e, |
---|
| 260 | 0x40b7,0x2aba,0x1d73,0x3b11, |
---|
| 261 | 0x40a0,0x1c2f,0xc731,0x9e82, |
---|
| 262 | 0x406e,0x402f,0x0628,0x0a54, |
---|
| 263 | }; |
---|
| 264 | #endif |
---|
| 265 | |
---|
| 266 | |
---|
| 267 | #ifdef UNK |
---|
| 268 | static double YP[8] = { |
---|
| 269 | 1.55924367855235737965E4, |
---|
| 270 | -1.46639295903971606143E7, |
---|
| 271 | 5.43526477051876500413E9, |
---|
| 272 | -9.82136065717911466409E11, |
---|
| 273 | 8.75906394395366999549E13, |
---|
| 274 | -3.46628303384729719441E15, |
---|
| 275 | 4.42733268572569800351E16, |
---|
| 276 | -1.84950800436986690637E16, |
---|
| 277 | }; |
---|
| 278 | static double YQ[7] = { |
---|
| 279 | /* 1.00000000000000000000E0,*/ |
---|
| 280 | 1.04128353664259848412E3, |
---|
| 281 | 6.26107330137134956842E5, |
---|
| 282 | 2.68919633393814121987E8, |
---|
| 283 | 8.64002487103935000337E10, |
---|
| 284 | 2.02979612750105546709E13, |
---|
| 285 | 3.17157752842975028269E15, |
---|
| 286 | 2.50596256172653059228E17, |
---|
| 287 | }; |
---|
| 288 | #endif |
---|
| 289 | #ifdef DEC |
---|
| 290 | static unsigned short YP[32] = { |
---|
| 291 | 0043563,0120677,0042264,0046166, |
---|
| 292 | 0146137,0140371,0113444,0042260, |
---|
| 293 | 0050241,0175707,0100502,0063344, |
---|
| 294 | 0152144,0125737,0007265,0164526, |
---|
| 295 | 0053637,0051621,0163035,0060546, |
---|
| 296 | 0155105,0004416,0107306,0060023, |
---|
| 297 | 0056035,0045133,0030132,0000024, |
---|
| 298 | 0155603,0065132,0144061,0131732, |
---|
| 299 | }; |
---|
| 300 | static unsigned short YQ[28] = { |
---|
| 301 | /*0040200,0000000,0000000,0000000,*/ |
---|
| 302 | 0042602,0024422,0135557,0162663, |
---|
| 303 | 0045030,0155665,0044075,0160135, |
---|
| 304 | 0047200,0035432,0105446,0104005, |
---|
| 305 | 0051240,0167331,0056063,0022743, |
---|
| 306 | 0053223,0127746,0025764,0012160, |
---|
| 307 | 0055064,0044206,0177532,0145545, |
---|
| 308 | 0056536,0111375,0163715,0127201, |
---|
| 309 | }; |
---|
| 310 | #endif |
---|
| 311 | #ifdef IBMPC |
---|
| 312 | static unsigned short YP[32] = { |
---|
| 313 | 0x898f,0xe896,0x7437,0x40ce, |
---|
| 314 | 0x8896,0x32e4,0xf81f,0xc16b, |
---|
| 315 | 0x4cdd,0xf028,0x3f78,0x41f4, |
---|
| 316 | 0xbd2b,0xe1d6,0x957b,0xc26c, |
---|
| 317 | 0xac2d,0x3cc3,0xea72,0x42d3, |
---|
| 318 | 0xcc02,0xd1d8,0xa121,0xc328, |
---|
| 319 | 0x4003,0x660b,0xa94b,0x4363, |
---|
| 320 | 0x367b,0x5906,0x6d4b,0xc350, |
---|
| 321 | }; |
---|
| 322 | static unsigned short YQ[28] = { |
---|
| 323 | /*0x0000,0x0000,0x0000,0x3ff0,*/ |
---|
| 324 | 0xfcb6,0x576d,0x4522,0x4090, |
---|
| 325 | 0xbc0c,0xa907,0x1b76,0x4123, |
---|
| 326 | 0xd101,0x5164,0x0763,0x41b0, |
---|
| 327 | 0x64bc,0x2b86,0x1ddb,0x4234, |
---|
| 328 | 0x828e,0xc57e,0x75fc,0x42b2, |
---|
| 329 | 0x596d,0xdfeb,0x8910,0x4326, |
---|
| 330 | 0xb5d0,0xbcf9,0xd25f,0x438b, |
---|
| 331 | }; |
---|
| 332 | #endif |
---|
| 333 | #ifdef MIEEE |
---|
| 334 | static unsigned short YP[32] = { |
---|
| 335 | 0x40ce,0x7437,0xe896,0x898f, |
---|
| 336 | 0xc16b,0xf81f,0x32e4,0x8896, |
---|
| 337 | 0x41f4,0x3f78,0xf028,0x4cdd, |
---|
| 338 | 0xc26c,0x957b,0xe1d6,0xbd2b, |
---|
| 339 | 0x42d3,0xea72,0x3cc3,0xac2d, |
---|
| 340 | 0xc328,0xa121,0xd1d8,0xcc02, |
---|
| 341 | 0x4363,0xa94b,0x660b,0x4003, |
---|
| 342 | 0xc350,0x6d4b,0x5906,0x367b, |
---|
| 343 | }; |
---|
| 344 | static unsigned short YQ[28] = { |
---|
| 345 | /*0x3ff0,0x0000,0x0000,0x0000,*/ |
---|
| 346 | 0x4090,0x4522,0x576d,0xfcb6, |
---|
| 347 | 0x4123,0x1b76,0xa907,0xbc0c, |
---|
| 348 | 0x41b0,0x0763,0x5164,0xd101, |
---|
| 349 | 0x4234,0x1ddb,0x2b86,0x64bc, |
---|
| 350 | 0x42b2,0x75fc,0xc57e,0x828e, |
---|
| 351 | 0x4326,0x8910,0xdfeb,0x596d, |
---|
| 352 | 0x438b,0xd25f,0xbcf9,0xb5d0, |
---|
| 353 | }; |
---|
| 354 | #endif |
---|
| 355 | |
---|
| 356 | #ifdef UNK |
---|
| 357 | /* 5.783185962946784521175995758455807035071 */ |
---|
| 358 | static double DR1 = 5.78318596294678452118E0; |
---|
| 359 | /* 30.47126234366208639907816317502275584842 */ |
---|
| 360 | static double DR2 = 3.04712623436620863991E1; |
---|
| 361 | #endif |
---|
| 362 | |
---|
| 363 | #ifdef DEC |
---|
| 364 | static unsigned short R1[] = {0040671,0007734,0001061,0056734}; |
---|
| 365 | #define DR1 *(double *)R1 |
---|
| 366 | static unsigned short R2[] = {0041363,0142445,0030416,0165567}; |
---|
| 367 | #define DR2 *(double *)R2 |
---|
| 368 | #endif |
---|
| 369 | |
---|
| 370 | #ifdef IBMPC |
---|
| 371 | static unsigned short R1[] = {0x2bbb,0x8046,0x21fb,0x4017}; |
---|
| 372 | #define DR1 *(double *)R1 |
---|
| 373 | static unsigned short R2[] = {0xdd6f,0xa621,0x78a4,0x403e}; |
---|
| 374 | #define DR2 *(double *)R2 |
---|
| 375 | #endif |
---|
| 376 | |
---|
| 377 | #ifdef MIEEE |
---|
| 378 | static unsigned short R1[] = {0x4017,0x21fb,0x8046,0x2bbb}; |
---|
| 379 | #define DR1 *(double *)R1 |
---|
| 380 | static unsigned short R2[] = {0x403e,0x78a4,0xa621,0xdd6f}; |
---|
| 381 | #define DR2 *(double *)R2 |
---|
| 382 | #endif |
---|
| 383 | |
---|
| 384 | #ifdef UNK |
---|
| 385 | static double RP[4] = { |
---|
| 386 | -4.79443220978201773821E9, |
---|
| 387 | 1.95617491946556577543E12, |
---|
| 388 | -2.49248344360967716204E14, |
---|
| 389 | 9.70862251047306323952E15, |
---|
| 390 | }; |
---|
| 391 | static double RQ[8] = { |
---|
| 392 | /* 1.00000000000000000000E0,*/ |
---|
| 393 | 4.99563147152651017219E2, |
---|
| 394 | 1.73785401676374683123E5, |
---|
| 395 | 4.84409658339962045305E7, |
---|
| 396 | 1.11855537045356834862E10, |
---|
| 397 | 2.11277520115489217587E12, |
---|
| 398 | 3.10518229857422583814E14, |
---|
| 399 | 3.18121955943204943306E16, |
---|
| 400 | 1.71086294081043136091E18, |
---|
| 401 | }; |
---|
| 402 | #endif |
---|
| 403 | #ifdef DEC |
---|
| 404 | static unsigned short RP[16] = { |
---|
| 405 | 0150216,0161235,0064344,0014450, |
---|
| 406 | 0052343,0135216,0035624,0144153, |
---|
| 407 | 0154142,0130247,0003310,0003667, |
---|
| 408 | 0055411,0173703,0047772,0176635, |
---|
| 409 | }; |
---|
| 410 | static unsigned short RQ[32] = { |
---|
| 411 | /*0040200,0000000,0000000,0000000,*/ |
---|
| 412 | 0042371,0144025,0032265,0136137, |
---|
| 413 | 0044451,0133131,0132420,0151466, |
---|
| 414 | 0046470,0144641,0072540,0030636, |
---|
| 415 | 0050446,0126600,0045042,0044243, |
---|
| 416 | 0052365,0172633,0110301,0071063, |
---|
| 417 | 0054215,0032424,0062272,0043513, |
---|
| 418 | 0055742,0005013,0171731,0072335, |
---|
| 419 | 0057275,0170646,0036663,0013134, |
---|
| 420 | }; |
---|
| 421 | #endif |
---|
| 422 | #ifdef IBMPC |
---|
| 423 | static unsigned short RP[16] = { |
---|
| 424 | 0x8325,0xad1c,0xdc53,0xc1f1, |
---|
| 425 | 0x990d,0xc772,0x7751,0x427c, |
---|
| 426 | 0x00f7,0xe0d9,0x5614,0xc2ec, |
---|
| 427 | 0x5fb4,0x69ff,0x3ef8,0x4341, |
---|
| 428 | }; |
---|
| 429 | static unsigned short RQ[32] = { |
---|
| 430 | /*0x0000,0x0000,0x0000,0x3ff0,*/ |
---|
| 431 | 0xb78c,0xa696,0x3902,0x407f, |
---|
| 432 | 0x1a67,0x36a2,0x36cb,0x4105, |
---|
| 433 | 0x0634,0x2eac,0x1934,0x4187, |
---|
| 434 | 0x4914,0x0944,0xd5b0,0x4204, |
---|
| 435 | 0x2e46,0x7218,0xbeb3,0x427e, |
---|
| 436 | 0x48e9,0x8c97,0xa6a2,0x42f1, |
---|
| 437 | 0x2e9c,0x7e7b,0x4141,0x435c, |
---|
| 438 | 0x62cc,0xc7b6,0xbe34,0x43b7, |
---|
| 439 | }; |
---|
| 440 | #endif |
---|
| 441 | #ifdef MIEEE |
---|
| 442 | static unsigned short RP[16] = { |
---|
| 443 | 0xc1f1,0xdc53,0xad1c,0x8325, |
---|
| 444 | 0x427c,0x7751,0xc772,0x990d, |
---|
| 445 | 0xc2ec,0x5614,0xe0d9,0x00f7, |
---|
| 446 | 0x4341,0x3ef8,0x69ff,0x5fb4, |
---|
| 447 | }; |
---|
| 448 | static unsigned short RQ[32] = { |
---|
| 449 | /*0x3ff0,0x0000,0x0000,0x0000,*/ |
---|
| 450 | 0x407f,0x3902,0xa696,0xb78c, |
---|
| 451 | 0x4105,0x36cb,0x36a2,0x1a67, |
---|
| 452 | 0x4187,0x1934,0x2eac,0x0634, |
---|
| 453 | 0x4204,0xd5b0,0x0944,0x4914, |
---|
| 454 | 0x427e,0xbeb3,0x7218,0x2e46, |
---|
| 455 | 0x42f1,0xa6a2,0x8c97,0x48e9, |
---|
| 456 | 0x435c,0x4141,0x7e7b,0x2e9c, |
---|
| 457 | 0x43b7,0xbe34,0xc7b6,0x62cc, |
---|
| 458 | }; |
---|
| 459 | #endif |
---|
| 460 | |
---|
| 461 | #ifdef ANSIPROT |
---|
| 462 | extern double polevl ( double, void *, int ); |
---|
| 463 | extern double p1evl ( double, void *, int ); |
---|
| 464 | extern double log ( double ); |
---|
| 465 | extern double sin ( double ); |
---|
| 466 | extern double cos ( double ); |
---|
| 467 | extern double sqrt ( double ); |
---|
| 468 | double j0 ( double ); |
---|
| 469 | #else |
---|
| 470 | double polevl(), p1evl(), log(), sin(), cos(), sqrt(); |
---|
| 471 | double j0(); |
---|
| 472 | #endif |
---|
| 473 | extern double TWOOPI, SQ2OPI, PIO4; |
---|
| 474 | |
---|
| 475 | double j0(x) |
---|
| 476 | double x; |
---|
| 477 | { |
---|
| 478 | double w, z, p, q, xn; |
---|
| 479 | |
---|
| 480 | if( x < 0 ) |
---|
| 481 | x = -x; |
---|
| 482 | |
---|
| 483 | if( x <= 5.0 ) |
---|
| 484 | { |
---|
| 485 | z = x * x; |
---|
| 486 | if( x < 1.0e-5 ) |
---|
| 487 | return( 1.0 - z/4.0 ); |
---|
| 488 | |
---|
| 489 | p = (z - DR1) * (z - DR2); |
---|
| 490 | p = p * polevl( z, RP, 3)/p1evl( z, RQ, 8 ); |
---|
| 491 | return( p ); |
---|
| 492 | } |
---|
| 493 | |
---|
| 494 | w = 5.0/x; |
---|
| 495 | q = 25.0/(x*x); |
---|
| 496 | p = polevl( q, PP, 6)/polevl( q, PQ, 6 ); |
---|
| 497 | q = polevl( q, QP, 7)/p1evl( q, QQ, 7 ); |
---|
| 498 | xn = x - PIO4; |
---|
| 499 | p = p * cos(xn) - w * q * sin(xn); |
---|
| 500 | return( p * SQ2OPI / sqrt(x) ); |
---|
| 501 | } |
---|
| 502 | |
---|
| 503 | /* y0() 2 */ |
---|
| 504 | /* Bessel function of second kind, order zero */ |
---|
| 505 | |
---|
| 506 | /* Rational approximation coefficients YP[], YQ[] are used here. |
---|
| 507 | * The function computed is y0(x) - 2 * log(x) * j0(x) / PI, |
---|
| 508 | * whose value at x = 0 is 2 * ( log(0.5) + EUL ) / PI |
---|
| 509 | * = 0.073804295108687225. |
---|
| 510 | */ |
---|
| 511 | |
---|
| 512 | /* |
---|
| 513 | #define PIO4 .78539816339744830962 |
---|
| 514 | #define SQ2OPI .79788456080286535588 |
---|
| 515 | */ |
---|
| 516 | extern double MAXNUM; |
---|
| 517 | |
---|
| 518 | double y0(x) |
---|
| 519 | double x; |
---|
| 520 | { |
---|
| 521 | double w, z, p, q, xn; |
---|
| 522 | |
---|
| 523 | if( x <= 5.0 ) |
---|
| 524 | { |
---|
| 525 | if( x <= 0.0 ) |
---|
| 526 | { |
---|
| 527 | mtherr( "y0", DOMAIN ); |
---|
| 528 | return( -MAXNUM ); |
---|
| 529 | } |
---|
| 530 | z = x * x; |
---|
| 531 | w = polevl( z, YP, 7) / p1evl( z, YQ, 7 ); |
---|
| 532 | w += TWOOPI * log(x) * j0(x); |
---|
| 533 | return( w ); |
---|
| 534 | } |
---|
| 535 | |
---|
| 536 | w = 5.0/x; |
---|
| 537 | z = 25.0 / (x * x); |
---|
| 538 | p = polevl( z, PP, 6)/polevl( z, PQ, 6 ); |
---|
| 539 | q = polevl( z, QP, 7)/p1evl( z, QQ, 7 ); |
---|
| 540 | xn = x - PIO4; |
---|
| 541 | p = p * sin(xn) + w * q * cos(xn); |
---|
| 542 | return( p * SQ2OPI / sqrt(x) ); |
---|
| 543 | } |
---|