Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r68266 - in sandbox/odeint/branches/karsten: . boost/numeric/odeint/algebra boost/numeric/odeint/stepper libs/numeric/odeint/ideas/units
From: karsten.ahnert_at_[hidden]
Date: 2011-01-19 03:30:16


Author: karsten
Date: 2011-01-19 03:30:13 EST (Wed, 19 Jan 2011)
New Revision: 68266
URL: http://svn.boost.org/trac/boost/changeset/68266

Log:
* added fusion algebra, chahged size_adjuster to work with units
Added:
   sandbox/odeint/branches/karsten/boost/numeric/odeint/algebra/fusion_algebra.hpp (contents, props changed)
Text files modified:
   sandbox/odeint/branches/karsten/TODO | 11 ++++++++---
   sandbox/odeint/branches/karsten/boost/numeric/odeint/stepper/adjust_size.hpp | 29 ++++++++++++++++++-----------
   sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/units/adjust_size_units.hpp | 2 ++
   3 files changed, 28 insertions(+), 14 deletions(-)

Modified: sandbox/odeint/branches/karsten/TODO
==============================================================================
--- sandbox/odeint/branches/karsten/TODO (original)
+++ sandbox/odeint/branches/karsten/TODO 2011-01-19 03:30:13 EST (Wed, 19 Jan 2011)
@@ -1,7 +1,12 @@
-* Controlled stepper
-* Dense output for euler
+* operations that fit units and result_of
+* include test/thrust in jam system, use system from
+* change stepper to stepper_units
+* change error_stepper to rrror_stepper_units
+* change stepper to stepper_units
+* include fusion_algebra in tests
+* split check_concepts into check_stepper_concept, check_error_stepper_concept, check_controlled_stepper_concept
+
 * Integrate functions
-* Implicit euler
 * skript for setting the include defines according to the position in file system an writing a general copyright comment at the beginning
 
 

