Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r68963 - in sandbox/odeint/branches/karsten: . boost/numeric/odeint/algebra boost/numeric/odeint/external/thrust boost/numeric/odeint/integrate boost/numeric/odeint/stepper boost/numeric/odeint/stepper/base
From: karsten.ahnert_at_[hidden]
Date: 2011-02-16 16:59:39


Author: karsten
Date: 2011-02-16 16:59:37 EST (Wed, 16 Feb 2011)
New Revision: 68963
URL: http://svn.boost.org/trac/boost/changeset/68963

Log:
small bug fixes and cuda support
Text files modified:
   sandbox/odeint/branches/karsten/TODO | 21 +++++--------
   sandbox/odeint/branches/karsten/boost/numeric/odeint/algebra/default_operations.hpp | 8 +++++
   sandbox/odeint/branches/karsten/boost/numeric/odeint/external/thrust/thrust_algebra.hpp | 61 +++++++++++----------------------------
   sandbox/odeint/branches/karsten/boost/numeric/odeint/external/thrust/thrust_operations.hpp | 1
   sandbox/odeint/branches/karsten/boost/numeric/odeint/integrate/integrate.hpp | 2 -
   sandbox/odeint/branches/karsten/boost/numeric/odeint/stepper/base/symplectic_rkn_stepper_base.hpp | 30 +++++++------------
   sandbox/odeint/branches/karsten/boost/numeric/odeint/stepper/symplectic_rkn_sb3a_mclachlan.hpp | 4 +-
   7 files changed, 48 insertions(+), 79 deletions(-)

Modified: sandbox/odeint/branches/karsten/TODO
==============================================================================
--- sandbox/odeint/branches/karsten/TODO (original)
+++ sandbox/odeint/branches/karsten/TODO 2011-02-16 16:59:37 EST (Wed, 16 Feb 2011)
@@ -6,8 +6,7 @@
     * include dense_output_explicit
     * inlcude dense_output_controlled_explicit_fsal
   * test gsl
- DIFFICULT * test explicit stepper with ranges
- * discuss
+ * test explicit stepper with ranges
   * split check_concepts into check_stepper_concept, check_error_stepper_concept, check_controlled_stepper_concept
   * include test/thrust in jam system, use system from
 * implicit euler, include dfdt
@@ -16,9 +15,6 @@
   * 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
-OK * file cleanup
- OK * split resizing and copy/destruct/construct in different files
- OK * subfolder algebra, operations, util
 * general:
   * check if everywhere static_cast< value_type > is used
   * check header guards
@@ -30,16 +26,9 @@
   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
-
-
-
+* 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
-
 * Documentation
 * Tutorials
 
@@ -47,6 +36,12 @@
 
 DONE:
 
+OK * decrease complexity:
+ LATER * remove construct, destruct, copy ?
+ OK * remove the overloads solving the forwarding problem. boost::range can not be used then anymore
+OK * file cleanup
+ OK * split resizing and copy/destruct/construct in different files
+ OK * subfolder algebra, operations, util
 OK * change standard_operations::rel_error in order to word with units and test it
 OK * include implicit euler
   OK * call via std::pair< deriv , jacobi >

Modified: sandbox/odeint/branches/karsten/boost/numeric/odeint/algebra/default_operations.hpp
==============================================================================
--- sandbox/odeint/branches/karsten/boost/numeric/odeint/algebra/default_operations.hpp (original)
+++ sandbox/odeint/branches/karsten/boost/numeric/odeint/algebra/default_operations.hpp 2011-02-16 16:59:37 EST (Wed, 16 Feb 2011)
@@ -16,8 +16,10 @@
 #include <algorithm>
 #include <cmath> // for std::max
 
+#ifndef __CUDACC__
 #include <boost/utility/result_of.hpp>
 #include <boost/units/quantity.hpp>
