/* nag_2d_spline_eval_rect (e02dfc) Example Program. * * Copyright 1991 Numerical Algorithms Group. * * Mark 2, 1991. * Mark 8 revised, 2004. */ #include #include #include #include #define FF(I,J) ff[my*(I)+(J)] int main(void) { Integer exit_status=0, i, j, mx, my; NagError fail; Nag_2dSpline spline; double *ff=0, *x=0, *y=0; INIT_FAIL(fail); Vprintf("nag_2d_spline_eval_rect (e02dfc) Example Program Results\n"); /* Skip heading in data file */ Vscanf("%*[^\n]"); /* Read mx and my, the number of grid points in the x and y * directions respectively. */ Vscanf("%ld%ld",&mx,&my); if (mx>=1 && my>=1) { if ( !( x = NAG_ALLOC(mx, double)) || !( y = NAG_ALLOC(my, double)) || !( ff = NAG_ALLOC(mx*my, double)) ) { Vprintf("Allocation failure\n"); exit_status = -1; goto END; } } else { Vprintf("Invalid mx or my.\n"); exit_status = 1; return exit_status; } /* Read spline.nx and spline.ny, the number of knots * in the x and y directions. */ Vscanf("%ld%ld",&(spline.nx),&(spline.ny)); 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("Storage allocation failed.\n"); exit_status = -1; goto END; } /* Read the knots spline.lamda[0]...spline.lamda[nx-1] * and spline.mu[0]...spline.mu[ny-1]. */ for (i=0; i