/* nag_jacobian_elliptic (s21cbc) 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 cn, dn, sn, z; Integer exit_status = 0; NagError fail; double ak2; 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_jacobian_elliptic (s21cbc) Example Program Results\n"); while (fscanf(fpin, " (%lf,%lf) %lf%*[^\n] ", &z.re, &z.im, &ak2) != EOF) { /* nag_jacobian_elliptic (s21cbc). * Jacobian elliptic functions sn, cn and dn of complex * argument */ nag_jacobian_elliptic(z, ak2, &sn, &cn, &dn, &fail); fprintf(fpout, " z ak2\n"); fprintf(fpout, " (%8.4f,%8.4f) %10.2f\n\n", z.re, z.im, ak2); if (fail.code == NE_NOERROR) { fprintf(fpout, " sn cn" " dn\n"); fprintf(fpout, " (%8.4f,%8.4f) ", sn.re, sn.im); fprintf(fpout, "(%8.4f,%8.4f) ", cn.re, cn.im); fprintf(fpout, "(%8.4f,%8.4f)", dn.re, dn.im); fprintf(fpout, "\n"); } else { fprintf(fpout, "Error from nag_jacobian_elliptic (s21cbc).\n%s\n", fail.message); exit_status = 1; goto END; } } END: if (fpin != stdin) fclose(fpin); if (fpout != stdout) fclose(fpout); return exit_status; }