Example description
/* nag_blast_zamin_val (f16jtc) Example Program.
 *
 * Copyright 2019 Numerical Algorithms Group.
 *
 * Mark 27.0, 2019.
 */

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

int main(void)
{
  /* Scalars */
  Integer exit_status, i, incx, ix, k, n;
  double r;
  /* Arrays */
  Complex *x = 0;
  /* Nag Types */
  NagError fail;

  exit_status = 0;
  INIT_FAIL(fail);

  printf("nag_blast_zamin_val (f16jtc) Example Program Results\n\n");

  /* Skip heading in data file */
  scanf("%*[^\n] ");
  /* Read the number of elements and the increment */
  scanf("%" NAG_IFMT "%" NAG_IFMT "%*[^\n] ", &n, &incx);

  if (n > 0) {
    /* Allocate memory */
    if (!(x = NAG_ALLOC(MAX(1, 1 + (n - 1) * ABS(incx)), Complex)))
    {
      printf("Allocation failure\n");
      exit_status = -1;
      goto END;
    }
  }
  else {
    printf("Invalid n\n");
    exit_status = 1;
    goto END;
  }

  /* Read the vector x and store forwards or backwards 
   * as determined by incx. */
  for (i = 0, ix = (incx > 0 ? 0 : (1-n)*incx); i < n; i++, ix += incx)
    scanf(" ( %lf , %lf ) ", &x[ix].re, &x[ix].im);
  scanf("%*[^\n] ");

  /* nag_blast_zamin_val (f16jtc).
   * Get absolutely minimum value (r) and location of that value (k)
   * of Complex array */
  nag_blast_zamin_val(n, x, incx, &k, &r, &fail);

  if (fail.code != NE_NOERROR) {
    printf("Error from nag_blast_zamin_val (f16jtc).\n%s\n", fail.message);
    exit_status = 1;
    goto END;
  }

  /* Print the absolutely minimum value */
  printf("Absolutely minimum element of x is %12.5f\n", r);
  /* Print its location */
  printf("Index of absolutely minimum element of x is %3" NAG_IFMT "\n", k);

END:
  NAG_FREE(x);

  return exit_status;
}