/* 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 #include int main(int argc, char *argv[]) { FILE *fpin, *fpout; Integer exit_status = 0, i, ia, ja, nl; NagError fail; double alpha, *b = 0, x; INIT_FAIL(fail); /* Check for command-line IO options */ fpin = nag_example_file_io(argc, argv, "-data", NULL); fpout = nag_example_file_io(argc, argv, "-results", NULL); /* Skip heading in data file */ fscanf(fpin, "%*[^\n]"); fprintf(fpout, "nag_bessel_k_alpha (s18egc) Example Program Results\n"); if (!(b = NAG_ALLOC(101, double))) { fprintf(fpout, "Allocation failure\n"); exit_status = -1; goto END; } while (fscanf(fpin, "%lf %ld %ld %ld%*[^\n]", &x, &ia, &ja, &nl) != EOF) { fprintf(fpout, " x ia ja nl\n"); fprintf(fpout, "%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) { fprintf(fpout, "Error from nag_bessel_k_alpha (s18egc).\n%s\n", fail.message); exit_status = 1; goto END; } fprintf(fpout, " Requested values of K_alpha(x)\n\n"); alpha = (double) ia / (double) ja; fprintf(fpout, " alpha K_alpha(x)\n"); for (i = 0; i <= nl; ++i) { fprintf(fpout, " %13.4e %13.4e\n", alpha, b[i]); alpha += 1.0; } } END: if (fpin != stdin) fclose(fpin); if (fpout != stdout) fclose(fpout); if (b) NAG_FREE(b); return exit_status; }