/* nag_scaled_log_gamma (s14ahc) Example Program. * * Copyright 2009, Numerical Algorithms Group. * * Mark 9, 2009. */ /* Pre-processor includes */ #include #include #include #include #include int main(int argc, char *argv[]) { FILE *fpin, *fpout; /*Integer scalar and array declarations */ Integer exit_status = 0; /*Double scalar and array declarations */ double x, y; 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); fprintf(fpout, "nag_scaled_log_gamma (s14ahc) Example Program Results\n"); /* Skip heading in data file*/ fscanf(fpin, "%*[^\n] "); fprintf(fpout, "\n%s\n\n", " x y"); while (fscanf(fpin, "%lf%*[^\n] ", &x) != EOF) { /* * nag_scaled_log_gamma (s14ahc) * Scaled logarithm of Gamma function, G(x) */ y = nag_scaled_log_gamma(x, &fail); if (fail.code != NE_NOERROR) { fprintf(fpout, "Error from nag_scaled_log_gamma (s14ahc) %s\n", fail.message); exit_status = 1; goto END; } fprintf(fpout, "%14.5e%14.5e\n", x, y); } END: if (fpin != stdin) fclose(fpin); if (fpout != stdout) fclose(fpout); return exit_status; }