74 #define SMALL_J0_BOUND 1e6
77 #define SMALL_JN_BOUND 5.0
80 #define BIG_JN_BOUND 25.0
83 #define MAX_SMALL_ITERATION 2048
113 ak =
pow (0.5 * z, n);
117 return n > 0 ? 0.0 : 1;
129 ak = -(z * z) / (4.0 * k * (n + k));
138 assert (k < MAX_SMALL_ITERATION);
154 m = (2 *
abs (z) + 0.25 * (n +
abs (
imag (z))));
157 m1pna2 = (n / 2) % 2 == 0 ? 1.0 : -1.0;
158 first = (1.0 + m1pna2 *
cos (z)) / (2.0 * m);
161 for (k = 1; k <= m - 1; k++)
163 t = (k *
M_PI) / (2 * m);
167 return first + second / (nr_double_t) m;
171 cbesselj_mediumarg_even (
unsigned int n,
nr_complex_t z)
181 m = (2 *
abs (z) + 0.25 * (n +
abs (
imag (z))));
184 m1pn1a2 = ((n - 1) / 2) % 2 == 0 ? 1.0 : -1.0;
185 first = (m1pn1a2 *
sin (z)) / (2.0 * m);
188 for (k = 1; k <= m - 1; k++)
190 t = (k *
M_PI) / (2 * m);
194 return first + second / (nr_double_t) m;
202 return cbesselj_mediumarg_odd (n, z);
204 return cbesselj_mediumarg_even (n, z);
210 #define MAX_LARGE_ITERATION 430
221 unsigned long num, denum;
231 Q0 = (4.0 * n * n - 1) / (8.0 * z);
235 m1a8z2 = (-1.0) / (8.0 *
sqr (z));
243 num = (4 *
sqr (n) -
sqr (4 * k - 3)) * (4 *
sqr (n) - (4 * k - 1));
244 denum = 2 * k * (2 * k - 1);
245 Pk = Pk * ((nr_double_t) num * m1a8z2) / ((nr_double_t) denum);
260 num = (4 *
sqr (n) -
sqr (4 * k - 1)) * (4 *
sqr (n) - (4 * k - 1));
261 denum = 2 * k * (2 * k - 1);
262 Qk = Qk * ((nr_double_t) num * m1a8z2) / ((nr_double_t) denum);
272 l = (n % 4 == 0) || (n % 4 == 3) ? 1.0 : -1.0;
273 m = (n % 4 == 0) || (n % 4 == 1) ? 1.0 : -1.0;
276 tmp = (l * P + m * Q_) *
cos (z);
277 tmp += (m * P - l * Q_) *
sin (z);
287 nr_double_t mul = 1.0;
299 ret = cbesselj_smallarg (n, z);
301 ret = cbesselj_largearg (n, z);
303 ret = cbesselj_mediumarg (n, z);