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

NAG CL Interface Introduction
Example description
/* nag_bessel_i_alpha (s18ejc) Example Program.
 *
 * Copyright 2023 Numerical Algorithms Group.
 *
 * NAG C Library
 *
 * Mark 29.2, 2023.
 */

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

int main(void) {
  Complex *b = 0;
  Integer exit_status = 0, i, nl;
  NagError fail;
  double a, alpha, d, x;

  INIT_FAIL(fail);

  /* Skip heading in data file */
  scanf("%*[^\n]");
  printf("nag_bessel_i_alpha (s18ejc) Example Program Results\n");
  if (!(b = NAG_ALLOC(101, Complex))) {
    printf("Allocation failure\n");
    exit_status = -1;
    goto END;
  }
  while (scanf("%lf %lf %" NAG_IFMT "%*[^\n]", &x, &a, &nl) != EOF)
  {
    printf("  x     a      nl\n");
    printf("%4.1f  %4.1f %6" NAG_IFMT "\n\n", x, a, nl);
    /* nag_bessel_i_alpha (s18ejc).
     * Modified Bessel functions I_(alpha+n-1)(x) or
     * I_(alpha-n+1)(x) for real x != 0, non-negative
     * alpha < 1 and n = 1,2,...,|N|+1
     */
    nag_bessel_i_alpha(x, a, nl, b, &fail);
    if (fail.code == NE_NOERROR) {
      printf(" Requested values of I_alpha(X)\n\n");
      alpha = a;
      printf("     alpha              I_alpha(X)\n");
      for (i = 1; i <= ABS(nl) + 1; ++i) {
        printf("%13.4e   (%13.4e, %13.4e)\n", alpha, b[i - 1].re, b[i - 1].im);
        d = (double)nl;
        alpha += SIGN(1.0, d);
      }
    } else {
      printf("Error from nag_bessel_i_alpha (s18ejc).\n%s\n", fail.message);
      exit_status = 1;
      goto END;
    }
  }
END:
  NAG_FREE(b);
  return exit_status;
} /* main */