Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r71561 - sandbox/odeint/branches/karsten/boost/numeric/odeint/algebra
From: mario.mulansky_at_[hidden]
Date: 2011-04-28 09:40:02


Author: mariomulansky
Date: 2011-04-28 09:40:01 EDT (Thu, 28 Apr 2011)
New Revision: 71561
URL: http://svn.boost.org/trac/boost/changeset/71561

Log:
added array_algebra which gives about 20% performance gain for the rk4 stepper
however, const correctness is a problem there....
Added:
   sandbox/odeint/branches/karsten/boost/numeric/odeint/algebra/array_algebra.hpp (contents, props changed)

Added: sandbox/odeint/branches/karsten/boost/numeric/odeint/algebra/array_algebra.hpp
==============================================================================
--- (empty file)
+++ sandbox/odeint/branches/karsten/boost/numeric/odeint/algebra/array_algebra.hpp 2011-04-28 09:40:01 EDT (Thu, 28 Apr 2011)
@@ -0,0 +1,87 @@
+/*
+ boost header: BOOST_NUMERIC_ODEINT/array_algebra.hpp
+
+ Copyright 2009 Karsten Ahnert
+ Copyright 2009 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)
+ */
+
+#ifndef BOOST_NUMERIC_ODEINT_ARRAY_ALGEBRA_HPP_INCLUDED
+#define BOOST_NUMERIC_ODEINT_ARRAY_ALGEBRA_HPP_INCLUDED
+
+
+#include <boost/array.hpp>
+
+namespace boost {
+namespace numeric {
+namespace odeint {
+
+struct array_algebra
+{
+ template< typename T , size_t dim , class Op >
+ static void for_each1( boost::array< T , dim > &s1 , Op op )
+ {
+ for( size_t i=0 ; i<dim ; ++i )
+ op( s1[i] );
+ }
+
+
+ template< typename T , size_t dim , class Op >
+ static void for_each2( boost::array< T , dim > &s1 ,
+ const boost::array< T , dim > &s2 , Op op )
+ {
+ for( size_t i=0 ; i<dim ; ++i )
+ op( s1[i] , s2[i] );
+ }
+
+ template< typename T , size_t dim , class Op >
+ static void for_each3( boost::array< T , dim > &s1 ,
+ const boost::array< T , dim > &s2 ,
+ const boost::array< T , dim > &s3 , Op op )
+ {
+ for( size_t i=0 ; i<dim ; ++i )
+ op( s1[i] , s2[i] , s3[i] );
+ }
+
+ template< typename T , size_t dim , class Op >
+ static void for_each4( boost::array< T , dim > &s1 ,
+ const boost::array< T , dim > &s2 ,
+ const boost::array< T , dim > &s3 ,
+ const boost::array< T , dim > &s4 , Op op )
+ {
+ for( size_t i=0 ; i<dim ; ++i )
+ op( s1[i] , s2[i] , s3[i] , s4[i] );
+ }
+
+ template< typename T , size_t dim , class Op >
+ static void for_each5( boost::array< T , dim > &s1 ,
+ const boost::array< T , dim > &s2 ,
+ const boost::array< T , dim > &s3 ,
+ const boost::array< T , dim > &s4 ,
+ const boost::array< T , dim > &s5 , Op op )
+ {
+ for( size_t i=0 ; i<dim ; ++i )
+ op( s1[i] , s2[i] , s3[i] , s4[i] , s5[i] );
+ }
+
+ template< typename T , size_t dim , class Op >
+ static void for_each6( boost::array< T , dim > &s1 ,
+ const boost::array< T , dim > &s2 ,
+ const boost::array< T , dim > &s3 ,
+ const boost::array< T , dim > &s4 ,
+ const boost::array< T , dim > &s5 ,
+ const boost::array< T , dim > &s6 , Op op )
+ {
+ for( size_t i=0 ; i<dim ; ++i )
+ op( s1[i] , s2[i] , s3[i] , s4[i] , s5[i] , s6[i] );
+ }
+};
+
+}
+}
+}
+
+#endif


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