Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r69201 - in sandbox/odeint/branches/karsten: . boost/numeric/odeint/stepper/base libs/numeric/odeint/test
From: karsten.ahnert_at_[hidden]
Date: 2011-02-23 01:39:11


Author: karsten
Date: 2011-02-23 01:39:09 EST (Wed, 23 Feb 2011)
New Revision: 69201
URL: http://svn.boost.org/trac/boost/changeset/69201

Log:
forwarding problem for base steppers

Text files modified:
   sandbox/odeint/branches/karsten/Jamroot | 4
   sandbox/odeint/branches/karsten/TODO | 7 ++
   sandbox/odeint/branches/karsten/boost/numeric/odeint/stepper/base/explicit_error_stepper_base.hpp | 55 +++++++++++++++++----
   sandbox/odeint/branches/karsten/boost/numeric/odeint/stepper/base/explicit_stepper_and_error_stepper_base.hpp | 100 ++++++++++++++++++++++++++++++++-------
   sandbox/odeint/branches/karsten/libs/numeric/odeint/test/stepper_with_ranges.cpp | 82 +++++++++++++++++++-------------
   5 files changed, 182 insertions(+), 66 deletions(-)

Modified: sandbox/odeint/branches/karsten/Jamroot
==============================================================================
--- sandbox/odeint/branches/karsten/Jamroot (original)
+++ sandbox/odeint/branches/karsten/Jamroot 2011-02-23 01:39:09 EST (Wed, 23 Feb 2011)
@@ -27,8 +27,8 @@
 
 
 # ideas
-build-project libs/numeric/odeint/ideas/butcher ;
-build-project libs/numeric/odeint/ideas/generic_stepper ;
+# build-project libs/numeric/odeint/ideas/butcher ;
+# build-project libs/numeric/odeint/ideas/generic_stepper ;
 build-project libs/numeric/odeint/ideas/rosenbrock4 ;
 build-project libs/numeric/odeint/ideas/units ;
 build-project libs/numeric/odeint/ideas/algebra ;

Modified: sandbox/odeint/branches/karsten/TODO
==============================================================================
--- sandbox/odeint/branches/karsten/TODO (original)
+++ sandbox/odeint/branches/karsten/TODO 2011-02-23 01:39:09 EST (Wed, 23 Feb 2011)
@@ -15,6 +15,11 @@
   * check if rosenbrock controller and controlled_stepper can both be used with the explicit steppers
   OK * move error_checker into controlled_stepper
   * rename controlled_stepper to a more specific name
+* ranges:
+ * explicit_stepper_and_error_stepper_fsal_base
+ * dense_output
+ * controlled_error_stepper
+ * integrate functions
 * general:
   * check if everywhere static_cast< value_type > is used
   * check header guards
@@ -25,7 +30,7 @@
   OK * find an appropriate name, (symplectic stroemer nystroem)
   OK * check is the coefficients are named good
   * check ranges and call
- * include do_step( system , q , p , t , dt )
+ OK * include do_step( system , q , p , t , dt )
 * dense output for rosenbrock
 * Integrate functions
 * skript for setting the include defines according to the position in file system an writing a general copyright comment at the beginning

Modified: sandbox/odeint/branches/karsten/boost/numeric/odeint/stepper/base/explicit_error_stepper_base.hpp
==============================================================================
--- sandbox/odeint/branches/karsten/boost/numeric/odeint/stepper/base/explicit_error_stepper_base.hpp (original)
+++ sandbox/odeint/branches/karsten/boost/numeric/odeint/stepper/base/explicit_error_stepper_base.hpp 2011-02-23 01:39:09 EST (Wed, 23 Feb 2011)
@@ -100,24 +100,38 @@
 
 
 
