/* nag_complex_erfc (s15ddc) Example Program.
 *
 * Copyright 2014 Numerical Algorithms Group.
 *
 * Mark 7, 2002.
 */

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

int main(void)
{
  Integer  exit_status = 0;
  Complex  w, z;
  NagError fail;

  INIT_FAIL(fail);

  /* Skip heading in data file */
  scanf("%*[^\n]");
  printf("nag_complex_erfc (s15ddc) Example Program Results\n");
  printf("          z                     w\n");
  while (scanf(" (%lf,%lf)%*[^\n] ", &z.re, &z.im) != EOF)
    {
      /* nag_complex_erfc (s15ddc).
       * Scaled complex complement of error function,
       * exp(-z^2)erfc(-iz)
       */
      w = nag_complex_erfc(z, &fail);
      if (fail.code != NE_NOERROR)
        {
          printf("Error from nag_complex_erfc (s15ddc).\n%s\n",
                  fail.message);
          exit_status = 1;
          goto END;
        }
      printf("(%8.4f,%8.4f)   (%8.4f,%8.4f)\n", z.re, z.im, w.re, w.im);
    }

 END:

  return exit_status;
}