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

NAG CL Interface Introduction
Example description
/* nag_specfun_erfc_complex_vector (s15drc) Example Program.
 *
 * Copyright 2022 Numerical Algorithms Group.
 *
 * Mark 28.3, 2022.
 */
#include <nag.h>
#include <stdio.h>

int main(void) {
  Integer exit_status = 0;
  Integer i, n;
  Complex *f = 0, *z = 0;
  Integer *ivalid = 0;
  NagError fail;

  INIT_FAIL(fail);

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

  printf("nag_specfun_erfc_complex_vector (s15drc) Example Program Results\n");
  printf("\n");
  printf("          z                     f          ivalid\n");
  printf("\n");
  scanf("%" NAG_IFMT "", &n);
  scanf("%*[^\n]");

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

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

  /* nag_specfun_erfc_complex_vector (s15drc). */
  nag_specfun_erfc_complex_vector(n, z, f, ivalid, &fail);
  if (fail.code != NE_NOERROR && fail.code != NW_IVALID) {
    printf("Error from nag_specfun_erfc_complex_vector (s15drc).\n%s\n",
           fail.message);
    exit_status = 1;
    goto END;
  }

  for (i = 0; i < n; i++)
    printf("(%8.4f,%8.4f)   (%8.4f,%8.4f) %4" NAG_IFMT "\n", z[i].re, z[i].im,
           f[i].re, f[i].im, ivalid[i]);

END:
  NAG_FREE(f);
  NAG_FREE(z);
  NAG_FREE(ivalid);

  return exit_status;
}