/* nag_incomplete_gamma (s14bac) Example Program. * * Copyright 1990 Numerical Algorithms Group. * * Mark 2 revised, 1992. */ #include #include #include #include #include #include int main(int argc, char *argv[]) { FILE *fpin, *fpout; Integer exit_status = 0; double a, p, q, tol, x; NagError fail; 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_incomplete_gamma (s14bac) Example Program Results\n"); /* nag_machine_precision (x02ajc). * The machine precision */ tol = X02AJC; fprintf(fpout, " a x p q\n"); while (fscanf(fpin, "%lf %lf", &a, &x) != EOF) { /* nag_incomplete_gamma (s14bac). * Incomplete Gamma functions P(ax) and Q(ax) */ nag_incomplete_gamma(a, x, tol, &p, &q, &fail); if (fail.code != NE_NOERROR) { fprintf(fpout, "Error from nag_incomplete_gamma (s14bac).\n%s\n", fail.message); exit_status = 1; goto END; } fprintf(fpout, "%12.4f%12.4f%12.4f%12.4f\n", a, x, p, q); } END: if (fpin != stdin) fclose(fpin); if (fpout != stdout) fclose(fpout); return exit_status; }