Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r57308 - sandbox/odeint/boost/numeric/odeint
From: mario.mulansky_at_[hidden]
Date: 2009-11-03 09:53:37


Author: mariomulansky
Date: 2009-11-03 09:53:36 EST (Tue, 03 Nov 2009)
New Revision: 57308
URL: http://svn.boost.org/trac/boost/changeset/57308

Log:
use numeric_limits for checking of small dt
Text files modified:
   sandbox/odeint/boost/numeric/odeint/integrator.hpp | 14 ++++++++------
   1 files changed, 8 insertions(+), 6 deletions(-)

Modified: sandbox/odeint/boost/numeric/odeint/integrator.hpp
==============================================================================
--- sandbox/odeint/boost/numeric/odeint/integrator.hpp (original)
+++ sandbox/odeint/boost/numeric/odeint/integrator.hpp 2009-11-03 09:53:36 EST (Tue, 03 Nov 2009)
@@ -16,6 +16,7 @@
 #include <boost/numeric/odeint/stepsize_controller_standard.hpp>
 #include <boost/numeric/odeint/resizer.hpp>
 #include <vector>
+#include <limits>
 
 namespace boost {
 namespace numeric {
@@ -59,9 +60,9 @@
 
         while( t_iter < times.end() ) {
 
- if( t >= *t_iter ) {
- *x_iter++ = x;
- t_iter++;
+ if( t >= *t_iter ) { // we've reached the next time point
+ *x_iter++ = x; // save the vector
+ t_iter++; // next time point
             }
 
             result = controller.controlled_step( stepper, system, x, t, dt );
@@ -69,7 +70,8 @@
                 result = controller.controlled_step( stepper, system, x, t, dt );
                 if( result == STEP_SIZE_INCREASED )
                     iterations++;
- if( dt < 1E-10 ) throw;
+ if( !( t+dt > t) )
+ throw; // we've reached machine precision with dt - no advancing in t
             }
             iterations++;
         }
@@ -117,8 +119,8 @@
                      typename StepType::container_type &x,
                      std::vector<T> &times,
                      std::vector<typename StepType::container_type> &x_vec,
- T dt = 1E-4, T eps_abs = 1E-7,
- T eps_rel = 1E-8, T a_x = 1.0 , T a_dxdt = 1.0)
+ T dt = 1E-4, T eps_abs = 1E-6,
+ T eps_rel = 1E-7, T a_x = 1.0 , T a_dxdt = 1.0)
     {
         if( times.size() != x_vec.size() ) throw;
         // we use the standard controller for this adaptive integrator


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk