/* nag_complex_log_gamma (s14agc) 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; Complex y, z; 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_log_gamma (s14agc) Example Program Results\n"); fprintf(fpout, " z ln(Gamma(z))\n"); while (fscanf(fpin, " (%lf,%lf)%*[^\n] ", &z.re, &z.im) != EOF) { /* nag_complex_log_gamma (s14agc). * Logarithm of the Gamma function ln~Gamma~(z) */ y = nag_complex_log_gamma(z, &fail); if (fail.code == NE_NOERROR) fprintf(fpout, "(%5.1f,%5.1f) (%13.4e,%13.4e)\n", z.re, z.im, y.re, y.im); else { fprintf(fpout, "Error from nag_complex_log_gamma (s14agc).\n%s\n", fail.message); exit_status = 1; goto END; } } END: if (fpin != stdin) fclose(fpin); if (fpout != stdout) fclose(fpout); return exit_status; }