/* nag_prob_von_mises (g01erc) Example Program.
 *
 * Copyright 2014 Numerical Algorithms Group.
 *
 * Mark 7, 2001.
 */

#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("%ld%*[^\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;
}