/* nag_prob_von_mises (g01erc) Example Program. * * Copyright 2001 Numerical Algorithms Group. * * Mark 7, 2001. */ #include #include #include #include #include int main(int argc, char *argv[]) { FILE *fpin, *fpout; /* Scalars */ double p, t, vk; Integer exit_status, i__, n; 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); exit_status = 0; fprintf(fpout, "nag_prob_von_mises (g01erc) Example Program Results\n\n"); /* Skip heading in data file */ fscanf(fpin, "%*[^\n] "); fscanf(fpin, "%ld%*[^\n] ", &n); for (i__ = 1; i__ <= n; ++i__) { fscanf(fpin, "%lf%lf%*[^\n] ", &t, &vk); /* nag_prob_von_mises (g01erc). * Computes probability for von Mises distribution */ p = nag_prob_von_mises(t, vk, &fail); if (fail.code != NE_NOERROR) { fprintf(fpout, "Error from nag_prob_von_mises (g01erc).\n%s\n", fail.message); exit_status = 1; goto END; } fprintf(fpout, " p = %10.4f\n", p); } END: if (fpin != stdin) fclose(fpin); if (fpout != stdout) fclose(fpout); return exit_status; }