/* nag_monotonic_deriv (e01bgc) 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, n, r; NagError fail; double *d=0, *f=0, *pd=0, *pf=0, *px=0, step, *x=0; INIT_FAIL(fail); Vprintf("nag_monotonic_deriv (e01bgc) Example Program Results\n"); Vscanf("%*[^\n]"); /* Skip heading in data file */ Vscanf("%ld",&n); if (n>=2) { if ( !( x = NAG_ALLOC(n, double)) || !( f = NAG_ALLOC(n, double)) || !( d = NAG_ALLOC(n, double)) ) { Vprintf("Allocation failure\n"); exit_status = -1; goto END; } } else { Vprintf("Invalid n.\n"); exit_status = 1; return exit_status; } for (r=0; r=1) { if ( !( pd = NAG_ALLOC(m, double)) || !( pf = NAG_ALLOC(m, double)) || !( px = NAG_ALLOC(m, double)) ) { Vprintf("Allocation failure\n"); exit_status = -1; goto END; } } else { Vprintf("Invalid m.\n"); exit_status = 1; return exit_status; } /* compute m equally spaced points from x[0] to x[n-1]. */ step = (x[n-1]-x[0]) / (double)(m-1); for (i=0; i