/* nag_1d_spline_fit_knots (e02bac) Example Program. * * Copyright 1996 Numerical Algorithms Group. * * Mark 4, 1996. * * Mark 6 revised, 2000. * Mark 8 revised, 2004. */ #include #include #include #include int main(void) { Integer exit_status=0, j, m, ncap, ncap7, r, wght; NagError fail; Nag_Spline spline; double fit, ss, *weights=0, *x=0, xarg, *y=0; INIT_FAIL(fail); Vprintf("nag_1d_spline_fit_knots (e02bac) Example Program Results\n"); Vscanf("%*[^\n]"); /* Skip heading in data file */ while(scanf("%ld",&m) != EOF) { if (m>=4) { if ( !( weights = NAG_ALLOC(m, double)) || !( x = NAG_ALLOC(m, double)) || !( y = NAG_ALLOC(m, double)) ) { Vprintf("Allocation failure\n"); exit_status = -1; goto END; } } else { Vprintf("Invalid m.\n"); exit_status = 1; return exit_status; } Vscanf("%ld%ld",&ncap,&wght); if (ncap>0) { ncap7 = ncap+7; spline.n = ncap7; if ( !( spline.lamda = NAG_ALLOC(ncap7, double)) ) { Vprintf("Allocation failure\n"); exit_status = -1; goto END; } } else { Vprintf("Invalid ncap.\n"); exit_status = 1; return exit_status; } for (j=4; j