/* nag_zero_nonlin_eqns_deriv (c05pbc) Example Program. * * Copyright 1991 Numerical Algorithms Group. * * Mark 2, 1991. * Mark 7 revised, 2001. * Mark 8 revised, 2004. */ #include #include #include #include #include #include #ifdef __cplusplus extern "C" { #endif static void f(Integer n, double x[], double fvec[], double fjac[], Integer tdfjac, Integer *userflag); #ifdef __cplusplus } #endif int main(void) { Integer exit_status=0, j, n=9, tdfjac; NagError fail; double *fjac=0, *fvec=0, *x=0, xtol; INIT_FAIL(fail); Vprintf("nag_zero_nonlin_eqns_deriv (c05pbc) Example Program Results\n"); /* The following starting values provide a rough solution. */ if (n>0) { if ( !( fjac = NAG_ALLOC(n*n, double)) || !( fvec = NAG_ALLOC(n, double)) || !( x = 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 (j=0; j0) fvec[k] -= x[k-1]; if (k0) FJAC(k,k-1) = -1.0; if (k