summaryrefslogtreecommitdiffstats
path: root/src/vZ
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@gmail.com>2010-10-06 14:38:22 -0400
committerTavian Barnes <tavianator@gmail.com>2010-10-06 14:38:22 -0400
commit2e25da27f14566000fb34d3859bfb470bf5fd1da (patch)
treec3514b8a1b2c79f7c2bfecac1fa26b234867e5d2 /src/vZ
parent3d8acfbde5f4eb4b612da36c136f9e8904f0c09d (diff)
downloadvz-2e25da27f14566000fb34d3859bfb470bf5fd1da.tar.xz
Add a new RKIntegrator base class.
Diffstat (limited to 'src/vZ')
-rw-r--r--src/vZ/Integrator.hpp2
-rw-r--r--src/vZ/RK.hpp48
-rw-r--r--src/vZ/Simple.hpp20
-rw-r--r--src/vZ/Traits.hpp3
4 files changed, 65 insertions, 8 deletions
diff --git a/src/vZ/Integrator.hpp b/src/vZ/Integrator.hpp
index a652bf6..25a84f6 100644
--- a/src/vZ/Integrator.hpp
+++ b/src/vZ/Integrator.hpp
@@ -66,7 +66,7 @@ namespace vZ
// Type alias
typedef GenericIntegrator<double> Integrator;
- // Definitions
+ // Implementations
template <typename T>
void
diff --git a/src/vZ/RK.hpp b/src/vZ/RK.hpp
new file mode 100644
index 0000000..3ba4b8a
--- /dev/null
+++ b/src/vZ/RK.hpp
@@ -0,0 +1,48 @@
+/*************************************************************************
+ * Copyright (C) 2009-2010 Tavian Barnes <tavianator@gmail.com> *
+ * *
+ * This file is part of The vZ Library. *
+ * *
+ * The vZ Library is free software; you can redistribute it and/or *
+ * modify it under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 3 of the *
+ * License, or (at your option) any later version. *
+ * *
+ * The vZ Library is distributed in the hope that it will be useful, but *
+ * WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this program. If not, see *
+ * <http://www.gnu.org/licenses/>. *
+ *************************************************************************/
+
+#ifndef VZ_RK_HPP
+#define VZ_RK_HPP
+
+#include <vector>
+
+namespace vZ
+{
+ // Base class for Runge-Kutta type algorithms
+ template <typename T>
+ class GenericRKIntegrator : public GenericIntegrator<T>
+ {
+ public:
+ typedef typename GenericIntegrator<T>::Function Function;
+
+ protected:
+ // Coefficients in the tableau representation of the RK algorithm
+ typedef std::vector<std::vector<T> > ACoefficients;
+ typedef std::vector<T> BCoefficients;
+
+ GenericRKIntegrator(Function f, T dt) : GenericIntegrator<T>(f, dt) { }
+ virtual ~GenericRKIntegrator() { }
+ };
+
+ // Type alias
+ typedef GenericRKIntegrator<double> RKIntegrator;
+}
+
+#endif // VZ_RK_HPP
diff --git a/src/vZ/Simple.hpp b/src/vZ/Simple.hpp
index 706b52c..103357e 100644
--- a/src/vZ/Simple.hpp
+++ b/src/vZ/Simple.hpp
@@ -27,22 +27,20 @@ namespace vZ
{
// Base class for non-adaptive RK-style algorithms
template <typename T>
- class GenericSimpleIntegrator : public GenericIntegrator<T>
+ class GenericSimpleIntegrator : public GenericRKIntegrator<T>
{
- protected:
- // Coefficients in the tableau representation of the RK algorithm
- typedef std::vector<std::vector<T> > ACoefficients;
- typedef std::vector<T> BCoefficients;
-
public:
typedef typename GenericIntegrator<T>::Function Function;
+ protected:
+ typedef typename GenericRKIntegrator<T>::ACoefficients ACoefficients;
+ typedef typename GenericRKIntegrator<T>::BCoefficients BCoefficients;
+
GenericSimpleIntegrator(Function f, T dt,
ACoefficients a, BCoefficients b)
: GenericIntegrator<T>(f, dt), m_a(a), m_b(b) { }
virtual ~GenericSimpleIntegrator() { }
- protected:
virtual void step(T& t, T& dt);
private:
@@ -52,6 +50,14 @@ namespace vZ
// Type alias
typedef GenericSimpleIntegrator<double> SimpleIntegrator;
+
+ // Implementations
+
+ template <typename T>
+ void
+ GenericSimpleIntegrator<T>::step(T& t, T& dt)
+ {
+ }
}
#endif // VZ_SIMPLE_HPP
diff --git a/src/vZ/Traits.hpp b/src/vZ/Traits.hpp
index baac9ed..76294ea 100644
--- a/src/vZ/Traits.hpp
+++ b/src/vZ/Traits.hpp
@@ -32,6 +32,9 @@ namespace vZ
{
public:
typedef T Scalar;
+
+ private:
+ Traits();
};
}