- // do_step( system , x , t , dt , xerr )
- template< class System , class StateIn , class Err >
- void do_step( System system , StateIn &x , const time_type &t , const time_type &dt , Err &xerr )
+ /*
+ * Version 1 : do_step( system , x , t , dt , xerr )
+ *
+ * Solves for the forwading 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 )
         {
- typename boost::unwrap_reference< System >::type &sys = system;
- m_size_adjuster.adjust_size_by_policy( x , adjust_size_policy() );
- sys( x , m_dxdt ,t );
- this->stepper().do_step_impl( system , x , m_dxdt , t , x , dt , xerr );
+ do_step_v1( system , x , t , dt , xerr );
         }
 
- // do_step( system , x , dxdt , t , dt , xerr )
- template< class System , class StateIn , class DerivIn , class Err >
- void do_step( System system , StateIn &x , const DerivIn &dxdt , const time_type &t , const time_type &dt , Err &xerr )
+ template< class System , class StateInOut , class Err >
+ void do_step( System system , StateInOut &x , const time_type &t , const time_type &dt , Err &xerr )
+ {
+ do_step_v1( system , x , t , dt , xerr );
+ }
+ /*
+ * Version 2 : do_step( system , x , dxdt , t , dt , xerr )
+ *
+ * Does not solve for the forwarding problem
+ */
+ template< class System , class StateInOut , class DerivIn , class Err >
+ void do_step( System system , StateInOut &x , const DerivIn &dxdt , const time_type &t , const time_type &dt , Err &xerr )
         {
                 this->stepper().do_step_impl( system , x , dxdt , t , x , dt , xerr );
         }
 
