Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r68944 - in sandbox/odeint/branches/karsten: . boost/numeric/odeint/stepper boost/numeric/odeint/stepper/base libs/numeric/odeint/ideas/algebra libs/numeric/odeint/regression_test libs/numeric/odeint/test
From: karsten.ahnert_at_[hidden]
Date: 2011-02-16 03:33:16


Author: karsten
Date: 2011-02-16 03:33:13 EST (Wed, 16 Feb 2011)
New Revision: 68944
URL: http://svn.boost.org/trac/boost/changeset/68944

Log:
* ideas for algebra
* fixes and do_step overloads in symplectir_rkn_stepper_base
* making explicit_stepper_base ready for boost.range and testing
Added:
   sandbox/odeint/branches/karsten/boost/numeric/odeint/stepper/base/symplectic_rkn_stepper_base.hpp (contents, props changed)
      - copied, changed from r68938, /sandbox/odeint/branches/karsten/boost/numeric/odeint/stepper/base/symplectic_nystroem_stepper_base.hpp
   sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/algebra/
   sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/algebra/Jamfile (contents, props changed)
   sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/algebra/algebra.hpp (contents, props changed)
   sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/algebra/test_algebra.cpp (contents, props changed)
Removed:
   sandbox/odeint/branches/karsten/boost/numeric/odeint/stepper/base/symplectic_nystroem_stepper_base.hpp
Text files modified:
   sandbox/odeint/branches/karsten/Jamroot | 6 +-
   sandbox/odeint/branches/karsten/TODO | 10 +++
   sandbox/odeint/branches/karsten/boost/numeric/odeint/stepper/base/symplectic_rkn_stepper_base.hpp | 110 ++++++++++++++++++++++++++++++---------
   sandbox/odeint/branches/karsten/boost/numeric/odeint/stepper/symplectic_euler.hpp | 2
   sandbox/odeint/branches/karsten/boost/numeric/odeint/stepper/symplectic_rkn_sb3a_mclachlan.hpp | 4
   sandbox/odeint/branches/karsten/libs/numeric/odeint/regression_test/hamiltonian_steppers.cpp | 4 +
   sandbox/odeint/branches/karsten/libs/numeric/odeint/test/stepper_with_ranges.cpp | 21 ++-----
   7 files changed, 109 insertions(+), 48 deletions(-)

Modified: sandbox/odeint/branches/karsten/Jamroot
==============================================================================
--- sandbox/odeint/branches/karsten/Jamroot (original)
+++ sandbox/odeint/branches/karsten/Jamroot 2011-02-16 03:33:13 EST (Wed, 16 Feb 2011)
@@ -27,11 +27,11 @@
 
 
 # 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 ;
+build-project libs/numeric/odeint/ideas/algebra ;
 
 
 # docs:

Modified: sandbox/odeint/branches/karsten/TODO
==============================================================================
--- sandbox/odeint/branches/karsten/TODO (original)
+++ sandbox/odeint/branches/karsten/TODO 2011-02-16 03:33:13 EST (Wed, 16 Feb 2011)
@@ -26,8 +26,16 @@
   * documente every file in the preamble
   * check once more, if all contructor, destructors and assign-operators are present
 * symplecit_stepper
- * find an appropriate name, (symplectic stroemer nystroem)
+ 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 )
+
+* decrease complexity:
+ * remove construct, destruct, copy ?
+ * remove the overloads solving the forwarding problem. boost::range can not be used then anymore
+
+
 
 * Integrate functions
 * skript for setting the include defines according to the position in file system an writing a general copyright comment at the beginning

