Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r64037 - in sandbox/odeint/branches/karsten: boost/numeric boost/numeric/odeint/algebra boost/numeric/odeint/algebra/detail boost/numeric/odeint/stepper libs/numeric/odeint/test
From: karsten.ahnert_at_[hidden]
Date: 2010-07-15 03:24:24


Author: karsten
Date: 2010-07-15 03:24:17 EDT (Thu, 15 Jul 2010)
New Revision: 64037
URL: http://svn.boost.org/trac/boost/changeset/64037

Log:
* add resize functionality test
* small changes in the stepper base
* organizing the standard algebra
Added:
   sandbox/odeint/branches/karsten/boost/numeric/odeint/algebra/detail/
   sandbox/odeint/branches/karsten/boost/numeric/odeint/algebra/detail/for_each.hpp (contents, props changed)
   sandbox/odeint/branches/karsten/boost/numeric/odeint/algebra/detail/macros.hpp (contents, props changed)
   sandbox/odeint/branches/karsten/libs/numeric/odeint/test/check_resize.cpp (contents, props changed)
Text files modified:
   sandbox/odeint/branches/karsten/boost/numeric/odeint.hpp | 3
   sandbox/odeint/branches/karsten/boost/numeric/odeint/algebra/gsl_vector_adaptor.hpp | 97 +++++++++--------
   sandbox/odeint/branches/karsten/boost/numeric/odeint/algebra/standard_algebra.hpp | 210 ++++++++++++++-------------------------
   sandbox/odeint/branches/karsten/boost/numeric/odeint/stepper/explicit_euler.hpp | 51 ++++-----
   sandbox/odeint/branches/karsten/boost/numeric/odeint/stepper/explicit_stepper_base.hpp | 121 +++++++++++++++++-----
   sandbox/odeint/branches/karsten/boost/numeric/odeint/stepper/runge_kutta_error_ck.hpp | 2
   sandbox/odeint/branches/karsten/libs/numeric/odeint/test/Jamfile | 3
   sandbox/odeint/branches/karsten/libs/numeric/odeint/test/check_stepper_concepts.cpp | 48 ++++----
   8 files changed, 272 insertions(+), 263 deletions(-)

Modified: sandbox/odeint/branches/karsten/boost/numeric/odeint.hpp
==============================================================================
--- sandbox/odeint/branches/karsten/boost/numeric/odeint.hpp (original)
+++ sandbox/odeint/branches/karsten/boost/numeric/odeint.hpp 2010-07-15 03:24:17 EDT (Thu, 15 Jul 2010)
@@ -18,6 +18,7 @@
 #include <boost/config.hpp>
 
 #include <boost/numeric/odeint/stepper/explicit_euler.hpp>
-#include <boost/numeric/odeint/stepper/runge_kutta_error_ck.hpp>
+
+// #include <boost/numeric/odeint/stepper/runge_kutta_error_ck.hpp>
 
 #endif // BOOST_NUMERIC_ODEINT_HPP

