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

NAG CL Interface Introduction
Example description
/* nag_stat_normal_scores_exact (g01dac) Example Program.
 *
 * Copyright 2024 Numerical Algorithms Group.
 *
 * Mark 30.0, 2024.
 */

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

int main(void) {
  /* Scalars */
  double errest, etol;
  Integer exit_status = 0, i, j, n, nmax;
  NagError fail;
  /* Arrays */
  double *pp = 0;

  INIT_FAIL(fail);

  printf("nag_stat_normal_scores_exact (g01dac) Example Program Results\n");

  etol = 0.001;
  nmax = 15;

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

  for (j = 5; j <= nmax; j += 5) {
    n = j;
    /* nag_stat_normal_scores_exact (g01dac).
     * Normal scores, accurate values
     */
    nag_stat_normal_scores_exact(n, pp, etol, &errest, &fail);

    if (fail.code != NE_NOERROR) {
      printf("Error from nag_stat_normal_scores_exact (g01dac).\n%s\n",
             fail.message);
      exit_status = 1;
      goto END;
    }
    printf("\nSet size = %2" NAG_IFMT "\n\n", n);
    printf("Error tolerance (input) = %13.3e\n\n", etol);
    printf("Error estimate (output) = %13.3e\n\n", errest);
    printf("Normal scores\n");
    for (i = 1; i <= n; ++i) {
      printf("%10.3f", pp[i - 1]);
      printf(i % 5 == 0 || i == n ? "\n" : " ");
    }
    printf("\n");
  }

END:
  NAG_FREE(pp);

  return exit_status;
}