diff options
author | Tavian Barnes <tavianator@gmail.com> | 2010-10-07 00:02:53 -0400 |
---|---|---|
committer | Tavian Barnes <tavianator@gmail.com> | 2010-10-07 00:02:53 -0400 |
commit | 90f6cedb9eae73fdf0c44c34874c7e67f39e02c2 (patch) | |
tree | a4fc804d92981da2d8e4354093e0b6df99cc3ed5 /src/vZ/Integrator.hpp | |
parent | 2b438504e0fc68ea8224e88675247e555ee6a6e6 (diff) | |
download | vz-90f6cedb9eae73fdf0c44c34874c7e67f39e02c2.tar.xz |
Add iteration count to Integrator.
Diffstat (limited to 'src/vZ/Integrator.hpp')
-rw-r--r-- | src/vZ/Integrator.hpp | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/vZ/Integrator.hpp b/src/vZ/Integrator.hpp index 9346eb8..c6d6fbe 100644 --- a/src/vZ/Integrator.hpp +++ b/src/vZ/Integrator.hpp @@ -41,7 +41,7 @@ namespace vZ // By default, y and t start at zero, h starts UNDEFINED GenericIntegrator(Function f) - : m_f(f), m_y(0), m_x(0), m_h() { } + : m_f(f), m_y(0), m_x(0), m_iterations(0) { } virtual ~GenericIntegrator() { } GenericIntegrator& y(Y y) { m_y = y; return *this; } @@ -52,6 +52,8 @@ namespace vZ Scalar x() const { return m_x; } Scalar h() const { return m_h; } + unsigned int iterations() const { return m_iterations; } + // Integrate until x == x_final void integrate(Scalar x_final); @@ -64,6 +66,7 @@ namespace vZ Function m_f; Y m_y; Scalar m_x, m_h; + unsigned int m_iterations; }; // Type alias @@ -78,6 +81,7 @@ namespace vZ while (m_x < x_final) { m_h = std::min(m_h, x_final - m_x); step(); + ++m_iterations; } } } |