Added: sandbox/odeint/branches/karsten/boost/numeric/odeint/algebra/detail/for_each.hpp
==============================================================================
--- (empty file)
+++ sandbox/odeint/branches/karsten/boost/numeric/odeint/algebra/detail/for_each.hpp 2010-07-15 03:24:17 EDT (Thu, 15 Jul 2010)
@@ -0,0 +1,80 @@
+/*
+ boost header: BOOST_NUMERIC_ODEINT_ALGEBRA_DETAIL_FOR_EACH/for_each.hpp
+
+ Copyright 2009 Karsten Ahnert
+ Copyright 2009 Mario Mulansky
+ Copyright 2009 Andre Bergner
+
+ 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_ALGEBRA_DETAIL_FOR_EACH_HPP_INCLUDED
+#define BOOST_NUMERIC_ODEINT_ALGEBRA_DETAIL_FOR_EACH_HPP_INCLUDED
+
+namespace boost {
+namespace numeric {
+namespace odeint {
+namespace detail {
+
+
+
+template< class Iterator1 , class Iterator2 , class Operation >
+inline void for_each2( Iterator1 first1 , Iterator1 last1 , Iterator2 first2 , Operation op )
+{
+ for( ; first1 != last1 ; )
+ op( *first1++ , *first2++ );
+}
+
+
+template< class Iterator1 , class Iterator2 , class Iterator3 , class Operation >
+inline void for_each3( Iterator1 first1 , Iterator1 last1 , Iterator2 first2 , Iterator3 first3, Operation op )
+{
+ for( ; first1 != last1 ; )
+ op( *first1++ , *first2++ , *first3++ );
+}
+
+
+template< class Iterator1 , class Iterator2 , class Iterator3 , class Iterator4 , class Operation >
+inline void for_each4( Iterator1 first1 , Iterator1 last1 , Iterator2 first2 , Iterator3 first3, Iterator4 first4, Operation op )
+{
+ for( ; first1 != last1 ; )
+ op( *first1++ , *first2++ , *first3++ , *first4++ );
+}
+
+
+template< class Iterator1 , class Iterator2 , class Iterator3 , class Iterator4 , class Iterator5 , class Operation >
+inline void for_each5( Iterator1 first1 , Iterator1 last1 , Iterator2 first2 , Iterator3 first3,
+ Iterator4 first4, Iterator5 first5, Operation op )
+{
+ for( ; first1 != last1 ; )
+ op( *first1++ , *first2++ , *first3++ , *first4++ , *first5++ );
+}
+
+
+template< class Iterator1 , class Iterator2 , class Iterator3 , class Iterator4 , class Iterator5 , class Iterator6 , class Operation >
+inline void for_each6( Iterator1 first1 , Iterator1 last1 , Iterator2 first2 , Iterator3 first3,
+ Iterator4 first4, Iterator5 first5, Iterator6 first6 , Operation op )
+{
+ for( ; first1 != last1 ; )
+ op( *first1++ , *first2++ , *first3++ , *first4++ , *first5++ , *first6++ );
+}
+
+
+template< class Iterator1 , class Iterator2 , class Iterator3 , class Iterator4 , class Iterator5 , class Iterator6 , class Iterator7 , class Operation >
+inline void for_each7( Iterator1 first1 , Iterator1 last1 , Iterator2 first2 , Iterator3 first3,
+ Iterator4 first4, Iterator5 first5, Iterator6 first6 , Iterator7 first7 , Operation op )
+{
+ for( ; first1 != last1 ; )
+ op( *first1++ , *first2++ , *first3++ , *first4++ , *first5++ , *first6++ , *first7++ );
+}
+
+
+} // detail
+} // odeint
+} // numeric
+} // boost
+
+
+#endif // BOOST_NUMERIC_ODEINT_ALGEBRA_DETAIL_FOR_EACH_HPP_INCLUDED

Added: sandbox/odeint/branches/karsten/boost/numeric/odeint/algebra/detail/macros.hpp
==============================================================================
--- (empty file)
+++ sandbox/odeint/branches/karsten/boost/numeric/odeint/algebra/detail/macros.hpp 2010-07-15 03:24:17 EDT (Thu, 15 Jul 2010)
@@ -0,0 +1,28 @@
+/*
+ boost header: BOOST_NUMERIC_ODEINT/macros.hpp
+
+ Copyright 2009 Karsten Ahnert
+ Copyright 2009 Mario Mulansky
+ Copyright 2009 Andre Bergner
+
+ 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_ALGEBRA_DETAIL_MACROS_HPP_INCLUDED
+#define BOOST_BOOST_NUMERIC_ODEINT_ALGEBRA_DETAIL_MACROS_HPP_INCLUDED
+
+#include <boost/type_traits.hpp>
+#include <boost/static_assert.hpp>
+
+#define BOOST_ODEINT_CHECK_CONTAINER_TYPE( Type1 , Type2 ) \
+ BOOST_STATIC_ASSERT(( boost::is_same< typename boost::remove_const< Type1 >::type , Type2 >::value ))
+
+
+/*
+#define BOOST_ODEINT_CHECK_OPERATION_ARITY( Operation , Arity ) \
+ BOOST_STATIC_ASSERT(( boost::function_traits< Operation >::arity == Arity ))
+*/
+
+#endif //BOOST_BOOST_NUMERIC_ODEINT_ALGEBRA_DETAIL_MACROS_HPP_INCLUDED

Modified: sandbox/odeint/branches/karsten/boost/numeric/odeint/algebra/gsl_vector_adaptor.hpp
==============================================================================
--- sandbox/odeint/branches/karsten/boost/numeric/odeint/algebra/gsl_vector_adaptor.hpp (original)
+++ sandbox/odeint/branches/karsten/boost/numeric/odeint/algebra/gsl_vector_adaptor.hpp 2010-07-15 03:24:17 EDT (Thu, 15 Jul 2010)
@@ -34,7 +34,7 @@
 
         gsl_vector_iterator( void ): m_p(0) , m_stride( 0 ) { }
         explicit gsl_vector_iterator( gsl_vector &p ) : m_p( p.data ) , m_stride( p.stride ) { }
- gsl_vector_iterator( gsl_vector_iterator &p ) : m_p( p.m_p ) , m_stride( p.m_stride ) { }
+ friend gsl_vector_iterator end_iterator( gsl_vector & );
 
 private :
 
@@ -52,8 +52,10 @@
         size_t m_stride;
 };
 
+
+
 /*
- * defines an iterator for gsl_vector
+ * defines an const iterator for gsl_vector
  */
 class const_gsl_vector_iterator : public boost::iterator_facade< const_gsl_vector_iterator , double , boost::random_access_traversal_tag >
 {
@@ -61,13 +63,13 @@
 
         const_gsl_vector_iterator( void ): m_p(0) , m_stride( 0 ) { }
         explicit const_gsl_vector_iterator( const gsl_vector &p ) : m_p( p.data ) , m_stride( p.stride ) { }
- const_gsl_vector_iterator( const const_gsl_vector_iterator &p ) : m_p( p.m_p ) , m_stride( p.m_stride ) { }
         const_gsl_vector_iterator( const gsl_vector_iterator &p ) : m_p( p.m_p ) , m_stride( p.m_stride ) { }
 
 private :
 
         friend class boost::iterator_core_access;
         friend class gsl_vector_iterator;
+ friend const_gsl_vector_iterator end_iterator( const gsl_vector & );
 
         void increment( void ) { m_p += m_stride; }
         void decrement( void ) { m_p -= m_stride; }
@@ -80,77 +82,80 @@
         size_t m_stride;
 };
 
+
 bool gsl_vector_iterator::equal( const const_gsl_vector_iterator &other ) const { return this->m_p == other.m_p; }
 
 
+gsl_vector_iterator end_iterator( gsl_vector &x )
+{
+ gsl_vector_iterator iter( x );
+ iter.m_p += iter.m_stride * x.size;
+ return iter;
+}
+
+const_gsl_vector_iterator end_iterator( const gsl_vector &x )
+{
+ const_gsl_vector_iterator iter( x );
+ iter.m_p += iter.m_stride * x.size;
+ return iter;
+}
+
+
 } // namespace odeint
 } // namespace numeric
 } // namespace boost
 
 
