/* nag_bessel_zeros (s17alc) Example Program. * * Copyright 2000 Numerical Algorithms Group. * * NAG C Library * * Mark 6, 2000. * Mark 7, revised, 2001. * */ #include #include #include #include #include #include int main(void) { #define NMAX 100 Integer exit_status=0, i, mode, n; NagError fail; double a, rel, *x=0; INIT_FAIL(fail); /* Skip heading in data file */ Vscanf("%*[^\n]"); Vprintf("nag_bessel_zeros (s17alc) Example Program Results\n\n"); if (! (x = NAG_ALLOC(NMAX, double))) { Vprintf("Allocation failure\n"); exit_status=-1; } /* nag_machine_precision (x02ajc). * The machine precision */ rel = sqrt (X02AJC); Vscanf("%lf %ld %ld", &a, &n, &mode); /* nag_bessel_zeros (s17alc). * Zeros of Bessel functions J_alpha(x), (J_alpha')(x), * Y_alpha(x) or (Y_alpha')(x) */ nag_bessel_zeros(a, n, mode, rel, x, &fail); if (fail.code == NE_NOERROR) { Vprintf(" a n mode\n"); Vprintf(" %4.1f%3ld%6ld\n\n", a, n, mode); if (mode == 1) Vprintf("Leading n positive zeros of J\n"); else if (mode == 2) Vprintf("Leading n positive zeros of Y\n"); else if (mode == 3) { if (a == 0.0) Vprintf("Leading n non-negative zeros of J'\n"); else Vprintf("Leading n positive zeros of J'\n"); } else if (mode == 4) Vprintf("Leading n positive zeros of Y'\n\n"); for (i = 0; i <= n-1; ++i) Vprintf(" x = %12.4e\n", x[i]); Vprintf("\n"); } else { Vprintf("Error from nag_bessel_zeros (s17alc).\n%s\n", fail.message); exit_status = 1; goto END; } END: if (x) NAG_FREE (x); return exit_status; }