/* nag_prob_von_mises (g01erc) Example Program.
 *
 * NAGPRODCODE Version.
 *
 * Copyright 2016 Numerical Algorithms Group.
 *
 * Mark 26, 2016.
 */

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

int main(void)
{

  /* Scalars */
  double p, t, vk;
  Integer exit_status, i__, n;
  NagError fail;

  INIT_FAIL(fail);

  exit_status = 0;

  printf("nag_prob_von_mises (g01erc) Example Program Results\n\n");

  /* Skip heading in data file */
  scanf("%*[^\n] ");
  scanf("%" NAG_IFMT "%*[^\n] ", &n);

  for (i__ = 1; i__ <= n; ++i__) {
    scanf("%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) {
      printf("Error from nag_prob_von_mises (g01erc).\n%s\n", fail.message);
      exit_status = 1;
      goto END;
    }
    printf(" p = %10.4f\n", p);
  }
END:
  return exit_status;
}