NAG Library Manual, Mark 30
Interfaces:  FL   CL   CPP   AD 

NAG CL Interface Introduction
Example description
/* nag_specfun_jacellip_complex (s21cbc) Example Program.
 *
 * Copyright 2024 Numerical Algorithms Group.
 *
 * NAG C Library
 *
 * Mark 30.0, 2024.
 */

#include <nag.h>
#include <stdio.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_specfun_jacellip_complex (s21cbc) Example Program Results\n");
  while (scanf(" (%lf,%lf) %lf%*[^\n] ", &z.re, &z.im, &ak2) != EOF)
  {
    /* nag_specfun_jacellip_complex (s21cbc).
     * Jacobian elliptic functions sn, cn and dn of complex
     * argument
     */
    nag_specfun_jacellip_complex(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_specfun_jacellip_complex (s21cbc).\n%s\n",
             fail.message);
      exit_status = 1;
      goto END;
    }
  }
END:
  return exit_status;
}