From 90f6cedb9eae73fdf0c44c34874c7e67f39e02c2 Mon Sep 17 00:00:00 2001 From: Tavian Barnes Date: Thu, 7 Oct 2010 00:02:53 -0400 Subject: Add iteration count to Integrator. --- src/vZ/Integrator.hpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src') 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; } } } -- cgit v1.2.3