/* nag_deviates_f_dist (g01fdc) Example Program. * * Copyright 1990 Numerical Algorithms Group. * * Mark 1, 1990. */ #include #include #include #include #include int main(int argc, char *argv[]) { FILE *fpin, *fpout; Integer exit_status = 0; double df1, df2, f, p; NagError fail; INIT_FAIL(fail); /* Check for command-line IO options */ fpin = nag_example_file_io(argc, argv, "-data", NULL); fpout = nag_example_file_io(argc, argv, "-results", NULL); /* Skip heading in data file */ fscanf(fpin, "%*[^\n]"); fprintf(fpout, "nag_deviates_f_dist (g01fdc) Example Program Results\n"); fprintf(fpout, " p df1 df2 f\n\n"); while (fscanf(fpin, "%lf %lf %lf", &p, &df1, &df2) != EOF) { /* nag_deviates_f_dist (g01fdc). * Deviates for the F-distribution */ f = nag_deviates_f_dist(p, df1, df2, &fail); if (fail.code != NE_NOERROR) { fprintf(fpout, "Error from nag_deviates_f_dist (g01fdc).\n%s\n", fail.message); exit_status = 1; goto END; } fprintf(fpout, "%8.3f%8.3f%8.3f%8.3f\n", p, df1, df2, f); } END: if (fpin != stdin) fclose(fpin); if (fpout != stdout) fclose(fpout); return exit_status; }