/* nag_jacobian_elliptic (s21cbc) Example Program.
*
* Copyright 2017 Numerical Algorithms Group.
*
* NAG C Library
*
* Mark 26.1, 2017.
*/
#include <stdio.h>
#include <nag.h>
#include <nag_stdlib.h>
#include <nags.h>
int main(void)
{
Complex cn, dn, sn, z;
Integer exit_status = 0;
NagError fail;
double ak2;
INIT_FAIL(fail);
/* Skip heading in data file */
scanf("%*[^\n] ");
printf("nag_jacobian_elliptic (s21cbc) Example Program Results\n");
while (scanf(" (%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);
printf(" z ak2\n");
printf(" (%8.4f,%8.4f) %10.2f\n\n", z.re, z.im, ak2);
if (fail.code == NE_NOERROR) {
printf(" sn cn"
" dn\n");
printf(" (%8.4f,%8.4f) ", sn.re, sn.im);
printf("(%8.4f,%8.4f) ", cn.re, cn.im);
printf("(%8.4f,%8.4f)", dn.re, dn.im);
printf("\n");
}
else {
printf("Error from nag_jacobian_elliptic (s21cbc).\n%s\n",
fail.message);
exit_status = 1;
goto END;
}
}
END:
return exit_status;
}