Example description
/* nag_quad_dim1_gauss_wgen (d01tcc) Example Program.
 *
 * Copyright 2019 Numerical Algorithms Group.
 *
 * Mark 27.0, 2019.
 */

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

int main(void)
{
  Integer exit_status = 0;
  Integer i, n;
  double a, b, c, d;
  Nag_QuadType quadtype;
  NagError fail;
  double *abscis = 0, *weight = 0;

  INIT_FAIL(fail);

  printf("nag_quad_dim1_gauss_wgen (d01tcc) Example Program Results\n");
  /* Skip heading in data file */
  scanf("%*[^\n] ");
  /* Input a, b, c, d and n */
  scanf("%lf %lf %lf %lf", &a, &b, &c, &d);
  scanf("%" NAG_IFMT "%*[^\n] ", &n);
  quadtype = Nag_Quad_Gauss_Laguerre_Adjusted;

  if (!(abscis = NAG_ALLOC(n, double)) || !(weight = NAG_ALLOC(n, double)))
  {
    printf("Allocation failure\n");
    exit_status = -1;
    goto END;
  }

  /* nag_quad_dim1_gauss_wgen (d01tcc).
   * Calculation of weights and abscissae for
   * Gaussian quadrature rules, general choice of rule.
   */
  nag_quad_dim1_gauss_wgen(quadtype, a, b, c, d, n, weight, abscis, &fail);
  if (fail.code != NE_NOERROR) {
    printf("Error from nag_quad_dim1_gauss_wgen (d01tcc).\n%s\n", fail.message);
    exit_status = 1;
    goto END;
  }

  printf("\nLaguerre formula, %3" NAG_IFMT " points\n\n"
         "    Abscissae        Weights\n\n", n);
  for (i = 0; i < n; i++) {
    printf("%15.5e", abscis[i]);
    printf("%15.5e\n", weight[i]);
  }
  printf("\n");

END:
  NAG_FREE(abscis);
  NAG_FREE(weight);

  return exit_status;
}