NAG Library Manual, Mark 27.3
Interfaces:  FL   CL   CPP   AD 

NAG CL Interface Introduction
Example description
/* nag_stat_pdf_gamma (g01kfc) Example Program.
 *
 * Copyright 2021 Numerical Algorithms Group.
 *
 * Mark 27.3, 2021.
 */

/* Pre-processor includes */
#include <math.h>
#include <nag.h>
#include <stdio.h>
#include <string.h>

int main(void) {
  /*Integer scalar and array declarations */
  Integer exit_status = 0;
  Integer i, ndata;
  /*Double scalar and array declarations */
  double a, b, f, x;
  /* Nag Types */
  NagError fail;

  INIT_FAIL(fail);

  printf("nag_stat_pdf_gamma (g01kfc) Example Program Results\n\n");
  scanf("%*[^\n] ");
  scanf("%" NAG_IFMT "%*[^\n] ", &ndata);
  printf("%14s%16s%16s%16s\n\n", "X", "A", "B", "RESULT");
  for (i = 0; i < ndata; i++) {
    scanf("%lf%lf%lf%*[^\n] ", &x, &a, &b);
    /*
     * nag_stat_pdf_gamma (g01kfc)
     * Calculates the value for the probability density function of
     * the gamma distribution at a chosen point.
     */
    f = nag_stat_pdf_gamma(x, a, b, &fail);
    if (fail.code != NE_NOERROR) {
      printf("Error from nag_stat_pdf_gamma (g01kfc).\n%s\n", fail.message);
      exit_status = 1;
      goto END;
    }
    printf("%18.4e%16.4e%16.4e%16.4e\n", x, a, b, f);
  }

END:

  return exit_status;
}