Listing 2: Euler class definition and the implementation of the Euler integrator.
template <class C, class T, class B /* base type of C */>
class Euler : public Integrator<C,T>
{
private:
C dxdt;
public:
Euler (const C &x0, const T t0, const T h_init,
void (*dxdt_calc)(const C&, const T, C&))
: Integrator <C,T> (x0, t0, h_init, dxdt_calc),
dxdt(x0) { }
void step(void);
};
template <class C, class T, class B>
void Euler<C,T,B>::step(void)
{
return_derivs(statevector,t,dxdt);
statevector += B(h)*dxdt;
t += h;
}