Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r71559 - in sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas: fusion_runge_kutta generic_stepper
From: mario.mulansky_at_[hidden]
Date: 2011-04-28 03:44:19


Author: mariomulansky
Date: 2011-04-28 03:44:16 EDT (Thu, 28 Apr 2011)
New Revision: 71559
URL: http://svn.boost.org/trac/boost/changeset/71559

Log:
some updates, and tested with msvc
Text files modified:
   sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/fusion_runge_kutta/Jamfile | 2
   sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/fusion_runge_kutta/fusion_algebra.hpp | 43 ++++++++++++++++++++++-----------------
   sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/fusion_runge_kutta/fusion_explicit_rk_new.hpp | 12 ++++------
   sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/fusion_runge_kutta/test_explicit_rk.cpp | 11 +++++----
   sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/generic_stepper/Jamfile | 3 -
   sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/generic_stepper/performance.cpp | 6 ++--
   sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/generic_stepper/performance_fusion.cpp | 12 ++++++----
   sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/generic_stepper/performance_mpl.cpp | 6 ++--
   sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/generic_stepper/performance_odeint.cpp | 12 ++++++----
   9 files changed, 57 insertions(+), 50 deletions(-)

Modified: sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/fusion_runge_kutta/Jamfile
==============================================================================
--- sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/fusion_runge_kutta/Jamfile (original)
+++ sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/fusion_runge_kutta/Jamfile 2011-04-28 03:44:16 EDT (Thu, 28 Apr 2011)
@@ -6,7 +6,7 @@
 import modules ;
 import path ;
 
-path-constant HOME : [ os.environ HOME ] ;
+#path-constant HOME : [ os.environ HOME ] ;
 #path-constant CHRONO_ROOT : [ os.environ CHRONO_ROOT ] ;
 
 project

