Debian Codegraph @

external/gsl/gsl_specfunc__bessel_Jn.c

raw symbols SCIP
1 /* specfunc/bessel_Jn.c
2 *
3 * Copyright (C) 1996, 1997, 1998, 1999, 2000 Gerard Jungman
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 3 of the License, or (at
8 * your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 */
19
20 /* Author: G. Jungman */
21
22 #include "gsl__config.h"cxx . . $ `<file>/external/gsl/gsl__config.h`/
23 #include "gsl_math.h"cxx . . $ `<file>/external/gsl/gsl_math.h`/
24 #include "gsl_errno.h"cxx . . $ `<file>/external/gsl/gsl_errno.h`/
25 #include "gsl_sf_pow_int.h"cxx . . $ `<file>/external/gsl/gsl_sf_pow_int.h`/
26 #include "gsl_specfunc__bessel.h"cxx . . $ `<file>/external/gsl/gsl_specfunc__bessel.h`/
27 #include "gsl_specfunc__bessel_amp_phase.h"cxx . . $ `<file>/external/gsl/gsl_specfunc__bessel_amp_phase.h`/
28 #include "gsl_specfunc__bessel_olver.h"cxx . . $ `<file>/external/gsl/gsl_specfunc__bessel_olver.h`/
29 #include "gsl_sf_bessel.h"cxx . . $ `<file>/external/gsl/gsl_sf_bessel.h`/
30
31
32
33 /*-*-*-*-*-*-*-*-*-*-*-* Functions with Error Codes *-*-*-*-*-*-*-*-*-*-*-*/
34
35
36 int gsl_sf_bessel_Jn_ecxx . . $ gsl_sf_bessel_Jn_e(6e0db8bf56396db2).(int n, double x, gsl_sf_resultcxx . . $ gsl_sf_result# * result)
37 {
38 int sign = 1;
39
40 if(n < 0) {
41 /* reduce to case n >= 0 */
42 n = -n;
43 if(GSL_IS_ODDcxx . . $ `external/gsl/gsl_math.h:112:9`!(n)) sign = -sign;
44 }
45
46 if(x < 0.0) {
47 /* reduce to case x >= 0. */
48 x = -x;
49 if(GSL_IS_ODDcxx . . $ `external/gsl/gsl_math.h:112:9`!(n)) sign = -sign;
50 }
51
52 /* CHECK_POINTER(result) */
53
54 if(n == 0) {
55 gsl_sf_resultcxx . . $ gsl_sf_result# b0;
56 int stat_J0 = gsl_sf_bessel_J0_ecxx . . $ gsl_sf_bessel_J0_e(feafd9287608bc44).(x, &b0);
57 result->valcxx . . $ gsl_sf_result_struct#val. = sign * b0.valcxx . . $ gsl_sf_result_struct#val.;
58 result->errcxx . . $ gsl_sf_result_struct#err. = b0.errcxx . . $ gsl_sf_result_struct#err.;
59 return stat_J0;
60 }
61 else if(n == 1) {
62 gsl_sf_resultcxx . . $ gsl_sf_result# b1;
63 int stat_J1 = gsl_sf_bessel_J1_ecxx . . $ gsl_sf_bessel_J1_e(feafd9287608bc44).(x, &b1);
64 result->valcxx . . $ gsl_sf_result_struct#val. = sign * b1.valcxx . . $ gsl_sf_result_struct#val.;
65 result->errcxx . . $ gsl_sf_result_struct#err. = b1.errcxx . . $ gsl_sf_result_struct#err.;
66 return stat_J1;
67 }
68 else {
69 if(x == 0.0) {
70 result->valcxx . . $ gsl_sf_result_struct#val. = 0.0;
71 result->errcxx . . $ gsl_sf_result_struct#err. = 0.0;
72 return GSL_SUCCESScxx . . $ GSL_SUCCESS.;
73 }
74 else if(x*x < 10.0*(n+1.0)*GSL_ROOT5_DBL_EPSILONcxx . . $ `external/gsl/gsl_machine.h:21:9`!) {
75 gsl_sf_resultcxx . . $ gsl_sf_result# b;
76 int status = gsl_sf_bessel_IJ_taylor_ecxx . . $ gsl_sf_bessel_IJ_taylor_e(2103957cdc9cfe31).((double)n, x, -1, 50, GSL_DBL_EPSILONcxx . . $ `external/gsl/gsl_machine.h:17:9`!, &b);
77 result->valcxx . . $ gsl_sf_result_struct#val. = sign * b.valcxx . . $ gsl_sf_result_struct#val.;
78 result->errcxx . . $ gsl_sf_result_struct#err. = b.errcxx . . $ gsl_sf_result_struct#err.;
79 result->errcxx . . $ gsl_sf_result_struct#err. += GSL_DBL_EPSILONcxx . . $ `external/gsl/gsl_machine.h:17:9`! * fabs(result->valcxx . . $ gsl_sf_result_struct#val.);
80 return status;
81 }
82 else if(GSL_ROOT4_DBL_EPSILONcxx . . $ `external/gsl/gsl_machine.h:20:9`! * x > (n*n+1.0)) {
83 int status = gsl_sf_bessel_Jnu_asympx_ecxx . . $ gsl_sf_bessel_Jnu_asympx_e(38fedf92a6b14b51).((double)n, x, result);
84 result->valcxx . . $ gsl_sf_result_struct#val. *= sign;
85 return status;
86 }
87 else if(n > 50) {
88 int status = gsl_sf_bessel_Jnu_asymp_Olver_ecxx . . $ gsl_sf_bessel_Jnu_asymp_Olver_e(38fedf92a6b14b51).((double)n, x, result);
89 result->valcxx . . $ gsl_sf_result_struct#val. *= sign;
90 return status;
91 }
92 else if(x > 1000.0)
93 {
94 /* We need this to avoid feeding large x to CF1; note that
95 * due to the above check, we know that n <= 50.
96 */
97 int status = gsl_sf_bessel_Jnu_asympx_ecxx . . $ gsl_sf_bessel_Jnu_asympx_e(38fedf92a6b14b51).((double)n, x, result);
98 result->valcxx . . $ gsl_sf_result_struct#val. *= sign;
99 return status;
100 }
101 else {
102 double ans;
103 double err;
104 double ratio;
105 double sgn;
106 int stat_b;
107 int stat_CF1 = gsl_sf_bessel_J_CF1cxx . . $ gsl_sf_bessel_J_CF1(7e13fe78331b9d07).((double)n, x, &ratio, &sgn);
108
109 /* backward recurrence */
110 double Jkp1 = GSL_SQRT_DBL_MINcxx . . $ `external/gsl/gsl_machine.h:26:9`! * ratio;
111 double Jk = GSL_SQRT_DBL_MINcxx . . $ `external/gsl/gsl_machine.h:26:9`!;
112 double Jkm1;
113 int k;
114
115 for(k=n; k>0; k--) {
116 Jkm1 = 2.0*k/x * Jk - Jkp1;
117 Jkp1 = Jk;
118 Jk = Jkm1;
119 }
120
121 if(fabs(Jkp1) > fabs(Jk)) {
122 gsl_sf_resultcxx . . $ gsl_sf_result# b1;
123 stat_b = gsl_sf_bessel_J1_ecxx . . $ gsl_sf_bessel_J1_e(feafd9287608bc44).(x, &b1);
124 ans = b1.valcxx . . $ gsl_sf_result_struct#val./Jkp1 * GSL_SQRT_DBL_MINcxx . . $ `external/gsl/gsl_machine.h:26:9`!;
125 err = b1.errcxx . . $ gsl_sf_result_struct#err./Jkp1 * GSL_SQRT_DBL_MINcxx . . $ `external/gsl/gsl_machine.h:26:9`!;
126 }
127 else {
128 gsl_sf_resultcxx . . $ gsl_sf_result# b0;
129 stat_b = gsl_sf_bessel_J0_ecxx . . $ gsl_sf_bessel_J0_e(feafd9287608bc44).(x, &b0);
130 ans = b0.valcxx . . $ gsl_sf_result_struct#val./Jk * GSL_SQRT_DBL_MINcxx . . $ `external/gsl/gsl_machine.h:26:9`!;
131 err = b0.errcxx . . $ gsl_sf_result_struct#err./Jk * GSL_SQRT_DBL_MINcxx . . $ `external/gsl/gsl_machine.h:26:9`!;
132 }
133
134 result->valcxx . . $ gsl_sf_result_struct#val. = sign * ans;
135 result->errcxx . . $ gsl_sf_result_struct#err. = fabs(err);
136 return GSL_ERROR_SELECT_2cxx . . $ `external/gsl/gsl_errno.h:145:9`!(stat_CF1, stat_b);
137 }
138 }
139 }
140
141
142 int
143 gsl_sf_bessel_Jn_arraycxx . . $ gsl_sf_bessel_Jn_array(fb7a5a69cfb04214).(int nmin, int nmax, double x, double * result_array)
144 {
145 /* CHECK_POINTER(result_array) */
146
147 if(nmin < 0 || nmax < nmin) {
148 int n;
149 for(n=nmax; n>=nmin; n--) {
150 result_array[n-nmin] = 0.0;
151 }
152 GSL_ERRORcxx . . $ `external/gsl/gsl_errno.h:104:9`! ("domain error", GSL_EDOM);
153 }
154 else if(x == 0.0) {
155 int n;
156 for(n=nmax; n>=nmin; n--) {
157 result_array[n-nmin] = 0.0;
158 }
159 if(nmin == 0) result_array[0] = 1.0;
160 return GSL_SUCCESScxx . . $ GSL_SUCCESS.;
161 }
162 else {
163 gsl_sf_resultcxx . . $ gsl_sf_result# r_Jnp1;
164 gsl_sf_resultcxx . . $ gsl_sf_result# r_Jn;
165 int stat_np1 = gsl_sf_bessel_Jn_ecxx . . $ gsl_sf_bessel_Jn_e(6e0db8bf56396db2).(nmax+1, x, &r_Jnp1);
166 int stat_n = gsl_sf_bessel_Jn_ecxx . . $ gsl_sf_bessel_Jn_e(6e0db8bf56396db2).(nmax, x, &r_Jn);
167 int stat = GSL_ERROR_SELECT_2cxx . . $ `external/gsl/gsl_errno.h:145:9`!(stat_np1, stat_n);
168
169 double Jnp1 = r_Jnp1.valcxx . . $ gsl_sf_result_struct#val.;
170 double Jn = r_Jn.valcxx . . $ gsl_sf_result_struct#val.;
171 double Jnm1;
172 int n;
173
174 if(stat == GSL_SUCCESScxx . . $ GSL_SUCCESS.) {
175 for(n=nmax; n>=nmin; n--) {
176 result_array[n-nmin] = Jn;
177 Jnm1 = -Jnp1 + 2.0*n/x * Jn;
178 Jnp1 = Jn;
179 Jn = Jnm1;
180 }
181 }
182 else {
183 for(n=nmax; n>=nmin; n--) {
184 result_array[n-nmin] = 0.0;
185 }
186 }
187
188 return stat;
189 }
190 }
191
192 /*-*-*-*-*-*-*-*-*-* Functions w/ Natural Prototypes *-*-*-*-*-*-*-*-*-*-*/
193
194 #include "gsl_specfunc__eval.h"cxx . . $ `<file>/external/gsl/gsl_specfunc__eval.h`/
195
196 double gsl_sf_bessel_Jncxx . . $ gsl_sf_bessel_Jn(538a8530131fd110).(const int n, const double x)
197 {
198 EVAL_RESULTcxx . . $ `external/gsl/gsl_specfunc__eval.h:3:9`!(gsl_sf_bessel_Jn_e(n, x, &result));
199 }