Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r66698 - sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/generic_stepper
From: mario.mulansky_at_[hidden]
Date: 2010-11-23 04:44:28


Author: mariomulansky
Date: 2010-11-23 04:44:25 EST (Tue, 23 Nov 2010)
New Revision: 66698
URL: http://svn.boost.org/trac/boost/changeset/66698

Log:
now using arrays
Text files modified:
   sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/generic_stepper/algebra.hpp | 11 ++++++++---
   sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/generic_stepper/fusion_stepper.hpp | 25 +++++++++++++++----------
   2 files changed, 23 insertions(+), 13 deletions(-)

Modified: sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/generic_stepper/algebra.hpp
==============================================================================
--- sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/generic_stepper/algebra.hpp (original)
+++ sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/generic_stepper/algebra.hpp 2010-11-23 04:44:25 EST (Tue, 23 Nov 2010)
@@ -10,6 +10,8 @@
 
 #include <vector>
 
+#include <boost/array.hpp>
+
 #include <boost/numeric/odeint/algebra/standard_algebra.hpp>
 #include <boost/numeric/odeint/algebra/standard_operations.hpp>
 
@@ -22,7 +24,8 @@
         typedef typename boost::numeric::odeint::standard_operations< double > std_op;
 
 
- static void foreach( state_type &x_tmp , const state_type &x , const std::vector< double > &a , const state_type *k_vector , const double dt )
+ static void foreach( state_type &x_tmp , const state_type &x , const boost::array< double , n > &a ,
+ const state_type *k_vector , const double dt )
         {}
 
 };
@@ -34,7 +37,8 @@
         typedef typename boost::numeric::odeint::standard_algebra< state_type > std_algebra;
         typedef typename boost::numeric::odeint::standard_operations< double > std_op;
 
- static void foreach( state_type &x_tmp , const state_type &x , const std::vector< double > &a , const state_type *k_vector , const double dt )
+ static void foreach( state_type &x_tmp , const state_type &x , const boost::array< double , 1 > &a ,
+ const state_type *k_vector , const double dt )
         {
                 std_algebra::for_each3( x_tmp , x , k_vector[0] , std_op::scale_sum2( 1.0 , a[0]*dt ) );
         }
@@ -49,7 +53,8 @@
         typedef typename boost::numeric::odeint::standard_algebra< state_type > std_algebra;
         typedef typename boost::numeric::odeint::standard_operations< double > std_op;
 
- static void foreach( state_type &x_tmp , const state_type &x , const std::vector< double > &a , const state_type *k_vector , const double dt )
+ static void foreach( state_type &x_tmp , const state_type &x , const boost::array< double , 2 > &a ,
+ const state_type *k_vector , const double dt )
         {
                 std_algebra::for_each4( x_tmp , x , k_vector[0] , k_vector[1] , std_op::scale_sum3( 1.0 , a[0]*dt , a[1]*dt ) );
         }

Modified: sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/generic_stepper/fusion_stepper.hpp
==============================================================================
--- sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/generic_stepper/fusion_stepper.hpp (original)
+++ sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/generic_stepper/fusion_stepper.hpp 2010-11-23 04:44:25 EST (Tue, 23 Nov 2010)
@@ -20,11 +20,14 @@
 #include <boost/mpl/insert_range.hpp>
 
 #include <vector>
+#include <algorithm>
 
 #include <boost/fusion/container.hpp>
 #include <boost/fusion/algorithm.hpp>
 #include <boost/fusion/include/mpl.hpp>
 
+#include <boost/array.hpp>
+
 #include <typeinfo>
 
 
@@ -49,7 +52,7 @@
 
     void init( const parameter_array_type2D &a , const parameter_array_type1D &c )
     {
- m_a_row = a[stage-1];
+ copy( a[stage-1].begin() , a[stage-1].end() , &m_a_row[0] );
         m_c = c[stage-1];
     }
 
@@ -63,7 +66,7 @@
 
 private:
 
- vector< value_type > m_a_row;
+ boost::array< value_type , stage > m_a_row;
     value_type m_c;
 
 };
@@ -82,7 +85,7 @@
 
     void init( const parameter_array_type2D &a , const parameter_array_type1D &c )
     {
- m_a_row = a[0];
+ copy( a[0].begin() , a[0].end() , &m_a_row[0] );
         m_c = c[0];
     }
 
@@ -96,7 +99,7 @@
 
 private:
 
- vector< value_type > m_a_row;
+ boost::array< value_type , 1 > m_a_row;
     value_type m_c;
 
 };
@@ -116,12 +119,13 @@
 
     void init( const parameter_array_type1D &b , const parameter_array_type1D &c )
     {
- m_b = b;
+ copy( b.begin() , b.end() , &m_b[0] );
         m_c = c[stage-1];
     }
 
     template< typename System >
- void operator() ( System &system , state_type &x_tmp , state_type &x , state_type *k_vector , double t , const double dt )
+ void operator() ( System &system , state_type &x_tmp , state_type &x , state_type *k_vector ,
+ double t , const double dt ) const
     {
         system( x_tmp , k_vector[stage-1] , t + m_c * dt );
         algebra<state_type , stage>::foreach( x , x , m_b , k_vector , dt);
@@ -129,7 +133,7 @@
 
 private:
 
- vector< value_type > m_b;
+ boost::array< value_type , stage > m_b;
     value_type m_c;
 
 };
@@ -149,12 +153,13 @@
 
     void init( const parameter_array_type1D &b , const parameter_array_type1D &c )
     {
- m_b = b;
+ copy( b.begin() , b.end() , &m_b[0] );
         m_c = c[0];
     }
 
     template< typename System >
- void operator() ( System &system , state_type &x_tmp , state_type &x , state_type k_vector[1] , double t , const double dt )
+ void operator() ( System &system , state_type &x_tmp , state_type &x , state_type k_vector[1] ,
+ double t , const double dt ) const
     {
         system( x , k_vector[0] , t + m_c * dt );
         algebra<state_type , 1>::foreach( x , x , m_b , k_vector , dt);
@@ -162,7 +167,7 @@
 
 private:
 
- vector< value_type > m_b;
+ boost::array< value_type , 1 > m_b;
     value_type m_c;
 
 };


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