/* nag_ode_ivp_rk_interp (d02pxc) Example Program. * * Copyright 1992 Numerical Algorithms Group. * * Mark 3, 1992. * Mark 7 revised, 2001. * Mark 8 revised, 2004. * */ #include #include #include #include #include #include #ifdef __cplusplus extern "C" { #endif static void f(Integer neq, double t1, double y[], double yp[], Nag_User *comm); #ifdef __cplusplus } #endif #define NEQ 2 #define NWANT 1 #define ZERO 0.0 #define ONE 1.0 #define TWO 2.0 #define FOUR 4.0 int main(void) { Integer exit_status=0, i, j, neq, nout, nwant; NagError fail; Nag_ErrorAssess errass; Nag_ODE_RK opt; Nag_RK_method method; Nag_User comm; double hstart, pi, tend, *thres=0, tinc, tnow, tol, tstart, twant, *ynow=0; double *ypnow=0, *ypwant=0, *ystart=0, *ywant=0; INIT_FAIL(fail); Vprintf("nag_ode_ivp_rk_interp (d02pxc) Example Program Results\n"); /* Set initial conditions and input for nag_ode_ivp_rk_setup (d02pvc) */ neq = NEQ; nwant = NWANT; if (neq>=1) { if ( !( thres = NAG_ALLOC(neq, double)) || !( ynow = NAG_ALLOC(neq, double)) || !( ypnow = NAG_ALLOC(neq, double)) || !( ystart = NAG_ALLOC(neq, double)) || !( ywant = NAG_ALLOC(nwant, double))|| !( ypwant = NAG_ALLOC(nwant, double)) ) { Vprintf("Allocation failure\n"); exit_status = -1; goto END; } } else { exit_status = 1; return exit_status; } method = Nag_RK_4_5; /* nag_pi (x01aac). * pi */ pi = X01AAC; tstart = ZERO; ystart[0] = ZERO; ystart[1] = ONE; tend = TWO*pi; for (i=0; i