/* nag_normal_scores_exact (g01dac) Example Program. * * Copyright 2001 Numerical Algorithms Group. * * Mark 7, 2001. */ #include #include #include #include #include int main(int argc, char *argv[]) { FILE *fpout; /* Scalars */ double errest, etol; Integer exit_status = 0, i, j, n, nmax; NagError fail; /* Arrays */ double *pp = 0; INIT_FAIL(fail); /* Check for command-line IO options */ fpout = nag_example_file_io(argc, argv, "-results", NULL); fprintf(fpout, "nag_normal_scores_exact (g01dac) Example Program Results\n"); etol = 0.001; nmax = 15; /* Allocate memory */ if (!(pp = NAG_ALLOC(nmax, double))) { fprintf(fpout, "Allocation failure\n"); exit_status = -1; goto END; } for (j = 5; j <= nmax; j += 5) { n = j; /* nag_normal_scores_exact (g01dac). * Normal scores, accurate values */ nag_normal_scores_exact(n, pp, etol, &errest, &fail); if (fail.code != NE_NOERROR) { fprintf(fpout, "Error from nag_normal_scores_exact (g01dac).\n%s\n", fail.message); exit_status = 1; goto END; } fprintf(fpout, "\nSet size = %2ld\n\n", n); fprintf(fpout, "Error tolerance (input) = %13.3e\n\n", etol); fprintf(fpout, "Error estimate (output) = %13.3e\n\n", errest); fprintf(fpout, "Normal scores\n"); for (i = 1; i <= n; ++i) { fprintf(fpout, "%10.3f", pp[i - 1]); fprintf(fpout, i%5 == 0 || i == n?"\n":" "); } fprintf(fpout, "\n"); } END: if (fpout != stdout) fclose(fpout); if (pp) NAG_FREE(pp); return exit_status; }