Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r69222 - in sandbox/odeint/branches/karsten: . boost/numeric/odeint/stepper boost/numeric/odeint/stepper/base libs/numeric/odeint/test
From: karsten.ahnert_at_[hidden]
Date: 2011-02-23 15:37:14


Author: karsten
Date: 2011-02-23 15:36:45 EST (Wed, 23 Feb 2011)
New Revision: 69222
URL: http://svn.boost.org/trac/boost/changeset/69222

Log:
preparing for boost range
Text files modified:
   sandbox/odeint/branches/karsten/TODO | 2
   sandbox/odeint/branches/karsten/boost/numeric/odeint/stepper/base/explicit_stepper_and_error_stepper_base.hpp | 2
   sandbox/odeint/branches/karsten/boost/numeric/odeint/stepper/base/explicit_stepper_and_error_stepper_fsal_base.hpp | 111 +++++++++++++++++++++++++++++++--------
   sandbox/odeint/branches/karsten/boost/numeric/odeint/stepper/base/explicit_stepper_base.hpp | 6 +-
   sandbox/odeint/branches/karsten/boost/numeric/odeint/stepper/controlled_error_stepper.hpp | 7 +
   sandbox/odeint/branches/karsten/libs/numeric/odeint/test/stepper_with_ranges.cpp | 32 +++++++++++
   6 files changed, 129 insertions(+), 31 deletions(-)

Modified: sandbox/odeint/branches/karsten/TODO
==============================================================================
--- sandbox/odeint/branches/karsten/TODO (original)
+++ sandbox/odeint/branches/karsten/TODO 2011-02-23 15:36:45 EST (Wed, 23 Feb 2011)
@@ -20,6 +20,8 @@
   * dense_output
   * controlled_error_stepper
   * integrate functions
+ * check comments (spelling and if the comment is true, in some versions dxdt is already const)
+ OK * check names of the impl functions
 * general:
   * check if everywhere static_cast< value_type > is used
   * check header guards

Modified: sandbox/odeint/branches/karsten/boost/numeric/odeint/stepper/base/explicit_stepper_and_error_stepper_base.hpp
==============================================================================
--- sandbox/odeint/branches/karsten/boost/numeric/odeint/stepper/base/explicit_stepper_and_error_stepper_base.hpp (original)
+++ sandbox/odeint/branches/karsten/boost/numeric/odeint/stepper/base/explicit_stepper_and_error_stepper_base.hpp 2011-02-23 15:36:45 EST (Wed, 23 Feb 2011)
@@ -187,7 +187,7 @@
         template< class System , class StateInOut , class Err >
         void do_step( System system , const StateInOut &x , const time_type &t , const time_type &dt , Err &xerr )
         {
- do_step_v5( system , x . t , dt , xerr );
+ do_step_v5( system , x , t , dt , xerr );
         }
 
 

Modified: sandbox/odeint/branches/karsten/boost/numeric/odeint/stepper/base/explicit_stepper_and_error_stepper_fsal_base.hpp
==============================================================================
--- sandbox/odeint/branches/karsten/boost/numeric/odeint/stepper/base/explicit_stepper_and_error_stepper_fsal_base.hpp (original)
+++ sandbox/odeint/branches/karsten/boost/numeric/odeint/stepper/base/explicit_stepper_and_error_stepper_fsal_base.hpp 2011-02-23 15:36:45 EST (Wed, 23 Feb 2011)
@@ -111,21 +111,29 @@
 
 
 
-
- // do_step( sys , x , t , dt )
+ /*
+ * version 1 : do_step( sys , x , t , dt )
+ *
+ * Solves the forwarding problem
+ */
         template< class System , class StateInOut >
         void do_step( System system , StateInOut &x , const time_type &t , const time_type &dt )
         {
- if( m_size_adjuster.adjust_size_by_policy( x , adjust_size_policy() ) || m_first_call )
- {
- typename boost::unwrap_reference< System >::type &sys = system;
- sys( x , m_dxdt ,t );
- m_first_call = false;
- }
- this->stepper().do_step_impl( system , x , m_dxdt , t , x , m_dxdt , dt );
+ do_step_v1( system , x , t , dt );
         }
 
- // do_step( sys , x , dxdt , t , dt )
+ template< class System , class StateInOut >
+ void do_step( System system , const StateInOut &x , const time_type &t , const time_type &dt )
+ {
+ do_step_v1( system , x , t , dt );
+ }
+
+
+ /*
+ * version 2 : do_step( sys , x , dxdt , t , dt )
+ *
+ * Does NOT solve the forwarding problem
+ */
         template< class System , class StateInOut , class DerivInOut >
         void do_step( System system , StateInOut &x , DerivInOut &dxdt , const time_type &t , const time_type &dt )
         {
@@ -133,7 +141,12 @@
                 this->stepper().do_step_impl( system , x , dxdt , t , x , dxdt , dt );
         }
 
