/* nag_quad_1d_gauss_wset (d01tbc) Example Program. * * Copyright 2011, Numerical Algorithms Group. * * Mark 23, 2011. */ #include #include #include #include int main(void) { Integer exit_status = 0; Integer n; double a, b; Integer i; Nag_QuadType quadtype; NagError fail; double *abscis = 0, *weight = 0; INIT_FAIL(fail); printf("nag_quad_1d_gauss_wset (d01tbc) Example Program Results\n"); /* Skip heading in data file */ scanf("%*[^\n] "); /* Input a, b and n */ scanf("%lf %lf", &a, &b); scanf("%ld%*[^\n] ", &n); quadtype = Nag_Quad_Gauss_Laguerre_Adjusted; if (!(abscis = NAG_ALLOC(n, double)) || !(weight = NAG_ALLOC(n, double))) { printf("Allocation failure\n"); exit_status = -1; goto END; } /* nag_quad_1d_gauss_wset (d01tbc). * Pre-computed weights and abscissae for * Gaussian quadrature rules, restricted choice of rule. */ nag_quad_1d_gauss_wset(quadtype, a, b, n, weight, abscis, &fail); if (fail.code != NE_NOERROR) { printf("Error from nag_quad_1d_gauss_wset (d01tbc).\n%s\n", fail.message); exit_status = 1; goto END; } printf("\nLaguerre formula, %3ld points\n\n" " Abscissae Weights\n\n", n); for (i = 0; i < n; i++) { printf("%15.6e", abscis[i]); printf("%15.6e\n", weight[i]); } printf("\n"); END: NAG_FREE(abscis); NAG_FREE(weight); return exit_status; }