/* nag_deviates_landau (g01ftc) Example Program.
 *
 * Copyright 2014 Numerical Algorithms Group.
 *
 * Mark 7, 2002.
 */

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

int main(void)
{
  /* Scalars */
  double   x, y;
  Integer  exit_status;
  NagError fail;

  INIT_FAIL(fail);

  exit_status = 0;

  printf(" nag_deviates_landau (g01ftc) Example Program Results\n");

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

  /* nag_deviates_landau (g01ftc).
   * Landau inverse function Psi(x)
   */
  y = nag_deviates_landau(x, &fail);

  if (fail.code == NE_NOERROR)
    {
      printf("\n   X          Y\n\n");
      printf("  %3.1f   %13.4e\n", x, y);
    }
  else
    {
      printf("Error from nag_deviates_landau (g01ftc).\n%s\n",
              fail.message);
      exit_status = 1;
      goto END;
    }
 END:
  return exit_status;
}