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

NAG CL Interface Introduction
Example description
/* nag_specfun_fresnel_c_vector (s20arc) Example Program.
 *
 * Copyright 2023 Numerical Algorithms Group.
 *
 * Mark 29.1, 2023.
 */
#include <nag.h>
#include <stdio.h>

int main(void) {
  Integer exit_status = 0;
  Integer i, n;
  double *f = 0, *x = 0;
  NagError fail;

  INIT_FAIL(fail);

  /* Skip heading in data file */
  scanf("%*[^\n]");

  printf("nag_specfun_fresnel_c_vector (s20arc) Example Program Results\n");
  printf("\n");
  printf("     x           f\n");
  printf("\n");
  scanf("%" NAG_IFMT "", &n);
  scanf("%*[^\n]");

  /* Allocate memory */
  if (!(x = NAG_ALLOC(n, double)) || !(f = NAG_ALLOC(n, double))) {
    printf("Allocation failure\n");
    exit_status = -1;
    goto END;
  }

  for (i = 0; i < n; i++)
    scanf("%lf", &x[i]);
  scanf("%*[^\n]");

  /* nag_specfun_fresnel_c_vector (s20arc).
   * Fresnel Integral C(x)
   */
  nag_specfun_fresnel_c_vector(n, x, f, &fail);
  if (fail.code != NE_NOERROR) {
    printf("Error from nag_specfun_fresnel_c_vector (s20arc).\n%s\n",
           fail.message);
    exit_status = 1;
    goto END;
  }

  for (i = 0; i < n; i++)
    printf(" %11.3e %11.3e\n", x[i], f[i]);

END:
  NAG_FREE(f);
  NAG_FREE(x);

  return exit_status;
}