/* nag_1d_spline_fit (e02bec) 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, j, m, nest, r; NagError fail; Nag_Comm warmstartinf; Nag_Spline spline; Nag_Start start; double fp, s, *sp=0, txr, *weights=0, *x=0, *y=0; INIT_FAIL(fail); Vprintf("nag_1d_spline_fit (e02bec) Example Program Results\n"); Vscanf("%*[^\n]"); /* Skip heading in data file */ /* Input the number of data points, followed by the data * points x, the function values y and the weights w. */ Vscanf("%ld",&m); nest = m + 4; if (m>=4) { if ( !( weights = NAG_ALLOC(m, double)) || !( x = NAG_ALLOC(m, double)) || !( y = NAG_ALLOC(m, double)) || !( sp = NAG_ALLOC(2*m-1, double)) ) { Vprintf("Allocation failure\n"); exit_status = -1; goto END; } } else { Vprintf("Invalid m.\n"); exit_status = 1; return exit_status; } start = Nag_Cold; for (r=0; r