+#endif
 
 namespace boost {
 namespace numeric {
@@ -28,6 +30,7 @@
  */
 namespace detail
 {
+
                 template< class T >
                 struct get_value_impl
                 {
@@ -35,12 +38,14 @@
                         typedef T result_type;
                 };
 
+ #ifndef __CUDACC__
                 template< class Unit , class T >
                 struct get_value_impl< boost::units::quantity< Unit , T > >
                 {
                         static T value( const boost::units::quantity< Unit , T > &t ) { return t.value(); }
                         typedef T result_type;
                 };
+ #endif
 
                 template< class T >
                 typename get_value_impl< T >::result_type get_value( const T &t ) { return get_value_impl< T >::value( t ); }
@@ -53,14 +58,17 @@
                         static void set_value( T &t , const V &v ) { t = v; }
                 };
 
+ #ifndef __CUDACC__
                 template< class Unit , class T , class V >
                 struct set_value_impl< boost::units::quantity< Unit , T > , V >
                 {
                         static void set_value( boost::units::quantity< Unit , T > &t , const V &v ) { t = boost::units::quantity< Unit , T >::from_value( v ); }
                 };
+ #endif
 
                 template< class T , class V >
                 void set_value( T &t , const V &v ) { return set_value_impl< T , V >::set_value( t , v ); }
+
 }
 
 

Modified: sandbox/odeint/branches/karsten/boost/numeric/odeint/external/thrust/thrust_algebra.hpp
==============================================================================
--- sandbox/odeint/branches/karsten/boost/numeric/odeint/external/thrust/thrust_algebra.hpp (original)
+++ sandbox/odeint/branches/karsten/boost/numeric/odeint/external/thrust/thrust_algebra.hpp 2011-02-16 16:59:37 EST (Wed, 16 Feb 2011)
@@ -17,9 +17,6 @@
 #include <thrust/iterator/zip_iterator.h>
 
 #include <boost/range.hpp>
-#define BOOST_FUNCTIONAL_FORWARD_ADAPTER_MAX_ARITY 9
-#include <boost/functional/forward_adapter.hpp>
-
 
 namespace boost {
 namespace numeric {
@@ -35,51 +32,29 @@
 
 struct thrust_algebra
 {
- struct for_each1_impl
+ template< class StateType , class Operation >
+ static void for_each1( StateType &s , Operation op )
         {
- template< class StateType , class Operation >
- void operator()( StateType &s , Operation op ) const
- {
- thrust::for_each( boost::begin(s) , boost::begin(s) , op );
- }
- typedef void result_type;
- };
-
+ thrust::for_each( boost::begin(s) , boost::begin(s) , op );
+ }
 
- struct for_each2_impl
+ template< class StateType1 , class StateType2 , class Operation >
+ static void for_each2( StateType1 &s1 , StateType2 &s2 , Operation op )
         {
+ thrust::for_each(
+ thrust::make_zip_iterator( thrust::make_tuple( boost::begin(s1) , boost::begin(s2) ) ) ,
+ thrust::make_zip_iterator( thrust::make_tuple( boost::end(s1) , boost::end(s2) ) ) ,
+ op);
+ }
 
- template< class StateType1 , class StateType2 , class Operation >
- void operator()( StateType1 &s1 , StateType2 &s2 , Operation op ) const
- {
- thrust::for_each(
- thrust::make_zip_iterator( thrust::make_tuple( boost::begin(s1) , boost::begin(s2) ) ) ,
- thrust::make_zip_iterator( thrust::make_tuple( boost::end(s1) , boost::end(s2) ) ) ,
- op);
- }
- typedef void result_type;
- };
-
-
-
- struct for_each3_impl
+ template< class StateType1 , class StateType2 , class StateType3 , class Operation >
+ static void for_each3( StateType1 &s1 , StateType2 &s2 , StateType3 &s3 , Operation op )
         {
-
-
- template< class StateType1 , class StateType2 , class StateType3 , class Operation >
- void operator()( StateType1 &s1 , StateType2 &s2 , StateType3 &s3 , Operation op ) const
- {
- thrust::for_each(
- thrust::make_zip_iterator( thrust::make_tuple( boost::begin(s1) , boost::begin(s2) , boost::begin(s3) ) ) ,
- thrust::make_zip_iterator( thrust::make_tuple( boost::end(s1) , boost::end(s2) , boost::begin(s3) ) ) ,
- op);
- }
- typedef void result_type;
- };
-
- typedef boost::forward_adapter< for_each1_impl , 2 > for_each1;
- typedef boost::forward_adapter< for_each2_impl , 3 > for_each2;
- typedef boost::forward_adapter< for_each3_impl , 4 > for_each3;
+ thrust::for_each(
+ thrust::make_zip_iterator( thrust::make_tuple( boost::begin(s1) , boost::begin(s2) , boost::begin(s3) ) ) ,
+ thrust::make_zip_iterator( thrust::make_tuple( boost::end(s1) , boost::end(s2) , boost::begin(s3) ) ) ,
+ op);
+ }
 };
 
 

