template struct StepperStoerm : StepperBS { using StepperBS::x; using StepperBS::xold; using StepperBS::y; using StepperBS::dydx; using StepperBS::dense; using StepperBS::n; using StepperBS::KMAXX; using StepperBS::IMAXX; using StepperBS::nseq; using StepperBS::cost; using StepperBS::mu; using StepperBS::errfac; using StepperBS::ysave; using StepperBS::fsave; using StepperBS::dens; using StepperBS::neqn; MatDoub ysavep; StepperStoerm(VecDoub_IO &yy, VecDoub_IO &dydxx, Doub &xx, const Doub atol, const Doub rtol, bool dens); void dy(VecDoub_I &y, const Doub htot, const Int k, VecDoub_O ¥d, Int &ipt,D &derivs); void prepare_dense(const Doub h,VecDoub_I &dydxnew, VecDoub_I &ysav, VecDoub_I &scale, const Int k, Doub &error); Doub dense_out(const Int i,const Doub x,const Doub h); void dense_interp(const Int n, VecDoub_IO &y, const Int imit); }; template StepperStoerm::StepperStoerm(VecDoub_IO &yy, VecDoub_IO &dydxx, Doub &xx, const Doub atoll,const Doub rtoll, bool dens) : StepperBS(yy,dydxx,xx,atoll,rtoll,dens),ysavep(IMAXX,n/2) { neqn=n/2; cost[0]=nseq[0]/2+1; for (Int k=0;k void StepperStoerm::prepare_dense(const Doub h,VecDoub_I &dydxnew, VecDoub_I &ysav,VecDoub_I &scale,const Int k, Doub &error) { Doub h2=h*h; mu=MAX(1,2*k-3); for (Int i=0; i=1; l--) { Doub factor=SQR(dblenj/nseq[l-1])-1.0; for (Int i=0; i=kbeg+1; l--) { Doub factor=SQR(dblenj/nseq[l-1])-1.0; for (Int i=0; i=lbeg; l--) for (Int i=0; i= 1) { for (Int i=0; i Doub StepperStoerm::dense_out(const Int i,const Doub x,const Doub h) { Doub theta=(x-xold)/h; Doub theta1=1.0-theta; Int neqn=n/2; if (i>=neqn) throw("no dense output for y' in StepperStoerm"); Doub yinterp=dens[i]+theta*(dens[neqn+i]+theta1*(dens[2*neqn+i]+ theta*(dens[3*neqn+i]+theta1*(dens[4*neqn+i]*theta+ dens[5*neqn+i]*theta1)))); if (mu<0) return yinterp; Doub theta05=theta-0.5; Doub t4=theta*theta1; Doub c=dens[neqn*(mu+6)+i]; for (Int j=mu;j>0; j--) c=dens[neqn*(j+5)+i]+c*theta05/j; yinterp += t4*t4*t4*c; return yinterp; } template void StepperStoerm::dense_interp(const Int n, VecDoub_IO &y, const Int imit) { Doub y0,y1,yp0,yp1,ypp0,ypp1,ydiff,ah,bh,ch,dh,eh,fh,gh,abh,gfh,gmf, ph0,ph1,ph2,ph3,ph4,ph5,fc1,fc2,fc3; VecDoub a(41); for (Int i=0; i= 1) { a[1]=64.0*(y[7*n+i]-ph1); if (imit >= 3) { a[3]=64.0*(y[9*n+i]-ph3+a[1]*9.0/8.0); if (imit >= 5) { a[5]=64.0*(y[11*n+i]-ph5+a[3]*15.0/4.0-a[1]*90.0); for (Int im=7; im <=imit; im+=2) { fc1=im*(im-1)*3.0/16.0; fc2=fc1*(im-2)*(im-3)*4.0; fc3=im*(im-1)*(im-2)*(im-3)*(im-4)*(im-5); a[im]=64.0*(y[(im+6)*n+i]+fc1*a[im-2]-fc2*a[im-4]+fc3*a[im-6]); } } } } a[0]=64.0*(y[6*n+i]-ph0); if (imit >= 2) { a[2]=64.0*(y[n*8+i]-ph2+a[0]*3.0/8.0); if (imit >= 4) { a[4]=64.0*(y[n*10+i]-ph4+a[2]*9.0/4.0-a[0]*18.0); for (Int im=6; im<=imit; im+=2) { fc1=im*(im-1)*3.0/16.0; fc2=fc1*(im-2)*(im-3)*4.0; fc3=im*(im-1)*(im-2)*(im-3)*(im-4)*(im-5); a[im]=64.0*(y[n*(im+6)+i]+a[im-2]*fc1-a[im-4]*fc2+a[im-6]*fc3); } } } for (Int im=0; im<=imit; im++) y[n*(im+6)+i]=a[im]; } } template void StepperStoerm::dy(VecDoub_I &y, const Doub htot, const Int k, VecDoub_O ¥d, Int &ipt, D &derivs) { VecDoub ytemp(n); Int nstep=nseq[k]; Doub h=htot/nstep; Doub h2=2.0*h; for (Int i=0;i