/* nag_complex_polygamma (s14afc) Example Program. * * Copyright 2000 Numerical Algorithms Group. * * NAG C Library * * Mark 6, 2000. */ #include #include #include #include #include int main(int argc, char *argv[]) { FILE *fpin, *fpout; Complex y, z; Integer exit_status = 0, k; 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_complex_polygamma (s14afc) Example Program Results\n"); fprintf(fpout, " z k (d^k/dz^k)psi(z)\n"); while (fscanf(fpin, " (%lf,%lf)%ld%*[^\n] ", &z.re, &z.im, &k) != EOF) { /* nag_complex_polygamma (s14afc). * Derivative of the psi function psi(z) */ y = nag_complex_polygamma(z, k, &fail); if (fail.code == NE_NOERROR) fprintf(fpout, "(%5.1f, %5.1f) %6ld (%13.4e, %13.4e)\n", z.re, z.im, k, y.re, y.im); else { fprintf(fpout, "Error from nag_complex_polygamma (s14afc).\n%s\n", fail.message); exit_status = 1; goto END; } } END: if (fpin != stdin) fclose(fpin); if (fpout != stdout) fclose(fpout); return exit_status; }