Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r61977 - in sandbox/odeint: boost/numeric/odeint libs/numeric/odeint/examples
From: karsten.ahnert_at_[hidden]
Date: 2010-05-15 06:22:57


Author: karsten
Date: 2010-05-15 06:22:56 EDT (Sat, 15 May 2010)
New Revision: 61977
URL: http://svn.boost.org/trac/boost/changeset/61977

Log:
small bug fixes in adaptive integration and rk78
Text files modified:
   sandbox/odeint/boost/numeric/odeint/integrator_adaptive_stepsize.hpp | 12 +++++++-----
   sandbox/odeint/boost/numeric/odeint/integrator_constant_stepsize.hpp | 2 +-
   sandbox/odeint/boost/numeric/odeint/stepper_rk78_fehlberg.hpp | 2 +-
   sandbox/odeint/libs/numeric/odeint/examples/lorenz_controlled.cpp | 6 ++++--
   4 files changed, 13 insertions(+), 9 deletions(-)

Modified: sandbox/odeint/boost/numeric/odeint/integrator_adaptive_stepsize.hpp
==============================================================================
--- sandbox/odeint/boost/numeric/odeint/integrator_adaptive_stepsize.hpp (original)
+++ sandbox/odeint/boost/numeric/odeint/integrator_adaptive_stepsize.hpp 2010-05-15 06:22:56 EDT (Sat, 15 May 2010)
@@ -35,7 +35,7 @@
             typename ControlledStepper::time_type start_time,
             typename ControlledStepper::time_type end_time,
             typename ControlledStepper::time_type dt,
- Observer &observer )
+ Observer observer )
     {
         typedef typename ControlledStepper::time_type time_type;
 
@@ -43,23 +43,25 @@
 
         controlled_step_result result;
         size_t iterations = 0;
- time_type t = start_time , dt_ = dt;
+ time_type t = start_time ;
 
         observer(t, state, system);
         
         while( t < end_time )
         {
             if( (end_time - t) < dt ) dt = end_time - t;
+
             // do a controlled step
- result = stepper.try_step( system, state, t, dt_ );
+ result = stepper.try_step( system, state, t, dt );
 
             if( result != step_size_decreased )
- { // we actually did a step forward (dt was small enough)
+ {
+ // we actually did a step forward (dt was small enough)
                 observer(t, state, system);
                 iterations++;
             }
 
- if( !( t+dt_ > t) )
+ if( !( t+dt > t) )
                 throw; // we've reached machine precision with dt - no advancing in t
         }
         return iterations;

Modified: sandbox/odeint/boost/numeric/odeint/integrator_constant_stepsize.hpp
==============================================================================
--- sandbox/odeint/boost/numeric/odeint/integrator_constant_stepsize.hpp (original)
+++ sandbox/odeint/boost/numeric/odeint/integrator_constant_stepsize.hpp 2010-05-15 06:22:56 EDT (Sat, 15 May 2010)
@@ -32,7 +32,7 @@
         typename Stepper::time_type start_time ,
         typename Stepper::time_type end_time ,
         typename Stepper::time_type dt ,
- Observer &observer
+ Observer observer
         )
     {
         stepper.adjust_size( state );

Modified: sandbox/odeint/boost/numeric/odeint/stepper_rk78_fehlberg.hpp
==============================================================================
--- sandbox/odeint/boost/numeric/odeint/stepper_rk78_fehlberg.hpp (original)
+++ sandbox/odeint/boost/numeric/odeint/stepper_rk78_fehlberg.hpp 2010-05-15 06:22:56 EDT (Sat, 15 May 2010)
@@ -362,7 +362,7 @@
         template< class DynamicalSystem >
         void do_step( DynamicalSystem &system ,
                       container_type &x ,
- container_type &dxdt ,
+ const container_type &dxdt ,
                       time_type t ,
                       time_type dt ,
                       container_type &xerr )

Modified: sandbox/odeint/libs/numeric/odeint/examples/lorenz_controlled.cpp
==============================================================================
--- sandbox/odeint/libs/numeric/odeint/examples/lorenz_controlled.cpp (original)
+++ sandbox/odeint/libs/numeric/odeint/examples/lorenz_controlled.cpp 2010-05-15 06:22:56 EDT (Sat, 15 May 2010)
@@ -22,6 +22,7 @@
 #include <vector>
 #include <list>
 #include <tr1/array>
+#include <tr1/functional>
 
 #include <boost/numeric/odeint.hpp>
 #include <boost/numeric/odeint/container_traits_tr1_array.hpp>
@@ -56,6 +57,7 @@
     ofstream m_file;
 
 public:
+
     output_observer( const char* file_name )
         : m_file( file_name )
     {
@@ -89,7 +91,7 @@
     stepper_rk5_ck< state_type > rk5;
     controlled_stepper_standard< stepper_rk5_ck< state_type > > controlled_rk5( eps_abs , eps_rel, 1.0, 1.0 );
     output_observer rk5_obs("lorenz_rk5.dat");
- size_t steps = integrate_adaptive( controlled_rk5, lorenz, x, 0.0, end_time, 1E-2, rk5_obs );
+ size_t steps = integrate_adaptive( controlled_rk5, lorenz, x, 0.0, end_time, 1E-2, ref(rk5_obs) );
 
     clog << "RK5: " << steps << " steps. (" << function_calls << " function calls)" << endl;
 
@@ -102,7 +104,7 @@
     controlled_stepper_bs< state_type > controlled_bs(eps_abs, eps_rel, 1.0, 1.0);
     
     output_observer bs_obs("lorenz_bs.dat");
- steps = integrate_adaptive( controlled_bs, lorenz, x, 0.0, end_time, 1E-2, bs_obs );
+ steps = integrate_adaptive( controlled_bs, lorenz, x, 0.0, end_time, 1E-2, ref(bs_obs) );
 
     clog << "BS: " << steps << " steps. (" << function_calls << " function calls)" << endl;
 


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