Deleted: sandbox/odeint/branches/karsten/boost/numeric/odeint/stepper/base/symplectic_nystroem_stepper_base.hpp
==============================================================================
--- sandbox/odeint/branches/karsten/boost/numeric/odeint/stepper/base/symplectic_nystroem_stepper_base.hpp 2011-02-16 03:33:13 EST (Wed, 16 Feb 2011)
+++ (empty file)
@@ -1,239 +0,0 @@
-/*
- * symplectic_nystroem.hpp
- *
- * Created on: Feb 12, 2011
- * Author: karsten
- */
-
-#ifndef BOOST_NUMERIC_ODEINT_STEPPER_SYMPLECTIC_NYSTROEM_STEPPER_BASE_HPP_INCLUDED
-#define BOOST_NUMERIC_ODEINT_STEPPER_SYMPLECTIC_NYSTROEM_STEPPER_BASE_HPP_INCLUDED
-
-#include <boost/ref.hpp>
-#include <boost/array.hpp>
-
-#include <boost/numeric/odeint/util/size_adjuster.hpp>
-#include <boost/numeric/odeint/util/construct.hpp>
-#include <boost/numeric/odeint/util/destruct.hpp>
-#include <boost/numeric/odeint/util/copy.hpp>
-
-#include <boost/numeric/odeint/stepper/stepper_categories.hpp>
-
-#include <boost/numeric/odeint/stepper/detail/is_pair.hpp>
-
-namespace boost {
-namespace numeric {
-namespace odeint {
-
-template<
- size_t NumOfStages ,
- class Stepper ,
- class Coor ,
- class Momentum ,
- class Value ,
- class CoorDeriv ,
- class MomentumDeriv ,
- class Time ,
- class Algebra ,
- class Operations ,
- class AdjustSizePolicy
- >
-class symplectic_nystroem_stepper_base
-{
-
- void initialize( void )
- {
- boost::numeric::odeint::construct( m_dqdt );
- boost::numeric::odeint::construct( m_dpdt );
- m_coor_deriv_adjuster.register_state( 0 , m_dqdt );
- m_momentum_deriv_adjuster.register_state( 0 , m_dpdt );
- }
-
- void copy( const symplectic_nystroem_stepper_base &b )
- {
- boost::numeric::odeint::copy( b.m_dqdt , m_dqdt );
- boost::numeric::odeint::copy( b.m_dpdt , m_dpdt );
- }
-
-public:
-
- const static size_t num_of_stages = NumOfStages;
- typedef Coor coor_type;
- typedef Momentum momentum_type;
- typedef std::pair< coor_type , momentum_type > state_type;
- typedef CoorDeriv coor_deriv_type;
- typedef MomentumDeriv momentum_deriv_type;
- typedef std::pair< coor_deriv_type , momentum_deriv_type > deriv_type;
- typedef Value value_type;
- typedef Time time_type;
- typedef Algebra algebra_type;
- typedef Operations operations_type;
- typedef AdjustSizePolicy adjust_size_policy;
- typedef Stepper stepper_type;
- typedef stepper_tag stepper_category;
-
- typedef boost::array< value_type , num_of_stages > coef_type;
-
- symplectic_nystroem_stepper_base( const coef_type &coef_a , const coef_type &coef_b )
- : m_coef_a( coef_a ) , m_coef_b( coef_b ) ,
- m_coor_deriv_adjuster() , m_momentum_deriv_adjuster() ,
- m_dqdt() , m_dpdt()
- {
- initialize();
- }
-
- symplectic_nystroem_stepper_base( const symplectic_nystroem_stepper_base &b )
- : m_coef_a( b.m_coef_a ) , m_coef_b( b.m_coef_b ) ,
- m_coor_deriv_adjuster() , m_momentum_deriv_adjuster(),
- m_dqdt() , m_dpdt()
- {
- initialize();
- copy( b );
- }
-
- ~symplectic_nystroem_stepper_base( void )
- {
- boost::numeric::odeint::destruct( m_dqdt );
- boost::numeric::odeint::destruct( m_dpdt );
- }
-
- symplectic_nystroem_stepper_base& operator=( const symplectic_nystroem_stepper_base &b )
- {
- copy( b );
- return *this;
- }
-
-
- template< class System , class StateIn , class StateOut >
- void do_step( System system , const StateIn &in , const time_type &t , const StateOut &out , const time_type &dt )
- {
- do_step( system , in , t , out , dt );
- }
-
-
- 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 )
- {
- typedef typename boost::unwrap_reference< System >::type system_type;
- do_step_impl( system , in , t , out , dt , typename detail::is_pair< system_type >::type() );
- }
-
-
-
-
- template< class System , class StateInOut >
- void do_step( System system , const StateInOut &state , const time_type &t , const time_type &dt )
- {
- do_step( system , state , t , dt );
- }
-
- template< class System , class StateInOut >
- void do_step( System system , StateInOut &state , const time_type &t , const time_type &dt )
- {
- typedef typename boost::unwrap_reference< System >::type system_type;
- do_step_impl( system , state , t , state , dt , typename detail::is_pair< system_type >::type() );
- }
-
- template< class StateType >
- void adjust_size( const StateType &x )
- {
- m_coor_deriv_adjuster.adjust_size( x );
- m_momentum_deriv_adjuster.adjust_size( x );
- }
-
- const coef_type& coef_a( void ) const { return m_coef_a; }
- const coef_type& coef_b( void ) const { return m_coef_b; }
-
-private:
-
- // stepper for systems with function for dq/dt = f(p) and dp/dt = -f(q)
- template< class System , class StateIn , class StateOut >
- void do_step_impl( System system , const StateIn &in , const time_type &t , StateOut &out , const time_type &dt , boost::mpl::true_ )
- {
- typedef typename boost::unwrap_reference< System >::type system_type;
- typedef typename boost::unwrap_reference< typename system_type::first_type >::type coor_deriv_func_type;
- typedef typename boost::unwrap_reference< typename system_type::second_type >::type momentum_deriv_func_type;
- system_type &sys = system;
- coor_deriv_func_type &coor_func = sys.first;
- momentum_deriv_func_type &momentum_func = sys.second;
-
-
- m_coor_deriv_adjuster.adjust_size_by_policy( in , adjust_size_policy() );
- m_momentum_deriv_adjuster.adjust_size_by_policy( in , adjust_size_policy() );
-
- // ToDo: check sizes?
-
- for( size_t l=0 ; l<num_of_stages ; ++l )
- {
- if( l == 0 )
- {
- coor_func( in.second , m_dqdt );
- typename algebra_type::for_each2()( out.first , in.first , m_dqdt ,
- typename operations_type::template scale_sum2< value_type , time_type >( 1.0 , coef_a[l] * dt ) );
- momentum_func( out.first , m_dqdt );
- typename algebra_type::for_each2()( out.second , in.second , m_dqdt ,
- typename operations_type::template scale_sum2< value_type , time_type >( 1.0 , coef_b[l] * dt ) );
- }
- else
- {
- coor_func( out.second , m_dqdt );
- typename algebra_type::for_each2()( out.first , out.first , m_dqdt ,
- typename operations_type::template scale_sum2< value_type , time_type >( 1.0 , coef_a[l] * dt ) );
- momentum_func( out.first , m_dqdt );
- typename algebra_type::for_each2()( out.second , out.second , m_dqdt ,
- typename operations_type::template scale_sum2< value_type , time_type >( 1.0 , coef_b[l] * dt ) );
- }
- }
- }
-
-
- // stepper for systems with only function dp /dt = -f(q), dq/dt = p
- template< class System , class StateIn , class StateOut >
- void do_step_impl( System system , const StateIn &in , const time_type &t , StateOut &out , const time_type &dt , boost::mpl::false_ )
- {
- typedef typename boost::unwrap_reference< System >::type momentum_deriv_func_type;
- momentum_deriv_func_type &momentum_func = system;
-
-
- m_coor_deriv_adjuster.adjust_size_by_policy( in , adjust_size_policy() );
- m_momentum_deriv_adjuster.adjust_size_by_policy( in , adjust_size_policy() );
-
- // ToDo: check sizes?
-
-
- for( size_t l=0 ; l<num_of_stages ; ++l )
- {
- if( l == 0 )
- {
- typename algebra_type::for_each3()( out.first , in.first , in.second ,
- typename operations_type::template scale_sum2< value_type , time_type >( 1.0 , m_coef_a[l] * dt ) );
- momentum_func( out.first , m_dqdt );
- typename algebra_type::for_each3()( out.second , in.second , m_dqdt ,
- typename operations_type::template scale_sum2< value_type , time_type >( 1.0 , m_coef_b[l] * dt ) );
- }
- else
- {
- typename algebra_type::for_each3()( out.first , out.first , out.second ,
- typename operations_type::template scale_sum2< value_type , time_type >( 1.0 , m_coef_a[l] * dt ) );
- momentum_func( out.first , m_dqdt );
- typename algebra_type::for_each3()( out.second , out.second , m_dqdt ,
- typename operations_type::template scale_sum2< value_type , time_type >( 1.0 , m_coef_b[l] * dt ) );
- }
- }
- }
-
- // ToDo : check if a and b are appropriate names for the coefficients
- const coef_type m_coef_a;
- const coef_type m_coef_b;
-
- size_adjuster< coor_deriv_type , 1 > m_coor_deriv_adjuster;
- size_adjuster< momentum_deriv_type , 1 > m_momentum_deriv_adjuster;
- coor_deriv_type m_dqdt;
- momentum_deriv_type m_dpdt;
-};
-
-} // namespace odeint
-} // namespace numeric
-} // namespace boost
-
-
-#endif // BOOST_NUMERIC_ODEINT_STEPPER_SYMPLECTIC_NYSTROEM_STEPPER_BASE_HPP_INCLUDED

