/* nag_bessel_j_alpha (s18ekc) Example Program. * * Copyright 2000 Numerical Algorithms Group. * * NAG C Library * * Mark 6, 2000. * Mark 8 revised, 2004. * */ #include #include #include #include int main(void) { Complex *b=0; Integer exit_status=0, i, nl; NagError fail; double a, alpha, d, x; INIT_FAIL(fail); /* Skip heading in data file */ Vscanf("%*[^\n]"); Vprintf("nag_bessel_j_alpha (s18ekc) Example Program Results\n"); if ( !( b = NAG_ALLOC(101, Complex)) ) { Vprintf("Allocation failure\n"); exit_status = -1; goto END; } while (scanf("%lf %lf %ld%*[^\n]", &x, &a, &nl) != EOF) { Vprintf(" x a nl\n"); Vprintf("%4.1f %4.1f %6ld\n\n", x, a, nl); /* nag_bessel_j_alpha (s18ekc). * Bessel functions J_(alpha~+~n~-~1)(x) or * J_(alpha~-~n~+~1)(x) for real x~!=~0, non-negative * alpha~<~1 and n~=~1~,~2~,~...~,~|N|~+~1 */ nag_bessel_j_alpha(x, a, nl, b, &fail); if (fail.code == NE_NOERROR) { Vprintf(" Requested values of J_alpha(X)\n\n"); alpha = a; Vprintf(" alpha J_alpha(X)\n"); for (i = 1; i <= ABS(nl) + 1; ++i) { Vprintf(" %12.4e (%12.4e, %12.4e)\n", alpha, b[i - 1].re, b[i - 1].im); d = (double) nl; alpha += SIGN(1.0, d); } } else { Vprintf("Error from nag_bessel_j_alpha (s18ekc).\n%s\n", fail.message); exit_status = 1; goto END; } } END: if (b) NAG_FREE(b); return exit_status; }