00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef O2SCL_NONADAPT_STEP_H
00025 #define O2SCL_NONADAPT_STEP_H
00026
00027 #include <o2scl/adapt_step.h>
00028 #include <gsl/gsl_math.h>
00029 #include <gsl/gsl_odeiv.h>
00030
00031 #ifndef DOXYGENP
00032 namespace o2scl {
00033 #endif
00034
00035
00036
00037 template<class param_t, class func_t, class vec_t=ovector_view,
00038 class alloc_vec_t=ovector, class alloc_t=ovector_alloc>
00039 class nonadapt_step :
00040 public adapt_step<param_t,func_t,vec_t,alloc_vec_t,alloc_t> {
00041
00042 public:
00043
00044 nonadapt_step() {
00045 }
00046
00047 virtual ~nonadapt_step() {}
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057 virtual int astep(double &x, double &h, double xmax, size_t n,
00058 vec_t &y, param_t &pa, func_t &derivs)
00059 {
00060 alloc_vec_t dydx, yerr;
00061
00062 ao.allocate(dydx,n);
00063 ao.allocate(yerr,n);
00064
00065 derivs(x,n,y,dydx,pa);
00066 int ret=this->stepp->step(x,h,n,y,dydx,y,yerr,dydx,pa,derivs);
00067 x+=h;
00068
00069 ao.free(dydx);
00070 ao.free(yerr);
00071
00072 return ret;
00073 }
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083 virtual int astep_derivs(double &x, double &h, double xmax, size_t n,
00084 vec_t &y, vec_t &dydx, param_t &pa,
00085 func_t &derivs)
00086 {
00087 alloc_vec_t yerr;
00088
00089 ao.allocate(yerr,n);
00090
00091 int ret=this->stepp->step(x,h,n,y,dydx,y,yerr,dydx,pa,derivs);
00092 x+=h;
00093
00094 ao.free(yerr);
00095
00096 return ret;
00097 }
00098
00099 #ifndef DOXYGEN_INTERNAL
00100
00101 protected:
00102
00103
00104 alloc_t ao;
00105
00106 #endif
00107
00108 };
00109
00110 #ifndef DOXYGENP
00111 }
00112 #endif
00113
00114 #endif