- // do_step( sys , in , t , out , dt )
+
+ /*
+ * version 3 : do_step( sys , in , t , out , dt )
+ *
+ * Does NOT solve the forwarding problem
+ */
         template< class System , class StateIn , class StateOut >
         void do_step( System system , const StateIn &in , const time_type &t , StateOut &out , const time_type &dt )
         {
@@ -146,7 +159,12 @@
                 this->stepper().do_step_impl( system , in , m_dxdt , t , out , m_dxdt , dt );
         }
 
- // do_step( sys , in , dxdt_in , t , out , dxdt_out , dt )
+
+ /*
+ * version 4 : do_step( sys , in , dxdt_in , t , out , dxdt_out , dt )
+ *
+ * Does NOT solve the forwarding problem
+ */
         template< class System , class StateIn , class DerivIn , class StateOut , class DerivOut >
         void do_step( System system , const StateIn &in , const DerivIn &dxdt_in , const time_type &t ,
                         StateOut &out , DerivOut &dxdt_out , const time_type &dt )
@@ -159,21 +177,30 @@
 
 
 
-
- // do_step( sys , x , t , dt , xerr )
+ /*
+ * version 5 : do_step( sys , x , t , dt , xerr )
+ *
+ * Solves the forwarding problem
+ */
         template< class System , class StateInOut , class Err >
         void do_step( System system , StateInOut &x , const time_type &t , const time_type &dt , Err &xerr )
         {
- if( m_size_adjuster.adjust_size_by_policy( x , adjust_size_policy() ) || m_first_call )
- {
- typename boost::unwrap_reference< System >::type &sys = system;
- sys( x , m_dxdt ,t );
- m_first_call = false;
- }
- this->stepper().do_step_impl( system , x , m_dxdt , t , x , m_dxdt , dt , xerr );
+ do_step_v5( system , x , t , dt , xerr );
         }
 
- // do_step( sys , x , dxdt , t , dt , xerr )
+ template< class System , class StateInOut , class Err >
+ void do_step( System system , const StateInOut &x , const time_type &t , const time_type &dt , Err &xerr )
+ {
+ do_step_v5( system , x , t , dt , xerr );
+ }
+
+
+
+ /*
+ * version 6 : do_step( sys , x , dxdt , t , dt , xerr )
+ *
+ * Does NOT solve the forwarding problem
+ */
         template< class System , class StateInOut , class DerivInOut , class Err >
         void do_step( System system , StateInOut &x , DerivInOut &dxdt , const time_type &t , const time_type &dt , Err &xerr )
         {
@@ -181,7 +208,12 @@
                 this->stepper().do_step_impl( system , x , dxdt , t , x , dxdt , dt , xerr );
         }
 
- // do_step( sys , in , t , out , dt , xerr )
+
+ /*
+ * version 7 : do_step( sys , in , t , out , dt , xerr )
+ *
+ * Does NOT solve the forwarding problem
+ */
         template< class System , class StateIn , class StateOut , class Err >
         void do_step( System system , const StateIn &in , const time_type &t , StateOut &out , const time_type &dt , Err &xerr )
         {
@@ -194,7 +226,12 @@
                 this->stepper().do_step_impl( system , in , m_dxdt , t , out , m_dxdt , dt , xerr );
         }
 
- // do_step( sys , in , dxdt_in , t , out , dxdt_out , dt )
+
+ /*
+ * version 8 : do_step( sys , in , dxdt_in , t , out , dxdt_out , dt )
+ *
+ * Does NOT solve the forwarding problem
+ */
         template< class System , class StateIn , class DerivIn , class StateOut , class DerivOut , class Err >
         void do_step( System system , const StateIn &in , const DerivIn &dxdt_in , const time_type &t ,
                         StateOut &out , DerivOut &dxdt_out , const time_type &dt , Err &xerr )
@@ -217,6 +254,32 @@
 
 private:
 