Copied: sandbox/odeint/branches/karsten/boost/numeric/odeint/stepper/base/symplectic_rkn_stepper_base.hpp (from r68938, /sandbox/odeint/branches/karsten/boost/numeric/odeint/stepper/base/symplectic_nystroem_stepper_base.hpp)
==============================================================================
--- /sandbox/odeint/branches/karsten/boost/numeric/odeint/stepper/base/symplectic_nystroem_stepper_base.hpp (original)
+++ sandbox/odeint/branches/karsten/boost/numeric/odeint/stepper/base/symplectic_rkn_stepper_base.hpp 2011-02-16 03:33:13 EST (Wed, 16 Feb 2011)
@@ -24,6 +24,10 @@
 namespace numeric {
 namespace odeint {
 
+
+/*
+ * Symplectic Runge Kutta Nystroem base
+ */
 template<
         size_t NumOfStages ,
         class Stepper ,
@@ -103,36 +107,60 @@
         }
 
 
- template< class System , class StateIn , class StateOut >
- void do_step( System system , const StateIn &in , const time_type &t , const StateOut &out , const time_type &dt )
+
+ /*
+ * Version 1 : do_step( system , x , t , dt )
+ *
+ * The overloads are needed in order to solve the forwarding problem
+ */
+ template< class System , class StateInOut >
+ void do_step( System system , const StateInOut &state , const time_type &t , const time_type &dt )
         {
- do_step( system , in , t , out , dt );
+ typedef typename boost::unwrap_reference< System >::type system_type;
+ do_step_impl( system , state , t , state , dt , typename detail::is_pair< system_type >::type() );
         }
 
-
- 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 )
+ template< class System , class StateInOut >
+ void do_step( System system , StateInOut &state , const time_type &t , const time_type &dt )
         {
                 typedef typename boost::unwrap_reference< System >::type system_type;
- do_step_impl( system , in , t , out , dt , typename detail::is_pair< system_type >::type() );
+ do_step_impl( system , state , t , state , dt , typename detail::is_pair< system_type >::type() );
         }
 
