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

NAG CL Interface Introduction
Example description
/* nag_quad_md_numth_coeff_prime (d01gyc) Example Program.
 *
 * Copyright 2024 Numerical Algorithms Group.
 *
 * Mark 30.2, 2024.
 */

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

int main(void) {
  Integer exit_status = 0;
  Integer i, ndim, npts;
  double *vk = 0;
  NagError fail;

  INIT_FAIL(fail);

  printf("nag_quad_md_numth_coeff_prime (d01gyc) Example Program Results\n");
  /* Skip heading in data file */
  scanf("%*[^\n] ");
  scanf("%" NAG_IFMT "", &ndim);
  scanf("%" NAG_IFMT "%*[^\n] ", &npts);

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

  /* nag_quad_md_numth_coeff_prime (d01gyc).
   * Korobov optimal coefficients for use in nag_quad_md_numth_vec (d01gdc),
   * when number of points is prime.
   */
  nag_quad_md_numth_coeff_prime(ndim, npts, vk, &fail);
  if (fail.code != NE_NOERROR) {
    printf("Error from nag_quad_md_numth_coeff_prime (d01gyc).\n%s\n",
           fail.message);
    exit_status = 1;
    goto END;
  }

  printf("\nndim = %3" NAG_IFMT " npts = %6" NAG_IFMT "\n", ndim, npts);
  printf("\nCoefficients =");
  for (i = 0; i < ndim; i++)
    printf("%4.0f ", vk[i]);
  printf("\n");

END:
  NAG_FREE(vk);

  return exit_status;
}