/* nag_1d_ratnl_eval (e01rbc) Example Program. * * Copyright 2001 Numerical Algorithms Group. * * Mark 7, 2001. */ #include #include #include #include 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); Vprintf("nag_1d_ratnl_eval (e01rbc) Example Program Results\n"); /* Skip heading in data file */ Vscanf("%*[^\n] "); m = 4; /* Allocate memory */ if ( !(a = NAG_ALLOC(m, double)) || !(u = NAG_ALLOC(m, double)) ) { Vprintf("Allocation failure\n"); exit_status = -1; goto END; } for (i = 1; i <= m; ++i) Vscanf("%lf", &a[i-1]); Vscanf("%*[^\n] "); for (i = 1; i <= m - 1; ++i) Vscanf("%lf", &u[i-1]); Vscanf("%*[^\n] "); Vscanf("%lf%*[^\n] ", &x); Vprintf("\n"); Vprintf("x = %11.4e\n", x); /* nag_1d_ratnl_eval (e01rbc). * Interpolated values, evaluate rational interpolant * computed by nag_1d_ratnl_interp (e01rac), one variable */ nag_1d_ratnl_eval(m, a, u, x, &f, &fail); Vprintf("\n"); Vprintf("The value of R(x) is %12.4e\n", f); END: if (a) NAG_FREE(a); if (u) NAG_FREE(u); return exit_status; }