/* nag_poisson_dist (g01bkc) Example Program. * * Copyright 1996 Numerical Algorithms Group. * * Mark 4, 1996. * */ #include #include #include #include #include int main(int argc, char *argv[]) { FILE *fpin, *fpout; Integer exit_status = 0; Integer k; double plek, peqk, pgtk; double rlamda; 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); fprintf(fpout, "nag_poisson_dist (g01bkc) Example Program Results\n"); /* Skip heading in data file */ fscanf(fpin, "%*[^\n] "); fprintf(fpout, "\n rlamda k plek pgtk peqk\n\n"); while ((fscanf(fpin, "%lf %ld%*[^\n] ", &rlamda, &k)) != EOF) { /* nag_poisson_dist (g01bkc). * Poisson distribution function */ nag_poisson_dist(rlamda, k, &plek, &pgtk, &peqk, &fail); if (fail.code != NE_NOERROR) { fprintf(fpout, "Error from nag_poisson_dist (g01bkc).\n%s\n", fail.message); exit_status = 1; goto END; } fprintf(fpout, " %10.3f%6ld%10.5f%10.5f%10.5f\n", rlamda, k, plek, pgtk, peqk); } END: if (fpin != stdin) fclose(fpin); if (fpout != stdout) fclose(fpout); return exit_status; }