/* nag_specfun_beta_incomplete_vector (s14cqc) Example Program.
*
* Copyright 2023 Numerical Algorithms Group.
*
* Mark 29.1, 2023.
*/
#include <nag.h>
#include <stdio.h>
int main(void) {
Integer exit_status = 0;
Integer i, n;
double *w = 0, *w1 = 0, *a = 0, *b = 0, *x = 0;
Integer *ivalid = 0;
/* Nag Types */
NagError fail;
INIT_FAIL(fail);
/* Skip heading in data file */
scanf("%*[^\n]");
printf(
"nag_specfun_beta_incomplete_vector (s14cqc) Example Program Results\n");
printf("\n");
printf(" a b x w w1"
" ivalid\n");
printf("\n");
scanf("%" NAG_IFMT "", &n);
scanf("%*[^\n]");
/* Allocate memory */
if (!(a = NAG_ALLOC(n, double)) || !(b = NAG_ALLOC(n, double)) ||
!(x = NAG_ALLOC(n, double)) || !(w = NAG_ALLOC(n, double)) ||
!(w1 = 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%lf", &a[i], &b[i], &x[i]);
scanf("%*[^\n]");
/* nag_specfun_beta_incomplete_vector (s14cqc). */
nag_specfun_beta_incomplete_vector(n, a, b, x, w, w1, ivalid, &fail);
if (fail.code != NE_NOERROR && fail.code != NW_IVALID) {
printf("Error from nag_specfun_beta_incomplete_vector (s14cqc).\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 %11.3e %4" NAG_IFMT "\n", a[i], b[i],
x[i], w[i], w1[i], ivalid[i]);
END:
NAG_FREE(w);
NAG_FREE(w1);
NAG_FREE(a);
NAG_FREE(b);
NAG_FREE(x);
NAG_FREE(ivalid);
return exit_status;
}