+ template< class System , class StateInOut >
+ void do_step_v1( System system , StateInOut &x , const time_type &t , const time_type &dt )
+ {
+ if( m_size_adjuster.adjust_size_by_policy( x , adjust_size_policy() ) || m_first_call )
+ {
+ typename boost::unwrap_reference< System >::type &sys = system;
+ sys( x , m_dxdt ,t );
+ m_first_call = false;
+ }
+ this->stepper().do_step_impl( system , x , m_dxdt , t , x , m_dxdt , dt );
+ }
+
+ template< class System , class StateInOut , class Err >
+ void do_step_v5( System system , StateInOut &x , const time_type &t , const time_type &dt , Err &xerr )
+ {
+ if( m_size_adjuster.adjust_size_by_policy( x , adjust_size_policy() ) || m_first_call )
+ {
+ typename boost::unwrap_reference< System >::type &sys = system;
+ sys( x , m_dxdt ,t );
+ m_first_call = false;
+ }
+ this->stepper().do_step_impl( system , x , m_dxdt , t , x , m_dxdt , dt , xerr );
+ }
+
+
+
     stepper_type& stepper( void )
     {
             return *static_cast< stepper_type* >( this );

Modified: sandbox/odeint/branches/karsten/boost/numeric/odeint/stepper/base/explicit_stepper_base.hpp
==============================================================================
--- sandbox/odeint/branches/karsten/boost/numeric/odeint/stepper/base/explicit_stepper_base.hpp (original)
+++ sandbox/odeint/branches/karsten/boost/numeric/odeint/stepper/base/explicit_stepper_base.hpp 2011-02-23 15:36:45 EST (Wed, 23 Feb 2011)
@@ -102,13 +102,13 @@
         template< class System , class StateInOut >
         void do_step( System system , StateInOut &x , const time_type &t , const time_type &dt )
         {
- do_step_caller_v1( system , x , t , dt );
+ do_step_v1( system , x , t , dt );
         }
 
         template< class System , class StateInOut >
         void do_step( System system , const StateInOut &x , const time_type &t , const time_type &dt )
         {
- do_step_caller_v1( system , x , t , dt );
+ do_step_v1( system , x , t , dt );
         }
 
 
@@ -174,7 +174,7 @@
 private:
 
         template< class System , class StateInOut >
- void do_step_caller_v1( System system , StateInOut &x , const time_type &t , const time_type &dt )
+ void do_step_v1( System system , StateInOut &x , const time_type &t , const time_type &dt )
         {
                 typename boost::unwrap_reference< System >::type &sys = system;
                 m_size_adjuster.adjust_size_by_policy( x , adjust_size_policy() );

Modified: sandbox/odeint/branches/karsten/boost/numeric/odeint/stepper/controlled_error_stepper.hpp
==============================================================================
--- sandbox/odeint/branches/karsten/boost/numeric/odeint/stepper/controlled_error_stepper.hpp (original)
+++ sandbox/odeint/branches/karsten/boost/numeric/odeint/stepper/controlled_error_stepper.hpp 2011-02-23 15:36:45 EST (Wed, 23 Feb 2011)
@@ -180,8 +180,11 @@
 
 
 
-
- // try_step( sys , x , t , dt )
+ /*
+ * Version 1 : try_step( sys , x , t , dt )
+ *
+ * The overloads are needed to solve the forwarding problem
+ */
         template< class System , class StateInOut >
         controlled_step_result try_step( System system , StateInOut &x , time_type &t , time_type &dt )
         {

Modified: sandbox/odeint/branches/karsten/libs/numeric/odeint/test/stepper_with_ranges.cpp
==============================================================================
--- sandbox/odeint/branches/karsten/libs/numeric/odeint/test/stepper_with_ranges.cpp (original)
+++ sandbox/odeint/branches/karsten/libs/numeric/odeint/test/stepper_with_ranges.cpp 2011-02-23 15:36:45 EST (Wed, 23 Feb 2011)
@@ -17,6 +17,7 @@
 
 #include <boost/numeric/odeint/stepper/explicit_euler.hpp>
 #include <boost/numeric/odeint/stepper/explicit_error_rk54_ck.hpp>
+#include <boost/numeric/odeint/stepper/explicit_error_dopri5.hpp>
 
 typedef std::vector< double > state_type;
 typedef std::tr1::array< double , 3 > state_type2;
@@ -84,15 +85,20 @@
 {
         const static size_t dim = 6;
         std::tr1::array< double , dim > in;
+ state_type err;
 
         vector_fixture( void )
 // : in( dim )
- : in()
+ : in() , err( 3 )
         {
                 for( size_t i=0 ; i<dim ; ++i )
                 {
                         in[ i ] = double( i );
                 }
+ for( size_t i=0 ; i<3 ; ++i )
+ {
+ err[i] = double( i ) * 10.0;
+ }
         }
 
         ~vector_fixture( void )
@@ -128,6 +134,30 @@
         CHECK_VALUES( f.in , 0.0 , 1.1 , 2.2 , 3.3 , 4.0 , 5.0 );
 }
 
+BOOST_AUTO_TEST_CASE( explicit_error_k54_with_range_v5 )
+{
+ vector_fixture f;
+ boost::numeric::odeint::explicit_error_rk54_ck< state_type > rk54;
+ rk54.do_step( system2() , std::make_pair( f.in.begin() + 1 , f.in.begin() + 4 ) , 0.1 , 0.1 , f.err );
+ CHECK_VALUES( f.in , 0.0 , 1.1 , 2.2 , 3.3 , 4.0 , 5.0 );
+}
+
+
+BOOST_AUTO_TEST_CASE( explicit_error_dopri5_with_range_v1 )
+{
+ vector_fixture f;
+ boost::numeric::odeint::explicit_error_dopri5< state_type > dopri5;
+ dopri5.do_step( system2() , std::make_pair( f.in.begin() + 1 , f.in.begin() + 4 ) , 0.1 , 0.1 );
+ CHECK_VALUES( f.in , 0.0 , 1.1 , 2.2 , 3.3 , 4.0 , 5.0 );
+}
+
+BOOST_AUTO_TEST_CASE( explicit_error_dopri5_with_range_v5 )
+{
+ vector_fixture f;
+ boost::numeric::odeint::explicit_error_dopri5< state_type > dopri5;
+ dopri5.do_step( system2() , std::make_pair( f.in.begin() + 1 , f.in.begin() + 4 ) , 0.1 , 0.1 , f.err );
+ CHECK_VALUES( f.in , 0.0 , 1.1 , 2.2 , 3.3 , 4.0 , 5.0 );
+}
 
 
 


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