/* nag_polygamma_deriv (s14adc) Example Program. * * Copyright 2002 Numerical Algorithms Group. * * Mark 7, 2002. */ #include #include #include #include #include int main(int argc, char *argv[]) { FILE *fpin, *fpout; Integer exit_status = 0; double x, w[4]; int n, m; 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_polygamma_deriv (s14adc) Example Program Results\n"); fprintf(fpout, "%9s%14s%14s%14s%14s\n", "x", "w(0,x)", "w(1,x)", "w(2,x)", "w(3,x)"); while (fscanf(fpin, "%lf", &x) != EOF) { n = 0; m = 4; /* nag_polygamma_deriv (s14adc). * Scaled derivatives of psi(x) */ nag_polygamma_deriv(x, n, m, w, &fail); if (fail.code != NE_NOERROR) { fprintf(fpout, "Error from nag_polygamma_deriv (s14adc).\n%s\n", fail.message); exit_status = 1; goto END; } fprintf(fpout, "%13.4e %13.4e %13.4e %13.4e %13.4e\n", x, w[0], w[1], w[2], w[3]); } END: if (fpin != stdin) fclose(fpin); if (fpout != stdout) fclose(fpout); return exit_status; }