/* nag_scaled_log_gamma (s14ahc) Example Program.
 *
 * Copyright 2017 Numerical Algorithms Group.
 *
 * Mark 26.1, 2017.
 */
/* Pre-processor includes */
#include <stdio.h>
#include <nag.h>
#include <nag_stdlib.h>
#include <nags.h>

int main(void)
{
  /*Integer scalar and array declarations */
  Integer exit_status = 0;
  /*Double scalar and array declarations */
  double x, y;
  NagError fail;

  INIT_FAIL(fail);

  printf("nag_scaled_log_gamma (s14ahc) Example Program Results\n");
  /* Skip heading in data file */
  scanf("%*[^\n] ");
  printf("\n%s\n\n", "       x          y");
  while (scanf("%lf%*[^\n] ", &x) != EOF)
  {
    /*
     * nag_scaled_log_gamma (s14ahc)
     * Scaled logarithm of Gamma function, G(x)
     */
    y = nag_scaled_log_gamma(x, &fail);
    if (fail.code != NE_NOERROR) {
      printf("Error from nag_scaled_log_gamma (s14ahc) %s\n", fail.message);
      exit_status = 1;
      goto END;
    }
    printf("%14.5e%14.5e\n", x, y);
  }

END:
  return exit_status;
}