- // do_step( system , in , t , out , dt , xerr )
+ /*
+ * Version 2 : do_step( system , in , t , out , dt , xerr )
+ *
+ * Does not solve for 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 )
         {
@@ -127,7 +141,11 @@
                 this->stepper().do_step_impl( system , in , m_dxdt , t , out , dt , xerr );
         }
 
- // do_step( system , in , dxdt , t , out , dt , xerr )
+ /*
+ * Version 2 : do_step( system , in , dxdt , t , out , dt , xerr )
+ *
+ * Does not solve for the forwarding problem
+ */
         template< class System , class StateIn , class DerivIn , class StateOut , class Err >
         void do_step( System system , const StateIn &in , const DerivIn &dxdt , const time_type &t , StateOut &out , const time_type &dt , Err &xerr )
         {
@@ -145,6 +163,17 @@
 
 private:
 
+
+ template< class System , class StateInOut , class Err >
+ void do_step_v1( System system , StateInOut &x , const time_type &t , const time_type &dt , Err &xerr )
+ {
+ typename boost::unwrap_reference< System >::type &sys = system;
+ m_size_adjuster.adjust_size_by_policy( x , adjust_size_policy() );
+ sys( x , m_dxdt ,t );
+ this->stepper().do_step_impl( system , x , m_dxdt , t , x , dt , xerr );
+ }
+
+
         // ToDo : make the next two methods private?
     stepper_type& stepper( void )
     {
@@ -156,6 +185,8 @@
             return *static_cast< const stepper_type* >( this );
     }
 
+ void
+
 
         size_adjuster< deriv_type , 1 > m_size_adjuster;
         deriv_type m_dxdt;

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 01:39:09 EST (Wed, 23 Feb 2011)
@@ -110,25 +110,41 @@
 
 
 
-
- // do_step( sys , x , t , dt )
+ /*
+ * Version 1 : do_step( sys , x , t , dt )
+ *
+ * Does solve for the forwarding problem
+ */
         template< class System , class StateInOut >
         void do_step( 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() );
- sys( x , m_dxdt ,t );
- this->stepper().do_step_impl( system , x , m_dxdt , t , x , 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 for the forwarding problem
+ */
         template< class System , class StateInOut , class DerivIn >
         void do_step( System system , StateInOut &x , const DerivIn &dxdt , const time_type &t , const time_type &dt )
         {
                 this->stepper().do_step_impl( system , x , dxdt , t , x , dt );
         }
 
- // do_step( sys , in , t , out , dt )
+
+ /*
+ * Version 3 : do_step( sys , in , t , out , dt )
+ *
+ * Does NOT solve for 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 )
         {
@@ -138,7 +154,11 @@
                 this->stepper().do_step_impl( system , in , m_dxdt , t , out , dt );
         }
 
- // do_step( sys , in , dxdt , t , out , dt )
+ /*
+ * Version 4 :do_step( sys , in , dxdt , t , out , dt )
+ *
+ * Does NOT solve for the forwarding problem
+ */
         template< class System , class StateIn , class DerivIn , class StateOut >
         void do_step( System system , const StateIn &in , const DerivIn &dxdt , const time_type &t , StateOut &out , const time_type &dt )
         {
@@ -149,25 +169,45 @@
 
 
 
-
- // do_step( sys , x , t , dt , xerr )
+ /*
+ * Version 5 :do_step( sys , x , t , dt , xerr )
+ *
+ * Does solve for 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 )
         {
- typename boost::unwrap_reference< System >::type &sys = system;
- m_size_adjuster.adjust_size_by_policy( x , adjust_size_policy() );
- sys( x , m_dxdt ,t );
- this->stepper().do_step_impl( system , x , m_dxdt , t , x , dt , xerr );
+ do_step_v5( system , x , t , dt , xerr );
+// typename boost::unwrap_reference< System >::type &sys = system;
+// m_size_adjuster.adjust_size_by_policy( x , adjust_size_policy() );
+// sys( x , m_dxdt ,t );
+// this->stepper().do_step_impl( system , x , m_dxdt , t , x , 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 );
         }
 
- // do_step( sys , x , dxdt , t , dt , xerr )
+
+ /*
+ * Version 6 :do_step( sys , x , dxdt , t , dt , xerr )
+ *
+ * Does NOT solve for the forwarding problem
+ */
         template< class System , class StateInOut , class DerivIn , class Err >
         void do_step( System system , StateInOut &x , const DerivIn &dxdt , const time_type &t , const time_type &dt , Err &xerr )
         {
                 this->stepper().do_step_impl( system , x , dxdt , t , x , dt , xerr );
         }
 
- // do_step( sys , in , t , out , dt , xerr )
+
+ /*
+ * Version 7 : do_step( sys , in , t , out , dt , xerr )
+ *
+ * Does NOT solve for 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 )
         {
@@ -177,7 +217,11 @@
                 this->stepper().do_step_impl( system , in , m_dxdt , t , out , dt , xerr );
         }
 
- // do_step( sys , in , dxdt , t , out , dt , xerr )
+ /*
+ * Version 8 : do_step( sys , in , dxdt , t , out , dt , xerr )
+ *
+ * Does NOT solve for the forwarding problem
+ */
         template< class System , class StateIn , class DerivIn , class StateOut , class Err >
         void do_step( System system , const StateIn &in , const DerivIn &dxdt , const time_type &t , StateOut &out , const time_type &dt , Err &xerr )
         {
@@ -196,6 +240,26 @@
 
 private:
 
+ template< class System , class StateInOut >
+ 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() );
+ sys( x , m_dxdt ,t );
+ this->stepper().do_step_impl( system , x , m_dxdt , t , x , 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 )
+ {
+ typename boost::unwrap_reference< System >::type &sys = system;
+ m_size_adjuster.adjust_size_by_policy( x , adjust_size_policy() );
+ sys( x , m_dxdt ,t );
+ this->stepper().do_step_impl( system , x , m_dxdt , t , x , dt , xerr );
+ }
+
+
+
     stepper_type& stepper( void )
     {
             return *static_cast< stepper_type* >( this );

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 01:39:09 EST (Wed, 23 Feb 2011)
@@ -16,11 +16,19 @@
 #include <boost/range.hpp>
 
 #include <boost/numeric/odeint/stepper/explicit_euler.hpp>
+#include <boost/numeric/odeint/stepper/explicit_error_rk54_ck.hpp>
 
 typedef std::vector< double > state_type;
 typedef std::tr1::array< double , 3 > state_type2;
 
-struct lorenz
+
+/*
+ * The two systems are needed, since for steppers with more than
+ * one internal step it is difficult to calculate the exact result
+ *
+ * system1 is suited for euler
+ */
+struct system1
 {
         template< class State , class Deriv >
         void operator()( const State &x_ , Deriv &dxdt_ , double t )
@@ -45,20 +53,45 @@
         }
 };
 
+/*
+ * system2 is suited for all steppers, it allows you to calculate the result analytically.
+ */
+struct system2
+{
+ template< class State , class Deriv >
+ void operator()( const State &x_ , Deriv &dxdt_ , double t )
+ {
+ typename boost::range_iterator< Deriv >::type dxdt = boost::begin( dxdt_ );
+
+ dxdt[0] = 1.0;
+ dxdt[1] = 2.0;
+ dxdt[2] = 3.0;
+ }
+
+ template< class State , class Deriv >
+ void operator()( const State &x_ , const Deriv &dxdt_ , double t )
+ {
+ typename boost::range_iterator< Deriv >::type dxdt = boost::begin( dxdt_ );
+
+ dxdt[0] = 1.0;
+ dxdt[1] = 2.0;
+ dxdt[2] = 3.0;
+ }
+};
+
+
 struct vector_fixture
 {
         const static size_t dim = 6;
- std::vector< double > in , out , dxdt ;
- boost::numeric::odeint::explicit_euler< state_type > euler;
+ std::tr1::array< double , dim > in;
 
         vector_fixture( void )
- : in( dim ) , out( dim ) , dxdt( dim )
+// : in( dim )
+ : in()
         {
                 for( size_t i=0 ; i<dim ; ++i )
                 {
                         in[ i ] = double( i );
- out[ i ] = double( i ) + 10.0 ;
- dxdt[ i ] = double( i ) + 100.0 ;
                 }
         }
 
@@ -75,30 +108,6 @@
         BOOST_CHECK_CLOSE( x[4] , x4 , 1.0e-8 ); \
         BOOST_CHECK_CLOSE( x[5] , x5 , 1.0e-8 )
 
-#define CHECK_IN_DEFAULT( x ) \
- BOOST_CHECK_CLOSE( x[0] , 0.0 , 1.0e-8 ); \
- BOOST_CHECK_CLOSE( x[1] , 1.0 , 1.0e-8 ); \
- BOOST_CHECK_CLOSE( x[2] , 2.0 , 1.0e-8 ); \
- BOOST_CHECK_CLOSE( x[3] , 3.0 , 1.0e-8 ); \
- BOOST_CHECK_CLOSE( x[4] , 4.0 , 1.0e-8 ); \
- BOOST_CHECK_CLOSE( x[5] , 5.0 , 1.0e-8 )
-
-#define CHECK_OUT_DEFAULT( x ) \
- BOOST_CHECK_CLOSE( x[0] , 10.0 , 1.0e-8 ); \
- BOOST_CHECK_CLOSE( x[1] , 11.0 , 1.0e-8 ); \
- BOOST_CHECK_CLOSE( x[2] , 12.0 , 1.0e-8 ); \
- BOOST_CHECK_CLOSE( x[3] , 13.0 , 1.0e-8 ); \
- BOOST_CHECK_CLOSE( x[4] , 14.0 , 1.0e-8 ); \
- BOOST_CHECK_CLOSE( x[5] , 15.0 , 1.0e-8 )
-
-#define CHECK_DXDT_DEFAULT( x ) \
- BOOST_CHECK_CLOSE( x[0] , 100.0 , 1.0e-8 ); \
- BOOST_CHECK_CLOSE( x[1] , 101.0 , 1.0e-8 ); \
- BOOST_CHECK_CLOSE( x[2] , 102.0 , 1.0e-8 ); \
- BOOST_CHECK_CLOSE( x[3] , 103.0 , 1.0e-8 ); \
- BOOST_CHECK_CLOSE( x[4] , 104.0 , 1.0e-8 ); \
- BOOST_CHECK_CLOSE( x[5] , 105.0 , 1.0e-8 )
-
 
 
 BOOST_AUTO_TEST_SUITE( stepper_with_ranges )
@@ -106,10 +115,17 @@
 BOOST_AUTO_TEST_CASE( explicit_euler_with_range_v1 )
 {
         vector_fixture f;
- f.euler.do_step( lorenz() , std::make_pair( f.in.begin() + 1 , f.in.begin() + 4 ) , 0.1 , 0.1 );
+ boost::numeric::odeint::explicit_euler< state_type > euler;
+ euler.do_step( system1() , 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_k54_with_range_v1 )
+{
+ 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 );
         CHECK_VALUES( f.in , 0.0 , 1.1 , 2.2 , 3.3 , 4.0 , 5.0 );
- CHECK_OUT_DEFAULT( f.out );
- CHECK_DXDT_DEFAULT( f.dxdt );
 }
 
 


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