/* nag_1d_cheb_eval2 (e02akc) Example Program. * * Copyright 2001 Numerical Algorithms Group. * * Mark 7, 2001. */ #include #include #include #include #include int main(int argc, char *argv[]) { FILE *fpout; /* Initialized data */ const double xmin = -0.5; const double xmax = 2.5; const double a[7] = { 2.53213, 1.13032, 0.2715, 0.04434, 0.00547, 5.4e-4, 4e-5 }; /* Scalars */ double p, x; Integer exit_status, i, m, n, one; NagError fail; INIT_FAIL(fail); /* Check for command-line IO options */ fpout = nag_example_file_io(argc, argv, "-results", NULL); exit_status = 0; fprintf(fpout, "nag_1d_cheb_eval2 (e02akc) Example Program Results\n"); n = 6; one = 1; fprintf(fpout, "\n"); fprintf(fpout, " i Argument Value of polynomial\n"); m = 4; for (i = 1; i <= m; ++i) { x = (xmin * (double)(m - i) + xmax * (double)(i - 1)) / (double)(m - 1); /* nag_1d_cheb_eval2 (e02akc). * Evaluation of fitted polynomial in one variable from * Chebyshev series form */ nag_1d_cheb_eval2(n, xmin, xmax, a, one, x, &p, &fail); if (fail.code != NE_NOERROR) { fprintf(fpout, "Error from nag_1d_cheb_eval2 (e02akc).\n%s\n", fail.message); exit_status = 1; goto END; } fprintf(fpout, "%4ld%10.4f %9.4f\n", i, x, p); } END: if (fpout != stdout) fclose(fpout); return exit_status; }