-namespace boost {
+namespace boost
+{
+ template<>
+ struct range_mutable_iterator< gsl_vector >
+ {
+ typedef boost::numeric::odeint::gsl_vector_iterator type;
+ };
+
+ template<>
+ struct range_const_iterator< gsl_vector >
+ {
+ typedef boost::numeric::odeint::const_gsl_vector_iterator type;
+ };
+} // namespace boost
 
 
 
-/*
- * specialization of range_iterator for gsl_vector_iterator
- */
-template<>
-struct range_iterator< gsl_vector >
-{
- typedef boost::numeric::odeint::gsl_vector_iterator type;
-};
-
-/*
- * specialization of range_iterator for const_gsl_vector_iterator
- */
-template<>
-struct range_iterator< const gsl_vector >
-{
- typedef boost::numeric::odeint::const_gsl_vector_iterator type;
-};
+namespace boost {
+namespace numeric {
+namespace odeint {
 
 
-/*
- * specialization of begin for gsl_vector
- */
-template<>
-range_iterator< gsl_vector >::type begin( gsl_vector &r )
+inline gsl_vector_iterator range_begin( gsl_vector &x )
 {
- return boost::numeric::odeint::gsl_vector_iterator( r );
+ return gsl_vector_iterator( x );
 }
 
-/*
- * specialization of begin for const gsl_vector
- */
-template<>
-range_iterator< const gsl_vector >::type begin( const gsl_vector &r )
+inline const_gsl_vector_iterator range_begin( const gsl_vector &x )
 {
- return boost::numeric::odeint::const_gsl_vector_iterator( r );
+ return const_gsl_vector_iterator( x );
 }
 
-
-/*
- * specialization of end for gsl_vector
- */
-template<>
-range_iterator< gsl_vector >::type end( gsl_vector &r )
+inline gsl_vector_iterator range_end( gsl_vector &x )
 {
- return boost::numeric::odeint::gsl_vector_iterator( r ) + r.size * r.stride ;
+ return end_iterator( x );
 }
 
-/*
- * specialization of end for const gsl_vector
- */
-template<>
-range_iterator< const gsl_vector >::type end( const gsl_vector &r )
+inline const_gsl_vector_iterator range_end( const gsl_vector &x )
 {
- return boost::numeric::odeint::const_gsl_vector_iterator( r ) + r.size * r.stride ;
+ return end_iterator( x );
 }
 
 
+} // namespace odeint
+} // namespace numeric
 } // namespace boost
 
 
 
+
+
+
 #endif // BOOST_NUMERIC_ODEINT_GSL_VECTOR_ADAPTOR_HPP_INCLUDED

Modified: sandbox/odeint/branches/karsten/boost/numeric/odeint/algebra/standard_algebra.hpp
==============================================================================
--- sandbox/odeint/branches/karsten/boost/numeric/odeint/algebra/standard_algebra.hpp (original)
+++ sandbox/odeint/branches/karsten/boost/numeric/odeint/algebra/standard_algebra.hpp 2010-07-15 03:24:17 EDT (Thu, 15 Jul 2010)
@@ -15,6 +15,9 @@
 
 #include <boost/range.hpp>
 
+#include <boost/numeric/odeint/algebra/detail/macros.hpp>
+#include <boost/numeric/odeint/algebra/detail/for_each.hpp>
+
 namespace boost {
 namespace numeric {
 namespace odeint {
@@ -28,180 +31,117 @@
         static void for_each2( StateType1 &s1 , StateType2 &s2 , Operation op )
         {
                 // ToDo : check that number of arguments of the operation is equal 2
+ BOOST_ODEINT_CHECK_CONTAINER_TYPE( StateType1 , container_type );
+ BOOST_ODEINT_CHECK_CONTAINER_TYPE( StateType2 , container_type );
 
- // ToDo : generate macro
- BOOST_STATIC_ASSERT(( boost::is_same< typename boost::remove_const< StateType1 >::type , container_type >::value ));
- BOOST_STATIC_ASSERT(( boost::is_same< typename boost::remove_const< StateType2 >::type , container_type >::value ));
-
- // ToDo : pack into detail namespace
- for_each2( boost::begin( s1 ) , boost::end( s1 ) ,
- boost::begin( s2 ) , op );
+ detail::for_each2( boost::begin( s1 ) , boost::end( s1 ) ,
+ boost::begin( s2 ) , op );
         }
 
- // ToDo : pack into namespace detail
- template< class Iterator1 , class Iterator2 , class Operation >
- static void for_each2( Iterator1 first1 , Iterator1 last1 , Iterator2 first2 , Operation op )
- {
- for( ; first1 != last1 ; )
- op( *first1++ , *first2++ );
- }
 
 
         template< class StateType1 , class StateType2 , class StateType3 , class Operation >
         static void for_each3( StateType1 &s1 , StateType2 &s2 , StateType3 &s3 , Operation op )
         {
                 // ToDo : check that number of arguments of the operation is equal 3
-
- // ToDo : generate macro
- BOOST_STATIC_ASSERT(( boost::is_same< typename boost::remove_const< StateType1 >::type , container_type >::value ));
- BOOST_STATIC_ASSERT(( boost::is_same< typename boost::remove_const< StateType2 >::type , container_type >::value ));
- BOOST_STATIC_ASSERT(( boost::is_same< typename boost::remove_const< StateType3 >::type , container_type >::value ));
-
- // ToDo : pack into detail namespace
- for_each3( boost::begin( s1 ) , boost::end( s1 ) ,
- boost::begin( s2 ) ,
- boost::begin( s3 ) ,
- op );
- }
-
- // ToDo : pack into namespace detail
- template< class Iterator1 , class Iterator2 , class Iterator3 , class Operation >
- static void for_each3( Iterator1 first1 , Iterator1 last1 , Iterator2 first2 , Iterator3 first3, Operation op )
- {
- for( ; first1 != last1 ; )
- op( *first1++ , *first2++ , *first3++ );
+ BOOST_ODEINT_CHECK_CONTAINER_TYPE( StateType1 , container_type );
+ BOOST_ODEINT_CHECK_CONTAINER_TYPE( StateType2 , container_type );
+ BOOST_ODEINT_CHECK_CONTAINER_TYPE( StateType3 , container_type );
+
+ detail::for_each3( boost::begin( s1 ) , boost::end( s1 ) ,
+ boost::begin( s2 ) ,
+ boost::begin( s3 ) ,
+ 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 )
         {
- // ToDo : check that number of arguments of the operation is equal 3
-
- // ToDo : generate macro
- BOOST_STATIC_ASSERT(( boost::is_same< typename boost::remove_const< StateType1 >::type , container_type >::value ));
- BOOST_STATIC_ASSERT(( boost::is_same< typename boost::remove_const< StateType2 >::type , container_type >::value ));
- BOOST_STATIC_ASSERT(( boost::is_same< typename boost::remove_const< StateType3 >::type , container_type >::value ));
- BOOST_STATIC_ASSERT(( boost::is_same< typename boost::remove_const< StateType4 >::type , container_type >::value ));
-
- // ToDo : pack into detail namespace
- for_each4( boost::begin( s1 ) , boost::end( s1 ) ,
- boost::begin( s2 ) ,
- boost::begin( s3 ) ,
- boost::begin( s4 ) ,
- op );
- }
-
- // ToDo : pack into namespace detail
- template< class Iterator1 , class Iterator2 , class Iterator3 , class Iterator4 , class Operation >
- static void for_each4( Iterator1 first1 , Iterator1 last1 , Iterator2 first2 , Iterator3 first3, Iterator4 first4, Operation op )
- {
- for( ; first1 != last1 ; )
- op( *first1++ , *first2++ , *first3++ , *first4++ );
+ // ToDo : check that number of arguments of the operation is equal 4
+ BOOST_ODEINT_CHECK_CONTAINER_TYPE( StateType1 , container_type );
+ BOOST_ODEINT_CHECK_CONTAINER_TYPE( StateType2 , container_type );
+ BOOST_ODEINT_CHECK_CONTAINER_TYPE( StateType3 , container_type );
+ BOOST_ODEINT_CHECK_CONTAINER_TYPE( StateType4 , container_type );
+
+ detail::for_each4( boost::begin( s1 ) , boost::end( s1 ) ,
+ boost::begin( s2 ) ,
+ boost::begin( s3 ) ,
+ boost::begin( s4 ) ,
+ 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 )
         {
- // ToDo : check that number of arguments of the operation is equal 3
-
- // ToDo : generate macro
- BOOST_STATIC_ASSERT(( boost::is_same< typename boost::remove_const< StateType1 >::type , container_type >::value ));
- BOOST_STATIC_ASSERT(( boost::is_same< typename boost::remove_const< StateType2 >::type , container_type >::value ));
- BOOST_STATIC_ASSERT(( boost::is_same< typename boost::remove_const< StateType3 >::type , container_type >::value ));
- BOOST_STATIC_ASSERT(( boost::is_same< typename boost::remove_const< StateType4 >::type , container_type >::value ));
- BOOST_STATIC_ASSERT(( boost::is_same< typename boost::remove_const< StateType5 >::type , container_type >::value ));
-
- // ToDo : pack into detail namespace
- for_each5( boost::begin( s1 ) , boost::end( s1 ) ,
- boost::begin( s2 ) ,
- boost::begin( s3 ) ,
- boost::begin( s4 ) ,
- boost::begin( s5 ) ,
- op );
- }
-
- // ToDo : pack into namespace detail
- template< class Iterator1 , class Iterator2 , class Iterator3 , class Iterator4 , class Iterator5 , class Operation >
- static void for_each5( Iterator1 first1 , Iterator1 last1 , Iterator2 first2 , Iterator3 first3,
- Iterator4 first4, Iterator5 first5, Operation op )
- {
- for( ; first1 != last1 ; )
- op( *first1++ , *first2++ , *first3++ , *first4++ , *first5++ );
+ // ToDo : check that number of arguments of the operation is equal 5
+ BOOST_ODEINT_CHECK_CONTAINER_TYPE( StateType1 , container_type );
+ BOOST_ODEINT_CHECK_CONTAINER_TYPE( StateType2 , container_type );
+ BOOST_ODEINT_CHECK_CONTAINER_TYPE( StateType3 , container_type );
+ BOOST_ODEINT_CHECK_CONTAINER_TYPE( StateType4 , container_type );
+ BOOST_ODEINT_CHECK_CONTAINER_TYPE( StateType5 , container_type );
+
+ detail::for_each5( boost::begin( s1 ) , boost::end( s1 ) ,
+ boost::begin( s2 ) ,
+ boost::begin( s3 ) ,
+ boost::begin( s4 ) ,
+ boost::begin( s5 ) ,
+ 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 )
         {
                 // ToDo : check that number of arguments of the operation is equal 6
-
- // ToDo : generate macro
- BOOST_STATIC_ASSERT(( boost::is_same< typename boost::remove_const< StateType1 >::type , container_type >::value ));
- BOOST_STATIC_ASSERT(( boost::is_same< typename boost::remove_const< StateType2 >::type , container_type >::value ));
- BOOST_STATIC_ASSERT(( boost::is_same< typename boost::remove_const< StateType3 >::type , container_type >::value ));
- BOOST_STATIC_ASSERT(( boost::is_same< typename boost::remove_const< StateType4 >::type , container_type >::value ));
- BOOST_STATIC_ASSERT(( boost::is_same< typename boost::remove_const< StateType5 >::type , container_type >::value ));
- BOOST_STATIC_ASSERT(( boost::is_same< typename boost::remove_const< StateType6 >::type , container_type >::value ));
-
- // ToDo : pack into detail namespace
- for_each6( boost::begin( s1 ) , boost::end( s1 ) ,
- boost::begin( s2 ) ,
- boost::begin( s3 ) ,
- boost::begin( s4 ) ,
- boost::begin( s5 ) ,
- boost::begin( s6 ) ,
- op );
- }
-
- // ToDo : pack into namespace detail
- template< class Iterator1 , class Iterator2 , class Iterator3 , class Iterator4 , class Iterator5 , class Iterator6 , class Operation >
- static void for_each6( Iterator1 first1 , Iterator1 last1 , Iterator2 first2 , Iterator3 first3,
- Iterator4 first4, Iterator5 first5, Iterator6 first6 , Operation op )
- {
- for( ; first1 != last1 ; )
- op( *first1++ , *first2++ , *first3++ , *first4++ , *first5++ , *first6++ );
+ BOOST_ODEINT_CHECK_CONTAINER_TYPE( StateType1 , container_type );
+ BOOST_ODEINT_CHECK_CONTAINER_TYPE( StateType2 , container_type );
+ BOOST_ODEINT_CHECK_CONTAINER_TYPE( StateType3 , container_type );
+ BOOST_ODEINT_CHECK_CONTAINER_TYPE( StateType4 , container_type );
+ BOOST_ODEINT_CHECK_CONTAINER_TYPE( StateType5 , container_type );
+ BOOST_ODEINT_CHECK_CONTAINER_TYPE( StateType6 , container_type );
+
+ detail::for_each6( boost::begin( s1 ) , boost::end( s1 ) ,
+ boost::begin( s2 ) ,
+ boost::begin( s3 ) ,
+ boost::begin( s4 ) ,
+ boost::begin( s5 ) ,
+ boost::begin( s6 ) ,
+ 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 )
         {
- // ToDo : check that number of arguments of the operation is equal 6
-
- // ToDo : generate macro
- BOOST_STATIC_ASSERT(( boost::is_same< typename boost::remove_const< StateType1 >::type , container_type >::value ));
- BOOST_STATIC_ASSERT(( boost::is_same< typename boost::remove_const< StateType2 >::type , container_type >::value ));
- BOOST_STATIC_ASSERT(( boost::is_same< typename boost::remove_const< StateType3 >::type , container_type >::value ));
- BOOST_STATIC_ASSERT(( boost::is_same< typename boost::remove_const< StateType4 >::type , container_type >::value ));
- BOOST_STATIC_ASSERT(( boost::is_same< typename boost::remove_const< StateType5 >::type , container_type >::value ));
- BOOST_STATIC_ASSERT(( boost::is_same< typename boost::remove_const< StateType6 >::type , container_type >::value ));
- BOOST_STATIC_ASSERT(( boost::is_same< typename boost::remove_const< StateType7 >::type , container_type >::value ));
-
- // ToDo : pack into detail namespace
- for_each7( boost::begin( s1 ) , boost::end( s1 ) ,
- boost::begin( s2 ) ,
- boost::begin( s3 ) ,
- boost::begin( s4 ) ,
- boost::begin( s5 ) ,
- boost::begin( s6 ) ,
- boost::begin( s7 ) ,
- op );
- }
-
- // ToDo : pack into namespace detail
- template< class Iterator1 , class Iterator2 , class Iterator3 , class Iterator4 , class Iterator5 , class Iterator6 , class Iterator7 , class Operation >
- static void for_each7( Iterator1 first1 , Iterator1 last1 , Iterator2 first2 , Iterator3 first3,
- Iterator4 first4, Iterator5 first5, Iterator6 first6 , Iterator7 first7 , Operation op )
- {
- for( ; first1 != last1 ; )
- op( *first1++ , *first2++ , *first3++ , *first4++ , *first5++ , *first6++ , *first7++ );
+ // ToDo : check that number of arguments of the operation is equal 7
+ BOOST_ODEINT_CHECK_CONTAINER_TYPE( StateType1 , container_type );
+ BOOST_ODEINT_CHECK_CONTAINER_TYPE( StateType2 , container_type );
+ BOOST_ODEINT_CHECK_CONTAINER_TYPE( StateType3 , container_type );
+ BOOST_ODEINT_CHECK_CONTAINER_TYPE( StateType4 , container_type );
+ BOOST_ODEINT_CHECK_CONTAINER_TYPE( StateType5 , container_type );
+ BOOST_ODEINT_CHECK_CONTAINER_TYPE( StateType6 , container_type );
+ BOOST_ODEINT_CHECK_CONTAINER_TYPE( StateType7 , container_type );
+
+ detail::for_each7( boost::begin( s1 ) , boost::end( s1 ) ,
+ boost::begin( s2 ) ,
+ boost::begin( s3 ) ,
+ boost::begin( s4 ) ,
+ boost::begin( s5 ) ,
+ boost::begin( s6 ) ,
+ boost::begin( s7 ) ,
+ op );
         }
 
+
 };
 
 } // odeint

Modified: sandbox/odeint/branches/karsten/boost/numeric/odeint/stepper/explicit_euler.hpp
==============================================================================
--- sandbox/odeint/branches/karsten/boost/numeric/odeint/stepper/explicit_euler.hpp (original)
+++ sandbox/odeint/branches/karsten/boost/numeric/odeint/stepper/explicit_euler.hpp 2010-07-15 03:24:17 EDT (Thu, 15 Jul 2010)
@@ -15,7 +15,6 @@
 
 #include <boost/numeric/odeint/algebra/standard_algebra.hpp>
 #include <boost/numeric/odeint/algebra/standard_operations.hpp>
-#include <boost/numeric/odeint/algebra/standard_resize.hpp>
 
 #include <boost/numeric/odeint/stepper/explicit_stepper_base.hpp>
 #include <boost/numeric/odeint/stepper/detail/macros.hpp>
@@ -42,43 +41,37 @@
 
         BOOST_ODEINT_EXPLICIT_STEPPERS_TYPEDEFS( explicit_euler , 1 );
 
- friend class explicit_stepper_base< explicit_euler< State , Time , Algebra , Operations , AdjustSizePolicy > ,
- 1 , State , Time , Algebra , Operations , AdjustSizePolicy >;
-
-
- explicit_euler( void )
- : m_dxdt()
- {
- }
-
- template< class System >
- void do_step( System system , state_type &x , time_type t , time_type dt )
- {
- this->adjust_size_by_policy( x , adjust_size_policy() );
- system( x , m_dxdt ,t );
- do_step( system , x , m_dxdt , t , dt );
- }
-
-
         template< class System >
- void do_step( System system , state_type &x , const state_type &dxdt , time_type t , time_type dt )
+ void do_step_impl( System system , state_type &x , const state_type &dxdt , time_type t , time_type dt )
         {
                 algebra_type::for_each2( x , dxdt , typename operations_type::increment( dt ) );
         }
 
 
+// explicit_euler( void ) : m_size_adjuster( *this ) { }
+//
+// void adjust_size( const state_type &x )
+// {
+// m_size_adjuster.adjust_size( x );
+// stepper_base_type::adjust_size( x );
+// }
+//
+//
+//private:
+//
+// typedef explicit_euler< State , Time , Algebra , Operations , AdjustSizePolicy > stepper_type;
+// typedef size_adjuster< state_type , stepper_type > size_adjuster_type;
+// friend class size_adjuster< state_type , stepper_type >;
+//
+// void adjust_size_impl( const state_type &x )
+// {
+// }
+//
+// size_adjuster_type m_size_adjuster;
+};
 
 
-private:
-
- void adjust_size_impl( const state_type &x )
- {
- adjust_size( x , m_dxdt );
- }
-
 
- state_type m_dxdt;
-};
 
 } // odeint
 } // numeric

Modified: sandbox/odeint/branches/karsten/boost/numeric/odeint/stepper/explicit_stepper_base.hpp
==============================================================================
--- sandbox/odeint/branches/karsten/boost/numeric/odeint/stepper/explicit_stepper_base.hpp (original)
+++ sandbox/odeint/branches/karsten/boost/numeric/odeint/stepper/explicit_stepper_base.hpp 2010-07-15 03:24:17 EDT (Thu, 15 Jul 2010)
@@ -13,17 +13,88 @@
 #ifndef BOOST_BOOST_NUMERIC_ODEINT_EXPLICIT_STEPPER_BASE_HPP_INCLUDED
 #define BOOST_BOOST_NUMERIC_ODEINT_EXPLICIT_STEPPER_BASE_HPP_INCLUDED
 
+
+#include <boost/numeric/odeint/algebra/standard_resize.hpp>
+
+
+
 namespace boost {
 namespace numeric {
 namespace odeint {
 
 
 
+/*
+ * Tags to specify resize behavior of steppers
+ */
 struct adjust_size_manually_tag {};
 struct adjust_size_initially_tag {};
 struct adjust_size_always_tag {};
 
 
+
+
+/*
+ * Adjust size functionality with policies and resizeability
+ */
+template< class State , class Stepper >
+class size_adjuster
+{
+public:
+
+ size_adjuster( Stepper &stepper ) : m_is_initialized( false ) , m_stepper( stepper ) { }
+
+ void adjust_size( const State &x )
+ {
+ adjust_size_by_resizeability( x , typename is_resizeable< State >::type() );
+ }
+
+ void adjust_size_by_policy( const State &x , adjust_size_manually_tag )
+ {
+ }
+
+ void adjust_size_by_policy( const State &x , adjust_size_initially_tag )
+ {
+ if( !m_is_initialized )
+ {
+ adjust_size_by_resizeability( x , typename is_resizeable< State >::type() );
+ m_is_initialized = true;
+ }
+ }
+
+ void adjust_size_by_policy( const State &x , adjust_size_always_tag )
+ {
+ adjust_size_by_resizeability( x , typename is_resizeable< State >::type() );
+ }
+
+
+
+private:
+
+
+ void adjust_size_by_resizeability( const State &x , boost::true_type )
+ {
+ m_stepper.adjust_size_impl( x );
+ }
+
+ void adjust_size_by_resizeability( const State &x , boost::false_type )
+ {
+ }
+
+
+private :
+
+ bool m_is_initialized;
+ Stepper &m_stepper;
+};
+
+
+
+
+
+/*
+ * base class for explicit steppers
+ */
 template<
         class Stepper ,
         unsigned short Order ,
@@ -37,6 +108,7 @@
 {
 public:
 
+
         typedef State state_type;
         typedef Time time_type;
         typedef Algebra algebra_type;
@@ -47,56 +119,51 @@
         typedef unsigned short order_type;
         static const order_type order_value = Order;
 
- explicit_stepper_base( void ) : m_is_initialized( false ) { }
+ order_type order( void ) const { return order_value; }
 
- stepper_type& stepper( void ) { return *static_cast< stepper_type* >( this ); }
 
- const stepper_type& stepper( void ) const {return *static_cast< const stepper_type* >( this );}
+ explicit_stepper_base( void ) : m_size_adjuster( *this ) { }
 
- order_type order( void ) const { return order_value; }
 
- void adjust_size( const state_type &x )
- {
- do_adjust_size( x , typename is_resizeable< state_type >::type() );
- }
+ stepper_type& stepper( void ) { return *static_cast< stepper_type* >( this ); }
+ const stepper_type& stepper( void ) const {return *static_cast< const stepper_type* >( this );}
 
-protected:
 
- void do_adjust_size( const state_type &x , boost::true_type )
- {
- this->stepper().adjust_size_impl( x );
- }
 
- void do_adjust_size( const state_type &x , boost::false_type )
+ template< class System >
+ void do_step( System system , state_type &x , time_type t , time_type dt )
         {
+ m_size_adjuster.adjust_size_by_policy( x , adjust_size_policy() );
+ system( x , m_dxdt ,t );
+ this->stepper().do_step_impl( system , x , m_dxdt , t , dt );
         }
 
 
- void adjust_size_by_policy( const state_type &x , adjust_size_manually_tag )
+ void adjust_size( const state_type &x )
         {
+ m_size_adjuster.adjust_size( x );
         }
 
- void adjust_size_by_policy( const state_type &x , adjust_size_initially_tag )
- {
- if( !m_is_initialized )
- {
- do_adjust_size( x , typename is_resizeable< state_type >::type() );
- m_is_initialized = true;
- }
- }
 
- void adjust_size_by_policy( const state_type &x , adjust_size_always_tag )
+private:
+
+ typedef explicit_stepper_base< Stepper , Order , State , Time , Algebra , Operations , AdjustSizePolicy > internal_stepper_base_type;
+ typedef size_adjuster< state_type , internal_stepper_base_type > base_size_adjuster_type;
+ friend class size_adjuster< state_type , internal_stepper_base_type >;
+
+ void adjust_size_impl( const state_type &x )
         {
- do_adjust_size( x , typename is_resizeable< state_type >::type() );
+ boost::numeric::odeint::adjust_size( x , m_dxdt );
         }
 
-private:
 
- bool m_is_initialized;
+ state_type m_dxdt;
+ base_size_adjuster_type m_size_adjuster;
 };
 
 
 
+
 } // odeint
 } // numeric
 } // boost

Modified: sandbox/odeint/branches/karsten/boost/numeric/odeint/stepper/runge_kutta_error_ck.hpp
==============================================================================
--- sandbox/odeint/branches/karsten/boost/numeric/odeint/stepper/runge_kutta_error_ck.hpp (original)
+++ sandbox/odeint/branches/karsten/boost/numeric/odeint/stepper/runge_kutta_error_ck.hpp 2010-07-15 03:24:17 EDT (Thu, 15 Jul 2010)
@@ -50,6 +50,7 @@
         runge_kutta_error_ck( void ) : m_dxdt() , m_x1() , m_x2() , m_x3() , m_x4() , m_x5() , m_x6()
         { }
 
+
         template< class System >
         void do_step( System system , state_type &x , time_type t , time_type dt , state_type &xerr)
         {
@@ -127,7 +128,6 @@
                 //error estimate
                 algebra_type::for_each6( xerr , dxdt , m_x3 , m_x4 , m_x5 , m_x6 ,
                                         typename operations_type::scale_sum5( dt*dc1 , dt*dc3 , dt*dc4 , dt*dc5 , dt*dc6 ));
-
         }
 
 

Modified: sandbox/odeint/branches/karsten/libs/numeric/odeint/test/Jamfile
==============================================================================
--- sandbox/odeint/branches/karsten/libs/numeric/odeint/test/Jamfile (original)
+++ sandbox/odeint/branches/karsten/libs/numeric/odeint/test/Jamfile 2010-07-15 03:24:17 EDT (Thu, 15 Jul 2010)
@@ -17,5 +17,6 @@
 lib libgslcblas : : <name>gslcblas ;
 
 test-suite "odeint"
- : [ run check_stepper_concepts.cpp libgsl libgslcblas ]
+ : [ run check_stepper_concepts.cpp libgsl libgslcblas ]
+ [ run check_resize.cpp ]
     ;
\ No newline at end of file

Added: sandbox/odeint/branches/karsten/libs/numeric/odeint/test/check_resize.cpp
==============================================================================
--- (empty file)
+++ sandbox/odeint/branches/karsten/libs/numeric/odeint/test/check_resize.cpp 2010-07-15 03:24:17 EDT (Thu, 15 Jul 2010)
@@ -0,0 +1,106 @@
+/* Boost stepper_euler.cpp test file
+
+ Copyright 2009 Karsten Ahnert
+ Copyright 2009 Mario Mulansky
+
+ This file tests the use of the euler stepper
+
+ 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)
+*/
+
+#include <vector>
+#include <cmath>
+#include <boost/array.hpp>
+
+#include <boost/test/unit_test.hpp>
+
+#include <boost/numeric/odeint.hpp>
+#include <boost/numeric/odeint/algebra/vector_space_algebra.hpp>
+
+using namespace boost::unit_test;
+using namespace boost::numeric::odeint;
+
+size_t adjust_size_count;
+
+typedef boost::array< double , 1 > test_array_type;
+
+namespace boost {
+namespace numeric {
+namespace odeint {
+
+
+
+template<>
+struct is_resizeable< test_array_type >
+{
+ struct type : public boost::true_type { };
+ const static bool value = type::value;
+};
+
+
+template<>
+void adjust_size( const test_array_type &x1 , test_array_type &x2 )
+{
+ adjust_size_count++;
+}
+
+}
+}
+}
+
+
+
+void constant_system( const test_array_type &x , test_array_type &dxdt , double t )
+{
+ dxdt[0] = 1.0;
+}
+
+
+void test_manual_resize( void )
+{
+ adjust_size_count = 0;
+
+ test_array_type x;
+ explicit_euler< test_array_type , double , standard_algebra< test_array_type > , standard_operations< double > , adjust_size_manually_tag > euler;
+ euler.do_step( constant_system , x , 0.0 , 0.1 );
+
+ BOOST_CHECK( adjust_size_count == 0 );
+}
+
+void test_initially_resize( void )
+{
+ adjust_size_count = 0;
+ test_array_type x;
+ explicit_euler< test_array_type , double , standard_algebra< test_array_type > , standard_operations< double > , adjust_size_initially_tag > euler;
+ euler.do_step( constant_system , x , 0.0 , 0.1 );
+ euler.do_step( constant_system , x , 0.0 , 0.1 );
+ euler.do_step( constant_system , x , 0.0 , 0.1 );
+ BOOST_CHECK( adjust_size_count == 1 );
+}
+
+void test_always_resize( void )
+{
+ adjust_size_count = 0;
+ test_array_type x;
+ explicit_euler< test_array_type , double , standard_algebra< test_array_type > , standard_operations< double > , adjust_size_always_tag > euler;
+ euler.do_step( constant_system , x , 0.0 , 0.1 );
+ euler.do_step( constant_system , x , 0.0 , 0.1 );
+ euler.do_step( constant_system , x , 0.0 , 0.1 );
+ BOOST_CHECK( adjust_size_count == 3 );
+}
+
+
+
+test_suite* init_unit_test_suite( int argc, char* argv[] )
+{
+ test_suite *test = BOOST_TEST_SUITE( "check resize functionality" );
+
+ test->add( BOOST_TEST_CASE( &test_manual_resize ) );
+ test->add( BOOST_TEST_CASE( &test_initially_resize ) );
+ test->add( BOOST_TEST_CASE( &test_always_resize ) );
+
+ return test;
+}
+

Modified: sandbox/odeint/branches/karsten/libs/numeric/odeint/test/check_stepper_concepts.cpp
==============================================================================
--- sandbox/odeint/branches/karsten/libs/numeric/odeint/test/check_stepper_concepts.cpp (original)
+++ sandbox/odeint/branches/karsten/libs/numeric/odeint/test/check_stepper_concepts.cpp 2010-07-15 03:24:17 EDT (Thu, 15 Jul 2010)
@@ -87,45 +87,47 @@
     BOOST_CHECK_SMALL( fabs( xval - 0.1 ) , eps );
 }
 
-//void test_euler_with_vector( void )
-//{
-// state_type1 x( 1 , 0.0 );
-// explicit_euler< state_type1 > euler;
-// check_stepper_concept( euler , constant_system1 , x );
-//}
+void test_euler_with_vector( void )
+{
+ state_type1 x( 1 , 0.0 );
+ explicit_euler< state_type1 > euler;
+ check_stepper_concept( euler , constant_system1 , x );
+}
 
 void test_euler_with_gsl_vector( void )
 {
         state_type2 *x = gsl_vector_alloc( 1 );
         explicit_euler< state_type2 > euler;
- check_stepper_concept( euler , constant_system2 , *x );
+// check_stepper_concept( euler , constant_system2 , *x );
+ gsl_vector_free( x );
 }
 
-//void test_euler_with_array( void )
-//{
-// state_type4 x;
-// x[0] = 0.0;
-// explicit_euler< state_type4 > euler;
-// check_stepper_concept( euler , constant_system4 , x );
-//}
-
-void test_runge_kutta_error_ck_with_vector( void )
+void test_euler_with_array( void )
 {
- state_type1 x( 1 , 0.0 );
- state_type1 xerr( 1 , 0.0 );
- runge_kutta_error_ck< state_type1 > rk_ck;
- check_error_stepper_concept( rk_ck , constant_system1 , x , xerr );
+ state_type4 x;
+ x[0] = 0.0;
+ explicit_euler< state_type4 > euler;
+ check_stepper_concept( euler , constant_system4 , x );
 }
 
+//void test_runge_kutta_error_ck_with_vector( void )
+//{
+// state_type1 x( 1 , 0.0 );
+// state_type1 xerr( 1 , 0.0 );
+// runge_kutta_error_ck< state_type1 > rk_ck;
+// check_error_stepper_concept( rk_ck , constant_system1 , x , xerr );
+//}
+
 test_suite* init_unit_test_suite( int argc, char* argv[] )
 {
     test_suite *test = BOOST_TEST_SUITE("check stepper concepts");
 
 
 
-// test->add( BOOST_TEST_CASE( &test_euler_with_vector ) );
-// test->add( BOOST_TEST_CASE( &test_euler_with_array ) );
- test->add( BOOST_TEST_CASE( &test_euler_with_gsl_vector ) );
+ test->add( BOOST_TEST_CASE( &test_euler_with_vector ) );
+ test->add( BOOST_TEST_CASE( &test_euler_with_array ) );
+
+// test->add( BOOST_TEST_CASE( &test_euler_with_gsl_vector ) );
 
 
 


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