Added: sandbox/odeint/branches/karsten/boost/numeric/odeint/algebra/fusion_algebra.hpp
==============================================================================
--- (empty file)
+++ sandbox/odeint/branches/karsten/boost/numeric/odeint/algebra/fusion_algebra.hpp 2011-01-19 03:30:13 EST (Wed, 19 Jan 2011)
@@ -0,0 +1,138 @@
+/*
+ boost header: BOOST_NUMERIC_ODEINT/vector_space_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_BOOST_NUMERIC_ODEINT_FUSION_ALGEBRA_HPP_INCLUDED
+#define BOOST_BOOST_NUMERIC_ODEINT_FUSION_ALGEBRA_HPP_INCLUDED
+
+#include <boost/fusion/container.hpp>
+#include <boost/fusion/sequence.hpp>
+#include <boost/fusion/algorithm.hpp>
+#include <boost/fusion/view.hpp>
+#include <boost/fusion/functional.hpp>
+
+
+namespace boost {
+namespace numeric {
+namespace odeint {
+
+
+/*
+ * TODO :
+ * 1. testing, include int unit test
+ * 2. change the standard operations, using boost::result_of. for example:
+ *
+ * struct increment
+ * {
+ * template< class T > struct result;
+ *
+ * template< class F , class T1 , class T2 >
+ * struct result< F( T1 , T2 ) >
+ * {
+ * typedef void type;
+ * };
+ *
+ * template< class T1 , class T2 >
+ * void operator()( T1 &t1 , T2 &t2 ) const
+ * {
+ * t1 += t2;
+ * }
+ * };
+ *
+ *
+ */
+struct fusion_algebra
+{
+
+ template< class StateType1 , class Operation >
+ static void for_each1( StateType1 &s1 , Operation op )
+ {
+ boost::fusion::for_each( s1 , op );
+ }
+
+
+ template< class StateType1 , class StateType2 , class Operation >
+ static void for_each2( StateType1 &s1 , StateType2 &s2 , Operation op )
+ {
+ typedef boost::fusion::vector< StateType1& , StateType2& > Sequences;
+ Sequences sequences( s1 , s2 );
+ boost::fusion::for_each( boost::fusion::zip_view< Sequences >( sequences ) , boost::fusion::make_fused( op ) );
+ }
+
+
+ template< class StateType1 , class StateType2 , class StateType3 , class Operation >
+ static void for_each3( StateType1 &s1 , StateType2 &s2 , StateType3 &s3 , Operation op )
+ {
+ typedef boost::fusion::vector< StateType1& , StateType2& , StateType3& > Sequences;
+ Sequences sequences( s1 , s2 , s3 );
+ boost::fusion::for_each( boost::fusion::zip_view< Sequences >( sequences ) , boost::fusion::make_fused( op ) );
+ }
+
+
+ template< class StateType1 , class StateType2 , class StateType3 , class StateType4 , class Operation >
+ static void for_each4( StateType1 &s1 , StateType2 &s2 , StateType3 &s3 , StateType4 &s4 , Operation op )
+ {
+ typedef boost::fusion::vector< StateType1& , StateType2& , StateType3& , StateType4& > Sequences;
+ Sequences sequences( s1 , s2 , s3 , s4 );
+ boost::fusion::for_each( boost::fusion::zip_view< Sequences >( sequences ) , boost::fusion::make_fused( op ) );
+ }
+
+
+ template< class StateType1 , class StateType2 , class StateType3 , class StateType4 , class StateType5 , class Operation >
+ static void for_each5( StateType1 &s1 , StateType2 &s2 , StateType3 &s3 , StateType4 &s4 , StateType5 &s5 , Operation op )
+ {
+ typedef boost::fusion::vector< StateType1& , StateType2& , StateType3& , StateType4& , StateType5& > Sequences;
+ Sequences sequences( s1 , s2 , s3 , s4 , s5 );
+ boost::fusion::for_each( boost::fusion::zip_view< Sequences >( sequences ) , boost::fusion::make_fused( op ) );
+ }
+
+
+ template< class StateType1 , class StateType2 , class StateType3 , class StateType4 , class StateType5 , class StateType6 , class Operation >
+ static void for_each6( StateType1 &s1 , StateType2 &s2 , StateType3 &s3 , StateType4 &s4 , StateType5 &s5 , StateType6 &s6 , Operation op )
+ {
+ typedef boost::fusion::vector< StateType1& , StateType2& , StateType3& , StateType4& , StateType5& , StateType6& > Sequences;
+ Sequences sequences( s1 , s2 , s3 , s4 , s5 , s6 );
+ boost::fusion::for_each( boost::fusion::zip_view< Sequences >( sequences ) , boost::fusion::make_fused( op ) );
+ }
+
+
+ template< class StateType1 , class StateType2 , class StateType3 , class StateType4 , class StateType5 , class StateType6 , class StateType7 , class Operation >
+ static void for_each7( StateType1 &s1 , StateType2 &s2 , StateType3 &s3 , StateType4 &s4 , StateType5 &s5 , StateType6 &s6 , StateType7 &s7 , Operation op )
+ {
+ typedef boost::fusion::vector< StateType1& , StateType2& , StateType3& , StateType4& , StateType5& , StateType6& , StateType7& > Sequences;
+ Sequences sequences( s1 , s2 , s3 , s4 , s5 , s6 , s7 );
+ boost::fusion::for_each( boost::fusion::zip_view< Sequences >( sequences ) , boost::fusion::make_fused( op ) );
+ }
+
+
+ template< class StateType1 , class StateType2 , class StateType3 , class StateType4 , class StateType5 , class StateType6 , class StateType7 , class StateType8 , class Operation >
+ static void for_each8( StateType1 &s1 , StateType2 &s2 , StateType3 &s3 , StateType4 &s4 , StateType5 &s5 , StateType6 &s6 , StateType7 &s7 , StateType8 &s8 , Operation op )
+ {
+ typedef boost::fusion::vector< StateType1& , StateType2& , StateType3& , StateType4& , StateType5& , StateType6& , StateType7& , StateType8& > Sequences;
+ Sequences sequences( s1 , s2 , s3 , s4 , s5 , s6 , s7 , s8 );
+ boost::fusion::for_each( boost::fusion::zip_view< Sequences >( sequences ) , boost::fusion::make_fused( op ) );
+ }
+
+
+ template< class ValueType , class StateType , class Reduction >
+ static ValueType reduce( StateType &s , Reduction red , ValueType init)
+ {
+ return boost::fusion::accumulate( s , init , red );
+ }
+};
+
+
+
+} // odeint
+} // numeric
+} // boost
+
+
+#endif //BOOST_BOOST_NUMERIC_ODEINT_VECTOR_SPACE_ALGEBRA_HPP_INCLUDED

