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

NAG CL Interface Introduction
Example description
/* nag_stat_inv_cdf_gamma (g01ffc) Example Program.
 *
 * Copyright 2024 Numerical Algorithms Group.
 *
 * Mark 30.0, 2024.
 */

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

int main(void) {
  Integer exit_status = 0;
  double a, b, p, g;
  double tol = 0.0;
  NagError fail;

  INIT_FAIL(fail);

  /* Skip heading in data file */
  scanf("%*[^\n]");
  printf("nag_stat_inv_cdf_gamma (g01ffc) Example Program Results\n");
  printf("    p       a       b           g\n\n");
  while (scanf("%lf %lf %lf", &p, &a, &b) != EOF)
  {
    /* nag_stat_inv_cdf_gamma (g01ffc).
     * Deviates for the gamma distribution
     */
    g = nag_stat_inv_cdf_gamma(p, a, b, tol, &fail);
    if (fail.code != NE_NOERROR) {
      printf("Error from nag_stat_inv_cdf_gamma (g01ffc).\n%s\n", fail.message);
      exit_status = 1;
      goto END;
    }
    printf("%8.3f%8.3f%8.3f%10.3f\n", p, a, b, g);
  }

END:
  return exit_status;
}