+ // for convenience
+ template< class System , class CoorInOut , class MomentumInOut >
+ void do_step( System system , CoorInOut &q , MomentumInOut &p , const time_type &t , const time_type &dt )
+ {
+ do_step( system , std::make_pair( boost::ref( q ) , boost::ref( p ) ) , t , std::make_pair( boost::ref( q ) , boost::ref( p ) ) , dt );
+ }
 
 
 
- template< class System , class StateInOut >
- void do_step( System system , const StateInOut &state , const time_type &t , const time_type &dt )
+
+
+ /*
+ * Version 2 : do_step( system , in , t , out , dt )
+ *
+ * The overloads are needed in order to solve the forwarding problem
+ */
+ template< class System , class StateIn , class StateOut >
+ void do_step( System system , const StateIn &in , const time_type &t , const StateOut &out , const time_type &dt )
         {
- do_step( system , state , t , dt );
+ typedef typename boost::unwrap_reference< System >::type system_type;
+ do_step_impl( system , in , t , out , dt , typename detail::is_pair< system_type >::type() );
         }
 
- template< class System , class StateInOut >
- void do_step( System system , StateInOut &state , const time_type &t , const time_type &dt )
+
+ 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 )
         {
                 typedef typename boost::unwrap_reference< System >::type system_type;
- do_step_impl( system , state , t , state , dt , typename detail::is_pair< system_type >::type() );
+ do_step_impl( system , in , t , out , dt , typename detail::is_pair< system_type >::type() );
         }
 
