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