From b9afb13de34b495956d5b0cee712e949052bfba8 Mon Sep 17 00:00:00 2001 From: Tavian Barnes Date: Wed, 6 Oct 2010 09:53:00 -0400 Subject: Don't use 'Real' for the template parameter. We could be dealing with vectors, etc. --- src/vZ/integrator.hpp | 30 +++++++++++++++--------------- src/vZ/simple.hpp | 16 ++++++++-------- 2 files changed, 23 insertions(+), 23 deletions(-) diff --git a/src/vZ/integrator.hpp b/src/vZ/integrator.hpp index 394f40f..a652bf6 100644 --- a/src/vZ/integrator.hpp +++ b/src/vZ/integrator.hpp @@ -32,35 +32,35 @@ namespace vZ // If the initial value problem is specified as // y' = f(t, y); y(t0) = y0 // then an Integrator could be constructed as Integrator(f, dt).y(y0).t(t0) - template + template class GenericIntegrator { public: - typedef std::tr1::function Function; + typedef std::tr1::function Function; // By default, y and t start at zero - GenericIntegrator(Function f, Real dt) + GenericIntegrator(Function f, T dt) : m_f(f), m_y(0), m_t(0), m_dt(dt) { } virtual ~GenericIntegrator() { } - GenericIntegrator& y(Real y) { m_y = y; return *this; } - GenericIntegrator& t(Real t) { m_t = t; return *this; } - GenericIntegrator& dt(Real dt) { m_dt = dt; return *this; } + GenericIntegrator& y(T y) { m_y = y; return *this; } + GenericIntegrator& t(T t) { m_t = t; return *this; } + GenericIntegrator& dt(T dt) { m_dt = dt; return *this; } - Real y() const { return m_y; } - Real t() const { return m_t; } - Real dt() const { return m_dt; } + T y() const { return m_y; } + T t() const { return m_t; } + T dt() const { return m_dt; } // Integrate until time t - void integrate(Real t_final); + void integrate(T t_final); protected: - virtual void step(Real& t, Real& dt) = 0; + virtual void step(T& t, T& dt) = 0; Function m_f; private: - Real m_y; - Real m_t, m_dt; + T m_y; + T m_t, m_dt; }; // Type alias @@ -68,9 +68,9 @@ namespace vZ // Definitions - template + template void - GenericIntegrator::integrate(Real t_final) + GenericIntegrator::integrate(T t_final) { while (m_t < t_final) { m_dt = std::min(m_dt, t_final - m_t); diff --git a/src/vZ/simple.hpp b/src/vZ/simple.hpp index 65b7560..3b02472 100644 --- a/src/vZ/simple.hpp +++ b/src/vZ/simple.hpp @@ -26,23 +26,23 @@ namespace vZ { // Base class for non-adaptive RK-style algorithms - template - class GenericSimpleIntegrator : public GenericIntegrator + template + class GenericSimpleIntegrator : public GenericIntegrator { public: - typedef typename GenericIntegrator::Function Function; + typedef typename GenericIntegrator::Function Function; // Coefficients in the tableau representation of the RK algorithm - typedef std::vector > ACoefficients; - typedef std::vector BCoefficients; + typedef std::vector > ACoefficients; + typedef std::vector BCoefficients; - GenericSimpleIntegrator(Function f, Real dt, + GenericSimpleIntegrator(Function f, T dt, ACoefficients a, BCoefficients b) - : GenericIntegrator(f, dt), m_a(a), m_b(b) { } + : GenericIntegrator(f, dt), m_a(a), m_b(b) { } virtual ~GenericSimpleIntegrator() { } protected: - virtual void step(Real& t, Real& dt); + virtual void step(T& t, T& dt); private: ACoefficients m_a; -- cgit v1.2.3