Modified: sandbox/odeint/branches/karsten/boost/numeric/odeint/stepper/adjust_size.hpp
==============================================================================
--- sandbox/odeint/branches/karsten/boost/numeric/odeint/stepper/adjust_size.hpp (original)
+++ sandbox/odeint/branches/karsten/boost/numeric/odeint/stepper/adjust_size.hpp 2011-01-19 03:30:13 EST (Wed, 19 Jan 2011)
@@ -42,42 +42,49 @@
 /*
  * Adjust size functionality with policies and resizeability
  */
-template< class State , size_t Dim >
+template< class Deriv , size_t Dim >
 class size_adjuster : boost::noncopyable
 {
 public:
 
         size_adjuster() : m_is_initialized( false ) , m_states()
         {
- std::fill( m_states.begin() , m_states.end() , static_cast< State* >( 0 ) );
+ std::fill( m_states.begin() , m_states.end() , static_cast< Deriv* >( 0 ) );
         }
 
+ template< class State >
         bool adjust_size( const State &x )
         {
- return adjust_size_by_resizeability( x , typename is_resizeable< State >::type() );
+ return adjust_size_by_resizeability( x , typename is_resizeable< Deriv >::type() );
         }
 
+ template< class State >
         bool adjust_size_by_policy( const State &x , adjust_size_manually_tag )
         {
             return false;
         }
 
+ template< class State >
         bool adjust_size_by_policy( const State &x , adjust_size_initially_tag )
         {
                 if( !m_is_initialized )
                 {
                         m_is_initialized = true;
- return adjust_size_by_resizeability( x , typename is_resizeable< State >::type() );
- } else
+ return adjust_size_by_resizeability( x , typename is_resizeable< Deriv >::type() );
+ }
+ else
+ {
                     return false;
+ }
         }
 
+ template< class State >
         bool adjust_size_by_policy( const State &x , adjust_size_always_tag )
         {
- return adjust_size_by_resizeability( x , typename is_resizeable< State >::type() );
+ return adjust_size_by_resizeability( x , typename is_resizeable< Deriv >::type() );
         }
 
- void register_state( size_t idx , State &x )
+ void register_state( size_t idx , Deriv &x )
         {
                 m_states[idx] = &x;
         }
@@ -85,17 +92,17 @@
 
 private:
 
+ template< class State >
         bool adjust_size_by_resizeability( const State &x , boost::true_type )
         {
- bool changed = false;
                 for( size_t i=0 ; i<Dim ; ++i )
                 {
             boost::numeric::odeint::adjust_size( x , *(m_states[i]) );
- changed = true;
                 }
- return changed;
+ return ( Dim > 0 );
         }
 
+ template< class State >
         bool adjust_size_by_resizeability( const State &x , boost::false_type )
         {
             return false;
@@ -105,7 +112,7 @@
 private :
 
         bool m_is_initialized;
- boost::array< State* , Dim > m_states;
+ boost::array< Deriv* , Dim > m_states;
 };
 
 

Modified: sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/units/adjust_size_units.hpp
==============================================================================
--- sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/units/adjust_size_units.hpp (original)
+++ sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/units/adjust_size_units.hpp 2011-01-19 03:30:13 EST (Wed, 19 Jan 2011)
@@ -37,6 +37,8 @@
 
 
 
+
+
 /*
  * Adjust size functionality with policies and resizeability
  */


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