Modified: sandbox/odeint/branches/karsten/boost/numeric/odeint/external/thrust/thrust_operations.hpp
==============================================================================
--- sandbox/odeint/branches/karsten/boost/numeric/odeint/external/thrust/thrust_operations.hpp (original)
+++ sandbox/odeint/branches/karsten/boost/numeric/odeint/external/thrust/thrust_operations.hpp 2011-02-16 16:59:37 EST (Wed, 16 Feb 2011)
@@ -16,6 +16,7 @@
 namespace numeric {
 namespace odeint {
 
+#include <thrust/tuple.h>
 #include <thrust/iterator/zip_iterator.h>
 
 

Modified: sandbox/odeint/branches/karsten/boost/numeric/odeint/integrate/integrate.hpp
==============================================================================
--- sandbox/odeint/branches/karsten/boost/numeric/odeint/integrate/integrate.hpp (original)
+++ sandbox/odeint/branches/karsten/boost/numeric/odeint/integrate/integrate.hpp 2011-02-16 16:59:37 EST (Wed, 16 Feb 2011)
@@ -46,7 +46,6 @@
         {
                 return detail::integrate_const( stepper , system , start_state , start_time , end_time , dt , observer , typename Stepper::stepper_category() );
         }
- return 0;
 }
 
 template< class Stepper , class System , class State , class Time , class Observer >
@@ -70,7 +69,6 @@
 size_t integrate_adaptive( Stepper stepper , System system , State &start_state , const Time &start_time , const Time &end_time , Time &dt , Observer observer )
 {
         return detail::integrate_adaptive( stepper , system , start_state , start_time , end_time , dt , observer , typename Stepper::stepper_category() );
- return 0;
 }
 
 

Modified: sandbox/odeint/branches/karsten/boost/numeric/odeint/stepper/base/symplectic_rkn_stepper_base.hpp
==============================================================================
--- sandbox/odeint/branches/karsten/boost/numeric/odeint/stepper/base/symplectic_rkn_stepper_base.hpp (original)
+++ sandbox/odeint/branches/karsten/boost/numeric/odeint/stepper/base/symplectic_rkn_stepper_base.hpp 2011-02-16 16:59:37 EST (Wed, 16 Feb 2011)
@@ -131,7 +131,7 @@
         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 );
+ do_step( system , std::make_pair( boost::ref( q ) , boost::ref( p ) ) , t , dt );
         }
 
 
@@ -141,17 +141,9 @@
         /*
          * Version 2 : do_step( system , in , t , out , dt )
          *
- * The overloads are needed in order to solve the forwarding problem
+ * The forwarding problem is not solved in this version
          */
         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 )
- {
- 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 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;
@@ -199,8 +191,8 @@
             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() );
+ m_coor_deriv_adjuster.adjust_size_by_policy( coor_in , adjust_size_policy() );
+ m_momentum_deriv_adjuster.adjust_size_by_policy( coor_in , adjust_size_policy() );
 
                 // ToDo: check sizes?
 
@@ -210,19 +202,19 @@
                         {
                                 coor_func( momentum_in , m_dqdt );
                                 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 ) );
+ typename operations_type::template scale_sum2< value_type , time_type >( 1.0 , m_coef_a[l] * dt ) );
                                 momentum_func( coor_out , m_dqdt );
                                 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 ) );
+ typename operations_type::template scale_sum2< value_type , time_type >( 1.0 , m_coef_b[l] * dt ) );
                         }
                         else
                         {
                                 coor_func( momentum_out , m_dqdt );
                                 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 ) );
+ typename operations_type::template scale_sum2< value_type , time_type >( 1.0 , m_coef_a[l] * dt ) );
                                 momentum_func( coor_out , m_dqdt );
                                 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 ) );
+ typename operations_type::template scale_sum2< value_type , time_type >( 1.0 , m_coef_b[l] * dt ) );
                         }
                 }
         }
@@ -240,7 +232,7 @@
             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;
+ const momentum_in_type &momentum_in = state_in.second;
 
             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;
@@ -250,8 +242,8 @@
             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() );
+ m_coor_deriv_adjuster.adjust_size_by_policy( coor_in , adjust_size_policy() );
+ m_momentum_deriv_adjuster.adjust_size_by_policy( coor_in , adjust_size_policy() );
 
                 // ToDo: check sizes?
 

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 16:59:37 EST (Wed, 16 Feb 2011)
@@ -90,13 +90,13 @@
         public symplectic_nystroem_stepper_base
         <
                 6 ,
- symplectic_euler< Coor , Momentum , Value , CoorDeriv , MomentumDeriv , Time , Algebra , Operations , AdjustSizePolicy > ,
+ symplectic_rkn_sb3a_mclachlan< Coor , Momentum , Value , CoorDeriv , MomentumDeriv , Time , Algebra , Operations , AdjustSizePolicy > ,
                 Coor , Momentum , Value , CoorDeriv , MomentumDeriv , Time , Algebra , Operations , AdjustSizePolicy
>
 {
 public:
 
- BOOST_ODEINT_SYMPLECTIC_NYSTROEM_STEPPER_TYPEDEFS( symplectic_euler , 6 );
+ BOOST_ODEINT_SYMPLECTIC_NYSTROEM_STEPPER_TYPEDEFS( symplectic_rkn_sb3a_mclachlan , 6 );
 
                 symplectic_rkn_sb3a_mclachlan( void )
                 : stepper_base_type(


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