/* nag_2d_spline_eval (e02dec) Example Program. * * Copyright 1991 Numerical Algorithms Group. * * Mark 2, 1991. * Mark 8 revised, 2004. */ #include #include #include #include int main(void) { Integer exit_status=0, i, m; NagError fail; Nag_2dSpline spline; double *ff=0, *x=0, *y=0; INIT_FAIL(fail); Vprintf("nag_2d_spline_eval (e02dec) Example Program Results\n"); Vscanf("%*[^\n]"); /* Skip heading in data file */ /* Read m, the number of spline evaluation points. */ Vscanf("%ld",&m); if (m>=1) { if ( !( x = NAG_ALLOC(m, double)) || !( y = NAG_ALLOC(m, double)) || !( ff = NAG_ALLOC(m, double)) ) { Vprintf("Allocation failure\n"); exit_status = -1; goto END; } } else { Vprintf("Invalid m.\n"); exit_status = 1; return exit_status; } /* Read nx and ny, the number of knots in the x and y directions. */ Vscanf("%ld%ld",&(spline.nx),&(spline.ny)) ; if (spline.nx>=8 && spline.ny>=8 ) { if ( !(spline.c = NAG_ALLOC((spline.nx-4)*(spline.ny-4), double)) || !(spline.lamda = NAG_ALLOC(spline.nx, double)) || !(spline.mu = NAG_ALLOC(spline.ny, double)) ) { Vprintf("Allocation failure\n"); exit_status = -1; goto END; } } else { Vprintf("Invalid spline.nx or spline.ny.\n"); exit_status = 1; return exit_status; } /* read the knots lamda[0] .. lamda[nx-1] and mu[0] .. mu[ny-1]. */ for (i=0; i