1 |
|
2 /* |
|
3 * Copyright (c) 1998, 2001, Oracle and/or its affiliates. All rights reserved. |
|
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
|
5 * |
|
6 * This code is free software; you can redistribute it and/or modify it |
|
7 * under the terms of the GNU General Public License version 2 only, as |
|
8 * published by the Free Software Foundation. Oracle designates this |
|
9 * particular file as subject to the "Classpath" exception as provided |
|
10 * by Oracle in the LICENSE file that accompanied this code. |
|
11 * |
|
12 * This code is distributed in the hope that it will be useful, but WITHOUT |
|
13 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
14 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
15 * version 2 for more details (a copy is included in the LICENSE file that |
|
16 * accompanied this code). |
|
17 * |
|
18 * You should have received a copy of the GNU General Public License version |
|
19 * 2 along with this work; if not, write to the Free Software Foundation, |
|
20 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
21 * |
|
22 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
|
23 * or visit www.oracle.com if you need additional information or have any |
|
24 * questions. |
|
25 */ |
|
26 |
|
27 /* |
|
28 * wrapper jn(int n, double x), yn(int n, double x) |
|
29 * floating point Bessel's function of the 1st and 2nd kind |
|
30 * of order n |
|
31 * |
|
32 * Special cases: |
|
33 * y0(0)=y1(0)=yn(n,0) = -inf with division by zero signal; |
|
34 * y0(-ve)=y1(-ve)=yn(n,-ve) are NaN with invalid signal. |
|
35 * Note 2. About jn(n,x), yn(n,x) |
|
36 * For n=0, j0(x) is called, |
|
37 * for n=1, j1(x) is called, |
|
38 * for n<x, forward recursion us used starting |
|
39 * from values of j0(x) and j1(x). |
|
40 * for n>x, a continued fraction approximation to |
|
41 * j(n,x)/j(n-1,x) is evaluated and then backward |
|
42 * recursion is used starting from a supposed value |
|
43 * for j(n,x). The resulting value of j(0,x) is |
|
44 * compared with the actual value to correct the |
|
45 * supposed value of j(n,x). |
|
46 * |
|
47 * yn(n,x) is similar in all respects, except |
|
48 * that forward recursion is used for all |
|
49 * values of n>1. |
|
50 * |
|
51 */ |
|
52 |
|
53 #include "fdlibm.h" |
|
54 |
|
55 #ifdef __STDC__ |
|
56 double jn(int n, double x) /* wrapper jn */ |
|
57 #else |
|
58 double jn(n,x) /* wrapper jn */ |
|
59 double x; int n; |
|
60 #endif |
|
61 { |
|
62 #ifdef _IEEE_LIBM |
|
63 return __ieee754_jn(n,x); |
|
64 #else |
|
65 double z; |
|
66 z = __ieee754_jn(n,x); |
|
67 if(_LIB_VERSION == _IEEE_ || isnan(x) ) return z; |
|
68 if(fabs(x)>X_TLOSS) { |
|
69 return __kernel_standard((double)n,x,38); /* jn(|x|>X_TLOSS,n) */ |
|
70 } else |
|
71 return z; |
|
72 #endif |
|
73 } |
|
74 |
|
75 #ifdef __STDC__ |
|
76 double yn(int n, double x) /* wrapper yn */ |
|
77 #else |
|
78 double yn(n,x) /* wrapper yn */ |
|
79 double x; int n; |
|
80 #endif |
|
81 { |
|
82 #ifdef _IEEE_LIBM |
|
83 return __ieee754_yn(n,x); |
|
84 #else |
|
85 double z; |
|
86 z = __ieee754_yn(n,x); |
|
87 if(_LIB_VERSION == _IEEE_ || isnan(x) ) return z; |
|
88 if(x <= 0.0){ |
|
89 if(x==0.0) |
|
90 /* d= -one/(x-x); */ |
|
91 return __kernel_standard((double)n,x,12); |
|
92 else |
|
93 /* d = zero/(x-x); */ |
|
94 return __kernel_standard((double)n,x,13); |
|
95 } |
|
96 if(x>X_TLOSS) { |
|
97 return __kernel_standard((double)n,x,39); /* yn(x>X_TLOSS,n) */ |
|
98 } else |
|
99 return z; |
|
100 #endif |
|
101 } |
|