/* nag_2d_spline_fit_grid (e02dcc) Example Program. * * Copyright 1991 Numerical Algorithms Group. * * Mark 2, 1991. * * Mark 6 revised, 2000. * Mark 8 revised, 2004. */ #include #include #include #include int main(void) { Integer exit_status=0, i, j, mx, my, npx, npy, nx, ny; NagError fail; Nag_2dSpline spline; Nag_Comm warmstartinf; Nag_Start start; double delta, *f=0, *fg=0, fp, *px=0, *py=0, s, *x=0, xhi, xlo, *y=0, yhi; double ylo; INIT_FAIL(fail); Vprintf("nag_2d_spline_fit_grid (e02dcc) Example Program Results\n"); Vscanf("%*[^\n]"); /* Skip heading in data file */ /* Input the number of x, y co-ordinates mx, my. */ Vscanf("%ld%ld",&mx,&my); if (mx>=4 && my>=4) { if ( !( f = NAG_ALLOC(mx*my, double)) || !( x = NAG_ALLOC(mx, double)) || !( y = NAG_ALLOC(my, double)) ) { Vprintf("Allocation failure\n"); exit_status = -1; goto END; } } else { Vprintf("Invalid mx or my.\n"); exit_status = 1; return exit_status; } /* Input the x co-ordinates followed by the y co-ordinates. */ for (i=0; i=1 && npy>=1) { if ( !( fg = NAG_ALLOC(npx*npy, double)) || !( px = NAG_ALLOC(npx, double)) || !( py = NAG_ALLOC(npy, double)) ) { Vprintf("Allocation failure\n"); exit_status = -1; goto END; } } else { Vprintf("Invalid npx or npy.\n"); exit_status = 1; return exit_status; } delta = (xhi-xlo) / (npx-1); for (i=0; i=0; i--) { Vprintf("%7.2f ",py[i]); for (j=0; j