void GetSol(void *cpode_mem, N_Vector yy0, realtype tol, realtype tout, booleantype proj, N_Vector yref) { N_Vector yy, yp; realtype t, x, y, xd, yd, g; int flag; long int nst, nfe, nsetups, nje, nfeLS, ncfn, netf; if (proj) { printf(" YES "); CPodeSetProjFrequency(cpode_mem, 1); } else { CPodeSetProjFrequency(cpode_mem, 0); printf(" NO "); } yy = N_VNew_Serial(4); yp = N_VNew_Serial(4); flag = CPodeReInit(cpode_mem, (void *)f, NULL, 0.0, yy0, NULL, CP_SS, tol, &tol); flag = CPode(cpode_mem, tout, &t, yy, yp, CP_NORMAL_TSTOP); x = Ith(yy,1); y = Ith(yy,2); g = ABS(x*x + y*y - 1.0); N_VLinearSum(1.0, yy, -1.0, yref, yy); N_VAbs(yy, yy); x = Ith(yy,1); y = Ith(yy,2); xd = Ith(yy,3); yd = Ith(yy,4); printf("%9.2e %9.2e %9.2e %9.2e | %9.2e |", Ith(yy,1),Ith(yy,2),Ith(yy,3),Ith(yy,4),g); CPodeGetNumSteps(cpode_mem, &nst); CPodeGetNumFctEvals(cpode_mem, &nfe); CPodeGetNumLinSolvSetups(cpode_mem, &nsetups); CPodeGetNumErrTestFails(cpode_mem, &netf); CPodeGetNumNonlinSolvConvFails(cpode_mem, &ncfn); CPDlsGetNumJacEvals(cpode_mem, &nje); CPDlsGetNumFctEvals(cpode_mem, &nfeLS); printf(" %6ld %6ld+%-4ld %4ld (%3ld) | %3ld %3ld\n", nst, nfe, nfeLS, nsetups, nje, ncfn, netf); N_VDestroy_Serial(yy); N_VDestroy_Serial(yp); return; }
static real KINScSteplength(KINMem kin_mem, N_Vector ucur, N_Vector ss, N_Vector usc) { N_VInv(usc, vtemp1); N_VAbs(ucur, vtemp2); N_VLinearSum(ONE, vtemp1, ONE, vtemp2, vtemp1); N_VDiv(ss, vtemp1, vtemp1); return(N_VMaxNorm(vtemp1)); }
void N_VAbs_SensWrapper(N_Vector x, N_Vector z) { int i; for (i=0; i < NV_NVECS_SW(x); i++) N_VAbs(NV_VEC_SW(x,i), NV_VEC_SW(z,i)); return; }
static real KINScFNorm(N_Vector vv, N_Vector scale, N_Vector wrkv) { N_VAbs(vv, wrkv); N_VProd(scale, wrkv, wrkv); return(N_VMaxNorm(wrkv)); }