Modified: sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/fusion_runge_kutta/fusion_algebra.hpp
==============================================================================
--- sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/fusion_runge_kutta/fusion_algebra.hpp (original)
+++ sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/fusion_runge_kutta/fusion_algebra.hpp 2011-04-28 03:44:16 EDT (Thu, 28 Apr 2011)
@@ -15,6 +15,7 @@
 struct fusion_algebra
 {
 
+
     template< typename T , size_t dim >
     inline static void foreach( boost::array< T , dim > &x_tmp , const boost::array< T , dim > &x ,
             const boost::array< double , n > &a ,
@@ -36,17 +37,18 @@
 /** hand-wise implementation for performance improvement for n = 1..4 **/
 
 /* !!!!!!! Actually, this is factor 3 slower with intel compiler, so we don'y use it !!!!!
- *
+ * Update: Current implementation increases performance on msvc 9.0 by about 30%, so it is in use again....
+ */
 
 template<>
 struct fusion_algebra< 1 >
 {
-
- template< class state_type >
- inline 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 )
+ template< typename T , size_t dim >
+ inline static void foreach( boost::array< T , dim > &x_tmp , const boost::array< T , dim > &x ,
+ const boost::array< double , 1 > &a ,
+ const boost::array< T , dim > *k_vector , const double dt )
     {
- for( size_t i=0 ; i<x.size() ; ++i )
+ for( size_t i=0 ; i<dim ; ++i )
         {
             x_tmp[i] = x[i] + a[0]*dt*k_vector[0][i];
         }
@@ -59,11 +61,12 @@
 struct fusion_algebra< 2 >
 {
 
- template< class state_type >
- inline 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 )
+ template< typename T , size_t dim >
+ inline static void foreach( boost::array< T , dim > &x_tmp , const boost::array< T , dim > &x ,
+ const boost::array< double , 2 > &a ,
+ const boost::array< T , dim > *k_vector , const double dt )
     {
- for( size_t i=0 ; i<x.size() ; ++i )
+ for( size_t i=0 ; i<dim ; ++i )
         {
             x_tmp[i] = x[i] + a[0]*dt*k_vector[0][i] + a[1]*dt*k_vector[1][i];
         }
@@ -76,11 +79,12 @@
 struct fusion_algebra< 3 >
 {
 
- template< class state_type >
- inline static void foreach( state_type &x_tmp , const state_type &x , const boost::array< double , 3 > &a ,
- const state_type *k_vector , const double dt )
+ template< typename T , size_t dim >
+ inline static void foreach( boost::array< T , dim > &x_tmp , const boost::array< T , dim > &x ,
+ const boost::array< double , 3 > &a ,
+ const boost::array< T , dim > *k_vector , const double dt )
     {
- for( size_t i=0 ; i<x.size() ; ++i )
+ for( size_t i=0 ; i<dim ; ++i )
         {
             x_tmp[i] = x[i] + a[0]*dt*k_vector[0][i] + a[1]*dt*k_vector[1][i] + a[2]*dt*k_vector[2][i];
         }
@@ -92,11 +96,12 @@
 struct fusion_algebra< 4 >
 {
 
- template< class state_type >
- inline static void foreach( state_type &x_tmp , const state_type &x , const boost::array< double , 4 > &a ,
- const state_type *k_vector , const double dt )
+ template< typename T , size_t dim >
+ inline static void foreach( boost::array< T , dim > &x_tmp , const boost::array< T , dim > &x ,
+ const boost::array< double , 4 > &a ,
+ const boost::array< T , dim > *k_vector , const double dt )
     {
- for( size_t i=0 ; i<x.size() ; ++i )
+ for( size_t i=0 ; i<dim ; ++i )
         {
             x_tmp[i] = x[i] + a[0]*dt*k_vector[0][i] + a[1]*dt*k_vector[1][i] +
                            a[2]*dt*k_vector[2][i] + a[3]*dt*k_vector[3][i];;
@@ -104,6 +109,6 @@
     }
 
 };
-*/
+
 
 #endif /* FUSION_ALGEBRA_HPP_ */

Modified: sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/fusion_runge_kutta/fusion_explicit_rk_new.hpp
==============================================================================
--- sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/fusion_runge_kutta/fusion_explicit_rk_new.hpp (original)
+++ sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/fusion_runge_kutta/fusion_explicit_rk_new.hpp 2011-04-28 03:44:16 EDT (Thu, 28 Apr 2011)
@@ -52,21 +52,19 @@
     typedef typename fusion::vector< size_t , T , boost::array< T , Constant::value > , StageCategory > type;
 };
 
-template< class T , size_t n , class StageCategory >
+template< class T , size_t i , class StageCategory >
 struct stage
 {
- static const size_t stage_number = n - 1;
     T m_c;
- boost::array< T , n > m_a;
+ boost::array< T , i > m_a;
     typedef StageCategory category;
 };
 
-template< class T , size_t n>
-struct stage< T , n , last_stage >
+template< class T , size_t i>
+struct stage< T , i , last_stage >
 {
- static const size_t stage_number = n - 1;
     T m_c;
- boost::array< T , n > m_b;
+ boost::array< T , i > m_b;
     typedef last_stage category;
 };
 

Modified: sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/fusion_runge_kutta/test_explicit_rk.cpp
==============================================================================
--- sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/fusion_runge_kutta/test_explicit_rk.cpp (original)
+++ sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/fusion_runge_kutta/test_explicit_rk.cpp 2011-04-28 03:44:16 EDT (Thu, 28 Apr 2011)
@@ -14,8 +14,8 @@
 #include <boost/accumulators/statistics.hpp>
 #include <boost/timer.hpp>
 
-//#include "fusion_explicit_rk.hpp"
-#include "fusion_explicit_rk_new.hpp"
+#include "fusion_explicit_rk.hpp"
+//#include "fusion_explicit_rk_new.hpp"
 
 #define tab "\t"
 
@@ -70,16 +70,17 @@
     rk4_fusion_type rk4_fusion( a , b , c );
 
     const size_t num_of_steps = 20000000;
- const size_t dt = 0.01;
+ const double dt = 0.01;
 
     accumulator_type acc;
     timer_type timer;
 
- srand48( 12312354 );
+ srand( 12312354 );
 
     while( true )
     {
- state_type x = {{ 10.0 * drand48() , 10.0 * drand48() , 10.0 * drand48() }};
+ state_type x = {{ 10.0 * rand()/RAND_MAX , 10.0 * rand()/RAND_MAX , 10.0 * rand()/RAND_MAX }};
+ //state_type x = {{ 10.0 , 1.0 , 5.0 }};
         double t = 0.0;
 
         timer.restart();

Modified: sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/generic_stepper/Jamfile
==============================================================================
--- sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/generic_stepper/Jamfile (original)
+++ sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/generic_stepper/Jamfile 2011-04-28 03:44:16 EDT (Thu, 28 Apr 2011)
@@ -6,8 +6,7 @@
 import modules ;
 import path ;
 
-path-constant HOME : [ os.environ HOME ] ;
-path-constant CHRONO_ROOT : [ os.environ CHRONO_ROOT ] ;
+#path-constant CHRONO_ROOT : [ os.environ CHRONO_ROOT ] ;
 
 project
     : requirements

Modified: sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/generic_stepper/performance.cpp
==============================================================================
--- sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/generic_stepper/performance.cpp (original)
+++ sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/generic_stepper/performance.cpp 2011-04-28 03:44:16 EDT (Thu, 28 Apr 2011)
@@ -15,7 +15,7 @@
 #include <iostream>
 #include <fstream>
 
-#include <tr1/array>
+#include <boost/array.hpp>
 
 #include <boost/numeric/odeint/stepper/explicit_rk4.hpp>
 #include <boost/accumulators/accumulators.hpp>
@@ -44,7 +44,7 @@
 typedef boost::timer timer_type;
 
 
-typedef std::tr1::array< double , 3 > state_type;
+typedef boost::array< double , 3 > state_type;
 typedef boost::numeric::odeint::explicit_rk4< state_type > rk4_odeint_type;
 typedef mpl_rk4_stepper< state_type > rk4_mpl_type;
 typedef runge_kutta_stepper< state_type , 4 > rk4_fusion_type;
@@ -83,7 +83,7 @@
     rk4_fusion_type rk4_fusion( a , b , c );
 
     const size_t num_of_steps = 20000000;
- const size_t dt = 0.01;
+ const double dt = 0.01;
 
     accumulator_type acc1 , acc2 , acc3;
     timer_type timer;

Modified: sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/generic_stepper/performance_fusion.cpp
==============================================================================
--- sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/generic_stepper/performance_fusion.cpp (original)
+++ sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/generic_stepper/performance_fusion.cpp 2011-04-28 03:44:16 EDT (Thu, 28 Apr 2011)
@@ -15,7 +15,7 @@
 #include <iostream>
 #include <fstream>
 
-#include <tr1/array>
+#include <boost/array.hpp>
 
 #include <boost/accumulators/accumulators.hpp>
 #include <boost/accumulators/statistics.hpp>
@@ -42,7 +42,7 @@
 typedef boost::timer timer_type;
 
 
-typedef std::tr1::array< double , 3 > state_type;
+typedef boost::array< double , 3 > state_type;
 typedef runge_kutta_stepper< state_type , 4 > rk4_fusion_type;
 
 
@@ -76,16 +76,18 @@
     rk4_fusion_type rk4_fusion( a , b , c );
 
     const size_t num_of_steps = 20000000;
- const size_t dt = 0.01;
+ const double dt = 0.01;
 
     accumulator_type acc;
     timer_type timer;
 
- srand48( 12312354 );
+ srand( 12312354 );
 
     while( true )
     {
- state_type x = {{ 10.0 * drand48() , 10.0 * drand48() , 10.0 * drand48() }};
+ state_type x = {{ 10.0 * rand()/RAND_MAX ,
+ 10.0 * rand()/RAND_MAX ,
+ 10.0 * rand()/RAND_MAX }};
         double t = 0.0;
 
         timer.restart();

Modified: sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/generic_stepper/performance_mpl.cpp
==============================================================================
--- sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/generic_stepper/performance_mpl.cpp (original)
+++ sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/generic_stepper/performance_mpl.cpp 2011-04-28 03:44:16 EDT (Thu, 28 Apr 2011)
@@ -15,7 +15,7 @@
 #include <iostream>
 #include <fstream>
 
-#include <tr1/array>
+#include <boost/array.hpp>
 
 #include <boost/accumulators/accumulators.hpp>
 #include <boost/accumulators/statistics.hpp>
@@ -42,7 +42,7 @@
 typedef boost::timer timer_type;
 
 
-typedef std::tr1::array< double , 3 > state_type;
+typedef boost::array< double , 3 > state_type;
 typedef mpl_rk4_stepper< state_type > rk4_mpl_type;
 
 
@@ -64,7 +64,7 @@
     rk4_mpl_type rk4_mpl;
 
     const size_t num_of_steps = 20000000;
- const size_t dt = 0.01;
+ const double dt = 0.01;
 
     accumulator_type acc;
     timer_type timer;

Modified: sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/generic_stepper/performance_odeint.cpp
==============================================================================
--- sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/generic_stepper/performance_odeint.cpp (original)
+++ sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/generic_stepper/performance_odeint.cpp 2011-04-28 03:44:16 EDT (Thu, 28 Apr 2011)
@@ -15,7 +15,7 @@
 #include <iostream>
 #include <fstream>
 
-#include <tr1/array>
+#include <boost/array.hpp>
 
 #include <boost/numeric/odeint/stepper/explicit_rk4.hpp>
 #include <boost/accumulators/accumulators.hpp>
@@ -41,7 +41,7 @@
 typedef boost::timer timer_type;
 
 
-typedef std::tr1::array< double , 3 > state_type;
+typedef boost::array< double , 3 > state_type;
 typedef boost::numeric::odeint::explicit_rk4< state_type > rk4_odeint_type;
 
 
@@ -63,16 +63,18 @@
     rk4_odeint_type rk4_odeint;
 
     const size_t num_of_steps = 20000000;
- const size_t dt = 0.01;
+ const double dt = 0.01;
 
     accumulator_type acc;
     timer_type timer;
 
- srand48( 12312354 );
+ srand( 12312354 );
 
     while( true )
     {
- state_type x = {{ 10.0 * drand48() , 10.0 * drand48() , 10.0 * drand48() }};
+ state_type x = {{ 10.0 * rand()/RAND_MAX ,
+ 10.0 * rand()/RAND_MAX ,
+ 10.0 * rand()/RAND_MAX }};
         double t = 0.0;
 
         timer.restart();


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