/* nag_bessel_k_alpha (s18egc) Example Program. * * Copyright 2000 Numerical Algorithms Group. * * NAG C Library * * Mark 6, 2000. * Mark 8 revised, 2004. */ #include #include #include #include int main(void) { Integer exit_status=0, i, ia, ja, nl; NagError fail; double alpha, *b=0, x; INIT_FAIL(fail); /* Skip heading in data file */ Vscanf("%*[^\n]"); Vprintf("nag_bessel_k_alpha (s18egc) Example Program Results\n"); if ( !( b = NAG_ALLOC(101, double)) ) { Vprintf("Allocation failure\n"); exit_status = -1; goto END; } while (scanf("%lf %ld %ld %ld%*[^\n]", &x, &ia, &ja, &nl) != EOF) { Vprintf(" x ia ja nl\n"); Vprintf("%4.1f %6ld %6ld %6ld\n\n", x, ia, ja, nl); /* nag_bessel_k_alpha (s18egc). * Modified Bessel functions K_(alpha~+~n)(x) for real * x~>~0, selected values of alpha~>=~0 and * n~=~0~,~1~,~...~,~N */ nag_bessel_k_alpha(x, ia, ja, nl, b, &fail); if (fail.code == NE_NOERROR) { Vprintf(" Requested values of K_alpha(x)\n\n"); alpha = (double) ia / (double) ja; Vprintf(" alpha K_alpha(x)\n"); for (i = 0; i <= nl; ++i) { Vprintf(" %12.4e %12.4e\n", alpha, b[i]); alpha += 1.0; } } else { Vprintf("Error from nag_bessel_k_alpha (s18egc).\n%s\n", fail.message); exit_status = 1; goto END; } } END: if (b) NAG_FREE(b); return exit_status; }