+
+
+
         template< class StateType >
         void adjust_size( const StateType &x )
         {
@@ -156,6 +184,20 @@
             coor_deriv_func_type &coor_func = sys.first;
             momentum_deriv_func_type &momentum_func = sys.second;
 
+ typedef typename boost::unwrap_reference< StateIn >::type state_in_type;
+ typedef typename boost::unwrap_reference< typename state_in_type::first_type >::type coor_in_type;
+ typedef typename boost::unwrap_reference< typename state_in_type::second_type >::type momentum_in_type;
+ state_in_type &state_in = in;
+ coor_in_type &coor_in = state_in.first;
+ momentum_in_type &momentum_in = state_in.first;
+
+ typedef typename boost::unwrap_reference< StateOut >::type state_out_type;
+ typedef typename boost::unwrap_reference< typename state_out_type::first_type >::type coor_out_type;
+ typedef typename boost::unwrap_reference< typename state_out_type::second_type >::type momentum_out_type;
+ state_out_type &state_out = out;
+ coor_out_type &coor_out = state_out.first;
+ momentum_out_type &momentum_out = state_out.second;
+
 
                 m_coor_deriv_adjuster.adjust_size_by_policy( in , adjust_size_policy() );
                 m_momentum_deriv_adjuster.adjust_size_by_policy( in , adjust_size_policy() );
@@ -166,20 +208,20 @@
                 {
                         if( l == 0 )
                         {
- coor_func( in.second , m_dqdt );
- typename algebra_type::for_each2()( out.first , in.first , m_dqdt ,
+ coor_func( momentum_in , m_dqdt );
+ typename algebra_type::for_each2()( coor_out , coor_in , m_dqdt ,
                                         typename operations_type::template scale_sum2< value_type , time_type >( 1.0 , coef_a[l] * dt ) );
- momentum_func( out.first , m_dqdt );
- typename algebra_type::for_each2()( out.second , in.second , m_dqdt ,
+ momentum_func( coor_out , m_dqdt );
+ typename algebra_type::for_each2()( momentum_out , momentum_in , m_dqdt ,
                                         typename operations_type::template scale_sum2< value_type , time_type >( 1.0 , coef_b[l] * dt ) );
                         }
                         else
                         {
- coor_func( out.second , m_dqdt );
- typename algebra_type::for_each2()( out.first , out.first , m_dqdt ,
+ coor_func( momentum_out , m_dqdt );
+ typename algebra_type::for_each2()( coor_out , coor_out , m_dqdt ,
                                         typename operations_type::template scale_sum2< value_type , time_type >( 1.0 , coef_a[l] * dt ) );
- momentum_func( out.first , m_dqdt );
- typename algebra_type::for_each2()( out.second , out.second , m_dqdt ,
+ momentum_func( coor_out , m_dqdt );
+ typename algebra_type::for_each2()( momentum_out , momentum_out , m_dqdt ,
                                         typename operations_type::template scale_sum2< value_type , time_type >( 1.0 , coef_b[l] * dt ) );
                         }
                 }
@@ -193,6 +235,20 @@
             typedef typename boost::unwrap_reference< System >::type momentum_deriv_func_type;
             momentum_deriv_func_type &momentum_func = system;
 
+ typedef typename boost::unwrap_reference< StateIn >::type state_in_type;
+ typedef typename boost::unwrap_reference< typename state_in_type::first_type >::type coor_in_type;
+ typedef typename boost::unwrap_reference< typename state_in_type::second_type >::type momentum_in_type;
+ const state_in_type &state_in = in;
+ const coor_in_type &coor_in = state_in.first;
+ const momentum_in_type &momentum_in = state_in.first;
+
+ typedef typename boost::unwrap_reference< StateOut >::type state_out_type;
+ typedef typename boost::unwrap_reference< typename state_out_type::first_type >::type coor_out_type;
+ typedef typename boost::unwrap_reference< typename state_out_type::second_type >::type momentum_out_type;
+ state_out_type &state_out = out;
+ coor_out_type &coor_out = state_out.first;
+ momentum_out_type &momentum_out = state_out.second;
+
 
                 m_coor_deriv_adjuster.adjust_size_by_policy( in , adjust_size_policy() );
                 m_momentum_deriv_adjuster.adjust_size_by_policy( in , adjust_size_policy() );
@@ -204,18 +260,18 @@
                 {
                         if( l == 0 )
                         {
- typename algebra_type::for_each3()( out.first , in.first , in.second ,
+ typename algebra_type::for_each3()( coor_out , coor_in , momentum_in ,
                                         typename operations_type::template scale_sum2< value_type , time_type >( 1.0 , m_coef_a[l] * dt ) );
- momentum_func( out.first , m_dqdt );
- typename algebra_type::for_each3()( out.second , in.second , m_dqdt ,
+ momentum_func( coor_out , m_dqdt );
+ typename algebra_type::for_each3()( momentum_out , momentum_in , m_dqdt ,
                                         typename operations_type::template scale_sum2< value_type , time_type >( 1.0 , m_coef_b[l] * dt ) );
                         }
                         else
                         {
- typename algebra_type::for_each3()( out.first , out.first , out.second ,
+ typename algebra_type::for_each3()( coor_out , coor_out , momentum_out ,
                                         typename operations_type::template scale_sum2< value_type , time_type >( 1.0 , m_coef_a[l] * dt ) );
- momentum_func( out.first , m_dqdt );
- typename algebra_type::for_each3()( out.second , out.second , m_dqdt ,
+ momentum_func( coor_out , m_dqdt );
+ typename algebra_type::for_each3()( momentum_out , momentum_out , m_dqdt ,
                                         typename operations_type::template scale_sum2< value_type , time_type >( 1.0 , m_coef_b[l] * dt ) );
                         }
                 }

Modified: sandbox/odeint/branches/karsten/boost/numeric/odeint/stepper/symplectic_euler.hpp
==============================================================================
--- sandbox/odeint/branches/karsten/boost/numeric/odeint/stepper/symplectic_euler.hpp (original)
+++ sandbox/odeint/branches/karsten/boost/numeric/odeint/stepper/symplectic_euler.hpp 2011-02-16 03:33:13 EST (Wed, 16 Feb 2011)
@@ -8,7 +8,7 @@
 #ifndef BOOST_NUMERIC_ODEINT_STEPPER_SYMPLECTIC_EULER_HPP_
 #define BOOST_NUMERIC_ODEINT_STEPPER_SYMPLECTIC_EULER_HPP_
 
-#include <boost/numeric/odeint/stepper/base/symplectic_nystroem_stepper_base.hpp>
+#include <boost/numeric/odeint/stepper/base/symplectic_rkn_stepper_base.hpp>
 
 #include <boost/numeric/odeint/algebra/range_algebra.hpp>
 #include <boost/numeric/odeint/algebra/default_operations.hpp>

Modified: sandbox/odeint/branches/karsten/boost/numeric/odeint/stepper/symplectic_rkn_sb3a_mclachlan.hpp
==============================================================================
--- sandbox/odeint/branches/karsten/boost/numeric/odeint/stepper/symplectic_rkn_sb3a_mclachlan.hpp (original)
+++ sandbox/odeint/branches/karsten/boost/numeric/odeint/stepper/symplectic_rkn_sb3a_mclachlan.hpp 2011-02-16 03:33:13 EST (Wed, 16 Feb 2011)
@@ -8,7 +8,7 @@
 #ifndef SYMPLECTIC_RKN_SB3A_MCLACHLAN_HPP_
 #define SYMPLECTIC_RKN_SB3A_MCLACHLAN_HPP_
 
-#include <boost/numeric/odeint/stepper/base/symplectic_nystroem_stepper_base.hpp>
+#include <boost/numeric/odeint/stepper/base/symplectic_rkn_stepper_base.hpp>
 
 #include <boost/numeric/odeint/algebra/range_algebra.hpp>
 #include <boost/numeric/odeint/algebra/default_operations.hpp>
@@ -70,7 +70,7 @@
                 }
         };
 
-} // namespace symplectic_euler_coef
+} // namespace symplectic_rkn_sb3a_mclachlan
 } // namespace detail
 
 

Added: sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/algebra/Jamfile
==============================================================================
--- (empty file)
+++ sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/algebra/Jamfile 2011-02-16 03:33:13 EST (Wed, 16 Feb 2011)
@@ -0,0 +1,13 @@
+# (C) Copyright 2010 : Karsten Ahnert, Mario Mulansky
+# Distributed under the Boost Software License, Version 1.0.
+# (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+#project
+# : requirements
+# <define>BOOST_ALL_NO_LIB=1
+# <include>../../../../..
+# ;
+
+exe test_algebra
+ : test_algebra.cpp
+ ;

Added: sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/algebra/algebra.hpp
==============================================================================
--- (empty file)
+++ sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/algebra/algebra.hpp 2011-02-16 03:33:13 EST (Wed, 16 Feb 2011)
@@ -0,0 +1,65 @@
+/*
+ * range_algebra.hpp
+ *
+ * Created on: Feb 12, 2011
+ * Author: karsten
+ */
+
+#ifndef RANGE_ALGEBRA_HPP_
+#define RANGE_ALGEBRA_HPP_
+
+#include <iostream>
+#include <algorithm>
+
+#include <boost/range.hpp>
+#include <boost/functional/forward_adapter.hpp>
+
+struct algebra1
+{
+ struct for_each1_impl
+ {
+ template< class S1 , class Op >
+ void operator()( S1 &s1 , Op op ) const
+ {
+ std::for_each( boost::begin( s1 ) , boost::end( s1 ) , op );
+ tmp2 = 0.11;
+ }
+ typedef void result_type;
+ };
+
+ struct for_each2_impl
+ {
+ template< class S1 , class Op >
+ void operator()( S1 &s1 , Op op ) const
+ {
+ std::for_each( boost::begin( s1 ) , boost::end( s1 ) , op );
+ std::cout << tmp2 << std::endl;
+ }
+ typedef void result_type;
+ };
+
+
+ typedef boost::forward_adapter< for_each1_impl , 2 > for_each1;
+
+ double tmp2;
+
+};
+
+
+// alternativ
+
+struct algebra2
+{
+ template< class S1 , class Op >
+ void for_each1( S1 &s1 , Op op )
+ {
+ tmp = 123.0;
+ std::for_each( boost::begin( s1 ) , boost::end( s1 ) , op );
+ };
+
+ double tmp;
+};
+
+
+
+#endif /* RANGE_ALGEBRA_HPP_ */

Added: sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/algebra/test_algebra.cpp
==============================================================================
--- (empty file)
+++ sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/algebra/test_algebra.cpp 2011-02-16 03:33:13 EST (Wed, 16 Feb 2011)
@@ -0,0 +1,41 @@
+/*
+ * test_algebra.cpp
+ *
+ * Created on: Feb 12, 2011
+ * Author: karsten
+ */
+
+#include <vector>
+#include <iostream>
+
+#include "algebra.hpp"
+
+using namespace std;
+
+struct print
+{
+ template< class T >
+ void operator()( T t )
+ {
+ cout << t << endl;
+ }
+};
+
+int main( int argc , char **argv )
+{
+ algebra2 al;
+ vector< double > vec( 3 );
+ vec[0] = 0.1;
+ vec[1] = 0.95;
+ vec[2] = 1.23;
+
+ al.for_each1( vec , print() );
+ cout << al.tmp << endl;
+
+ algebra1 al2;
+
+// al2.for_each1()( vec , print() );
+// al.for_each2()( vec , print() );
+
+ return 0;
+}

Modified: sandbox/odeint/branches/karsten/libs/numeric/odeint/regression_test/hamiltonian_steppers.cpp
==============================================================================
--- sandbox/odeint/branches/karsten/libs/numeric/odeint/regression_test/hamiltonian_steppers.cpp (original)
+++ sandbox/odeint/branches/karsten/libs/numeric/odeint/regression_test/hamiltonian_steppers.cpp 2011-02-16 03:33:13 EST (Wed, 16 Feb 2011)
@@ -75,7 +75,11 @@
         const double dt = 0.1;
         const double omega_sq = 4.0;
 
+ container_type q = { { 0.0 } } , p = { { 1.0 } };
+
         stepper.do_step( harm_osc( omega_sq ) , state , t , dt );
+ stepper.do_step( harm_osc( omega_sq ) , q , p , t , dt );
+ stepper.do_step( harm_osc( omega_sq ) , std::make_pair( boost::ref( q ) , boost::ref( p ) ) , t , dt );
 }
 
 void test_rkn_sb3a_mclachlan( void )

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-16 03:33:13 EST (Wed, 16 Feb 2011)
@@ -43,7 +43,6 @@
                 dxdt[1] = 2.0;
                 dxdt[2] = 3.0;
         }
-
 };
 
 struct vector_fixture
@@ -138,22 +137,16 @@
 BOOST_AUTO_TEST_CASE( explicit_euler_with_range_v4 )
 {
         vector_fixture f;
- f.euler.do_step( lorenz() , std::make_pair( f.in.begin() + 2 , f.in.begin() + 5 ) , 0.1 ,
- std::make_pair( f.out.begin() , f.out.begin() +3 ) , 0.1 );
+ lorenz()( std::make_pair( f.in.begin() , f.in.begin() + 3 ) ,
+ std::make_pair( f.dxdt.begin() + 3 , f.dxdt.begin() + 6 ) , 0.0 );
+ f.euler.do_step( lorenz() , std::make_pair( f.in.begin() , f.in.begin() + 3 ) ,
+ std::make_pair( f.dxdt.begin() + 3 , f.dxdt.begin() + 6 ) , 0.1 ,
+ std::make_pair( f.out.begin() , f.out.begin() + 3 ) , 0.1 );
         CHECK_IN_DEFAULT( f.in );
- CHECK_VALUES( f.out , 2.2 , 3.2 , 4.3 , 13.0 , 14.0 , 15.0 );
- CHECK_DXDT_DEFAULT( f.dxdt );
+ CHECK_VALUES( f.out , 0.0 , 1.2 , 2.3 , 13.0 , 14.0 , 15.0 );
+ CHECK_VALUES( f.dxdt , 100.0 , 101.0 , 102.0 , 0.0 , 2.0 , 3.0 );
 }
 
 
 
-BOOST_AUTO_TEST_CASE( explicit_euler_with_array )
-{
- state_type2 x;
- boost::numeric::odeint::explicit_euler< state_type > euler;
- euler.do_step( lorenz() , x , 0.0 , 0.1 );
- euler.do_step( lorenz() , x , 0.1 , 0.1 );
-}
-
-
 BOOST_AUTO_TEST_SUITE_END()


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