/* nag_ode_bvp_fd_nonlin_fixedbc (d02gac) Example Program. * * Copyright 1992 Numerical Algorithms Group. * * Mark 3, 1992. * Mark 7 revised, 2001. * Mark 8 revised, 2004. * */ #include #include #include #include #ifdef __cplusplus extern "C" { #endif static void fcn(Integer neq, double x, double y[], double f[], Nag_User *comm); #ifdef __cplusplus } #endif #define NEQ 3 #define MNP 40 #define U(I,J) u[(I)*tdu + J] #define Y(I,J) y[(I)*tdy + J] #define V(I,J) v[(I)*tdv + J] int main(void) { Integer exit_status=0, i, j, k, mnp, neq, np, tdu, tdv, tdy, *v=0; NagError fail; Nag_User comm; double a, b, beta, tol, *u=0, *x=0, *y=0; INIT_FAIL(fail); Vprintf("nag_ode_bvp_fd_nonlin_fixedbc (d02gac) Example Program Results\n"); /* For communication with function fcn() * assign address of beta to comm.p. */ comm.p = (Pointer)β neq = NEQ; mnp = MNP; tol = 0.001; np = 26; a = 0.0; b = 10.0; beta = 0.0; if (mnp>=32 && neq>=2) { if ( !( u = NAG_ALLOC(neq*2, double)) || !( x = NAG_ALLOC(mnp, double)) || !( y = NAG_ALLOC(neq*mnp, double)) || !( v = NAG_ALLOC(neq*2, Integer)) ) { Vprintf("Allocation failure\n"); exit_status = -1; goto END; } tdu = 2; tdy = mnp; tdv = 2; } else { exit_status = 1; return exit_status; } for (i=0; ip; f[0] = y[1]; f[1] = y[2]; f[2] = -y[0] * y[2] - *beta * (1.0-y[1]*y[1]); }