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

NAG CL Interface Introduction
Example description
/* nag_specfun_bessel_j_seq_complex (s18gkc) Example Program.
 *
 * Copyright 2022 Numerical Algorithms Group.
 *
 * Mark 28.5, 2022.
 */

#include <nag.h>
#include <stdio.h>

int main(void) {
  Integer exit_status = 0;
  Complex z, b[20];
  double a, alpha;
  Integer i, nl;
  NagError fail;

  INIT_FAIL(fail);

  /* Skip heading in data file */
  scanf("%*[^\n]");
  printf("nag_specfun_bessel_j_seq_complex (s18gkc) Example Program Results\n");
  while (scanf(" (%lf,%lf) %lf %" NAG_IFMT "%*[^\n] ", &z.re, &z.im, &a, &nl) !=
         EOF) {
    /* nag_specfun_bessel_j_seq_complex (s18gkc).
     * Bessel function of the 1st kind J_(alpha+/-n)(z)
     */
    nag_specfun_bessel_j_seq_complex(z, a, nl, b, &fail);
    if (fail.code == NE_NOERROR) {
      printf("         z             a       nl\n");
      printf(" (%7.3f,%7.3f)  %lf    %" NAG_IFMT "\n\n", z.re, z.im, a, nl);
      printf("Requested values of J_alpha(Z)\n\n");
      alpha = a;
      printf("     alpha              J_alpha(z)\n");
      for (i = 0; i < ABS(nl) + 1; i++) {
        printf("%13.4e   (%13.4e,%13.4e)\n", alpha, b[i].re, b[i].im);
        if (nl > 0)
          alpha += 1.0;
        else
          alpha -= 1.0;
      }
    } else {
      printf("Error from nag_specfun_bessel_j_seq_complex (s18gkc).\n%s\n",
             fail.message);
      exit_status = 1;
      goto END;
    }
  }

END:

  return exit_status;
}