/* nag_interp_dim1_ratnl_eval (e01rbc) Example Program.
*
* Copyright 2024 Numerical Algorithms Group.
*
* Mark 30.3, 2024.
*/
#include <nag.h>
#include <stdio.h>
int main(void) {
/* Scalars */
double f, x;
Integer exit_status, i, m;
NagError fail;
/* Arrays */
double *a = 0, *u = 0;
exit_status = 0;
INIT_FAIL(fail);
printf("nag_interp_dim1_ratnl_eval (e01rbc) Example Program Results\n");
/* Skip heading in data file */
scanf("%*[^\n] ");
m = 4;
/* Allocate memory */
if (!(a = NAG_ALLOC(m, double)) || !(u = NAG_ALLOC(m, double))) {
printf("Allocation failure\n");
exit_status = -1;
goto END;
}
for (i = 1; i <= m; ++i)
scanf("%lf", &a[i - 1]);
scanf("%*[^\n] ");
for (i = 1; i <= m - 1; ++i)
scanf("%lf", &u[i - 1]);
scanf("%*[^\n] ");
scanf("%lf%*[^\n] ", &x);
printf("\n");
printf("x = %13.4e\n", x);
/* nag_interp_dim1_ratnl_eval (e01rbc).
* Interpolated values, evaluate rational interpolant
* computed by nag_interp_dim1_ratnl (e01rac), one variable
*/
nag_interp_dim1_ratnl_eval(m, a, u, x, &f, &fail);
if (fail.code == NE_NOERROR) {
printf("\n");
printf("The value of R(x) is %13.4e\n", f);
} else {
printf("Error from nag_interp_dim1_ratnl_eval (e01rbc).\n%s\n",
fail.message);
exit_status = 1;
}
END:
NAG_FREE(a);
NAG_FREE(u);
return exit_status;
}