diff options
author | Tavian Barnes <tavianator@gmail.com> | 2010-10-06 16:47:04 -0400 |
---|---|---|
committer | Tavian Barnes <tavianator@gmail.com> | 2010-10-06 16:47:04 -0400 |
commit | 0f04e97fa748b6740da4c9512b596d7d3a2788c5 (patch) | |
tree | eb03f2de5798c78e13c53b305758bf727403f872 /src/vZ/Simple.hpp | |
parent | 2e25da27f14566000fb34d3859bfb470bf5fd1da (diff) | |
download | vz-0f04e97fa748b6740da4c9512b596d7d3a2788c5.tar.xz |
Add the Euler method.
Diffstat (limited to 'src/vZ/Simple.hpp')
-rw-r--r-- | src/vZ/Simple.hpp | 25 |
1 files changed, 14 insertions, 11 deletions
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 <typename T> - class GenericSimpleIntegrator : public GenericRKIntegrator<T> + template <typename Y> + class GenericSimpleIntegrator : public GenericRKIntegrator<Y> { public: - typedef typename GenericIntegrator<T>::Function Function; + typedef typename GenericRKIntegrator<Y>::Scalar Scalar; + typedef typename GenericRKIntegrator<Y>::Function Function; protected: - typedef typename GenericRKIntegrator<T>::ACoefficients ACoefficients; - typedef typename GenericRKIntegrator<T>::BCoefficients BCoefficients; + typedef typename GenericRKIntegrator<Y>::ACoefficients ACoefficients; + typedef typename GenericRKIntegrator<Y>::BCoefficients BCoefficients; + typedef typename GenericRKIntegrator<Y>::KVector KVector; - GenericSimpleIntegrator(Function f, T dt, - ACoefficients a, BCoefficients b) - : GenericIntegrator<T>(f, dt), m_a(a), m_b(b) { } + GenericSimpleIntegrator(Function f, ACoefficients a, BCoefficients b) + : GenericRKIntegrator<Y>(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 <typename T> + template <typename Y> void - GenericSimpleIntegrator<T>::step(T& t, T& dt) + GenericSimpleIntegrator<Y>::step() { + this->y(calculateY(calculateK(m_a), m_b)); + this->x(this->x() + this->h()); } } |