From 0f04e97fa748b6740da4c9512b596d7d3a2788c5 Mon Sep 17 00:00:00 2001 From: Tavian Barnes Date: Wed, 6 Oct 2010 16:47:04 -0400 Subject: Add the Euler method. --- src/vZ/Simple.hpp | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) (limited to 'src/vZ/Simple.hpp') diff --git a/src/vZ/Simple.hpp b/src/vZ/Simple.hpp index 103357e..9d9be46 100644 --- a/src/vZ/Simple.hpp +++ b/src/vZ/Simple.hpp @@ -26,22 +26,23 @@ namespace vZ { // Base class for non-adaptive RK-style algorithms - template - class GenericSimpleIntegrator : public GenericRKIntegrator + template + class GenericSimpleIntegrator : public GenericRKIntegrator { public: - typedef typename GenericIntegrator::Function Function; + typedef typename GenericRKIntegrator::Scalar Scalar; + typedef typename GenericRKIntegrator::Function Function; protected: - typedef typename GenericRKIntegrator::ACoefficients ACoefficients; - typedef typename GenericRKIntegrator::BCoefficients BCoefficients; + typedef typename GenericRKIntegrator::ACoefficients ACoefficients; + typedef typename GenericRKIntegrator::BCoefficients BCoefficients; + typedef typename GenericRKIntegrator::KVector KVector; - GenericSimpleIntegrator(Function f, T dt, - ACoefficients a, BCoefficients b) - : GenericIntegrator(f, dt), m_a(a), m_b(b) { } + GenericSimpleIntegrator(Function f, ACoefficients a, BCoefficients b) + : GenericRKIntegrator(f), m_a(a), m_b(b) { } virtual ~GenericSimpleIntegrator() { } - virtual void step(T& t, T& dt); + void step(); private: ACoefficients m_a; @@ -53,10 +54,12 @@ namespace vZ // Implementations - template + template void - GenericSimpleIntegrator::step(T& t, T& dt) + GenericSimpleIntegrator::step() { + this->y(calculateY(calculateK(m_a), m_b)); + this->x(this->x() + this->h()); } } -- cgit v1.2.3