/* nag_specfun_gamma_incomplete_vector (s14bnc) Example Program.
*
* Copyright 2024 Numerical Algorithms Group.
*
* Mark 30.0, 2024.
*/
#include <nag.h>
#include <stdio.h>
int main(void) {
Integer exit_status = 0;
Integer i, n;
double tol;
double *p = 0, *q = 0, *a = 0, *x = 0;
Integer *ivalid = 0;
/* Nag Types */
NagError fail;
INIT_FAIL(fail);
tol = nag_machine_precision;
/* Skip heading in data file */
scanf("%*[^\n]");
printf(
"nag_specfun_gamma_incomplete_vector (s14bnc) Example Program Results\n");
printf("\n");
printf(" a x p q ivalid\n");
printf("\n");
scanf("%" NAG_IFMT "", &n);
scanf("%*[^\n]");
/* Allocate memory */
if (!(a = NAG_ALLOC(n, double)) || !(x = NAG_ALLOC(n, double)) ||
!(p = NAG_ALLOC(n, double)) || !(q = NAG_ALLOC(n, double)) ||
!(ivalid = NAG_ALLOC(n, Integer))) {
printf("Allocation failure\n");
exit_status = -1;
goto END;
}
for (i = 0; i < n; i++)
scanf("%lf%lf", &a[i], &x[i]);
scanf("%*[^\n]");
/* nag_specfun_gamma_incomplete_vector (s14bnc). */
nag_specfun_gamma_incomplete_vector(n, a, x, tol, p, q, ivalid, &fail);
if (fail.code != NE_NOERROR && fail.code != NW_IVALID) {
printf("Error from nag_specfun_gamma_incomplete_vector (s14bnc).\n%s\n",
fail.message);
exit_status = 1;
goto END;
}
for (i = 0; i < n; i++)
printf(" %11.3e %11.3e %11.3e %11.3e %4" NAG_IFMT "\n", a[i], x[i], p[i],
q[i], ivalid[i]);
END:
NAG_FREE(p);
NAG_FREE(q);
NAG_FREE(a);
NAG_FREE(x);
NAG_FREE(ivalid);
return exit_status;
}