Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r63749 - in sandbox/odeint/branches/karsten: boost/numeric boost/numeric/odeint/algebra boost/numeric/odeint/stepper boost/numeric/odeint/stepper/detail libs/numeric/odeint/test
From: karsten.ahnert_at_[hidden]
Date: 2010-07-08 11:11:47


Author: karsten
Date: 2010-07-08 11:11:44 EDT (Thu, 08 Jul 2010)
New Revision: 63749
URL: http://svn.boost.org/trac/boost/changeset/63749

Log:
checked in the draft
Added:
   sandbox/odeint/branches/karsten/boost/numeric/odeint/algebra/
   sandbox/odeint/branches/karsten/boost/numeric/odeint/algebra/idea_algebra_dispatcher.hpp (contents, props changed)
   sandbox/odeint/branches/karsten/boost/numeric/odeint/algebra/idea_operations_dispatcher.hpp (contents, props changed)
   sandbox/odeint/branches/karsten/boost/numeric/odeint/algebra/standard_algebra.hpp (contents, props changed)
   sandbox/odeint/branches/karsten/boost/numeric/odeint/algebra/standard_operations.hpp (contents, props changed)
   sandbox/odeint/branches/karsten/boost/numeric/odeint/algebra/standard_resize.hpp (contents, props changed)
   sandbox/odeint/branches/karsten/boost/numeric/odeint/algebra/tr1_array_resize.hpp (contents, props changed)
   sandbox/odeint/branches/karsten/boost/numeric/odeint/algebra/vector_space_algebra.hpp (contents, props changed)
   sandbox/odeint/branches/karsten/boost/numeric/odeint/stepper/
   sandbox/odeint/branches/karsten/boost/numeric/odeint/stepper/detail/
   sandbox/odeint/branches/karsten/boost/numeric/odeint/stepper/detail/macros.hpp (contents, props changed)
   sandbox/odeint/branches/karsten/boost/numeric/odeint/stepper/explicit_euler.hpp (contents, props changed)
   sandbox/odeint/branches/karsten/boost/numeric/odeint/stepper/explicit_stepper_base.hpp (contents, props changed)
Text files modified:
   sandbox/odeint/branches/karsten/boost/numeric/odeint.hpp | 1
   sandbox/odeint/branches/karsten/libs/numeric/odeint/test/Jamfile | 5 +
   sandbox/odeint/branches/karsten/libs/numeric/odeint/test/check_stepper_concepts.cpp | 106 +++++++++++++++++++++++++--------------
   sandbox/odeint/branches/karsten/libs/numeric/odeint/test/gsl_vector_adaptor.hpp | 8 ++
   4 files changed, 78 insertions(+), 42 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-08 11:11:44 EDT (Thu, 08 Jul 2010)
@@ -17,5 +17,6 @@
 
 #include <boost/config.hpp>
 
+#include <boost/numeric/odeint/stepper/explicit_euler.hpp>
 
 #endif // BOOST_NUMERIC_ODEINT_HPP

Added: sandbox/odeint/branches/karsten/boost/numeric/odeint/algebra/idea_algebra_dispatcher.hpp
==============================================================================
--- (empty file)
+++ sandbox/odeint/branches/karsten/boost/numeric/odeint/algebra/idea_algebra_dispatcher.hpp 2010-07-08 11:11:44 EDT (Thu, 08 Jul 2010)
@@ -0,0 +1,39 @@
+/*
+ boost header: BOOST_NUMERIC_ODEINT/algebra_dispatcher.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_DISPATCHER_HPP_INCLUDED
+#define BOOST_BOOST_NUMERIC_ODEINT_ALGEBRA_DISPATCHER_HPP_INCLUDED
+
+namespace boost {
+namespace numeric {
+namespace odeint {
+
+
+/*
+ * ToDo : Implement
+ */
+template< class Container , class Time >
+struct algebra_dispatcher
+{
+ typedef Container container_type;
+ typedef Time time_type;
+
+ typedef standard_algebra< container_type > type;
+};
+
+
+} // odeint
+} // numeric
+} // boost
+
+
+#endif //BOOST_BOOST_NUMERIC_ODEINT_ALGEBRA_DISPATCHER_HPP_INCLUDED

Added: sandbox/odeint/branches/karsten/boost/numeric/odeint/algebra/idea_operations_dispatcher.hpp
==============================================================================
--- (empty file)
+++ sandbox/odeint/branches/karsten/boost/numeric/odeint/algebra/idea_operations_dispatcher.hpp 2010-07-08 11:11:44 EDT (Thu, 08 Jul 2010)
@@ -0,0 +1,35 @@
+/*
+ boost header: BOOST_NUMERIC_ODEINT/operations_dispatcher.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_OPERATIONS_DISPATCHER_HPP_INCLUDED
+#define BOOST_BOOST_NUMERIC_ODEINT_OPERATIONS_DISPATCHER_HPP_INCLUDED
+
+namespace boost {
+namespace numeric {
+namespace odeint {
+
+/*
+ * ToDo : implement
+ */
+template< class Container , class Time >
+struct operations_dispatcher
+{
+ typedef standard_operations< Time > type;
+};
+
+
+} // odeint
+} // numeric
+} // boost
+
+
+#endif //BOOST_BOOST_NUMERIC_ODEINT_OPERATIONS_DISPATCHER_HPP_INCLUDED

Added: sandbox/odeint/branches/karsten/boost/numeric/odeint/algebra/standard_algebra.hpp
==============================================================================
--- (empty file)
+++ sandbox/odeint/branches/karsten/boost/numeric/odeint/algebra/standard_algebra.hpp 2010-07-08 11:11:44 EDT (Thu, 08 Jul 2010)
@@ -0,0 +1,55 @@
+/*
+ boost header: BOOST_NUMERIC_ODEINT/standard_algebra.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_STANDARD_ALGEBRA_HPP_INCLUDED
+#define BOOST_BOOST_NUMERIC_ODEINT_STANDARD_ALGEBRA_HPP_INCLUDED
+
+#include <boost/range.hpp>
+
+namespace boost {
+namespace numeric {
+namespace odeint {
+
+template< class Container >
+struct standard_algebra
+{
+ typedef Container container_type;
+
+ template< class StateType1 , class StateType2 , class Operation >
+ static void transform2( StateType1 &s1 , StateType2 &s2 , Operation op )
+ {
+ // ToDo : check that number of arguments of the operation is equal 2
+
+ // 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
+ transform2( boost::begin( s1 ) , boost::end( s1 ) ,
+ boost::begin( s2 ) , op );
+ }
+
+ // ToDo : pack into namespace detail
+ template< class Iterator1 , class Iterator2 , class Operation >
+ static void transform2( Iterator1 first1 , Iterator1 last1 , Iterator2 first2 , Operation op )
+ {
+ for( ; first1 != last1 ; )
+ op( *first1++ , *first2++ );
+ }
+};
+
+} // odeint
+} // numeric
+} // boost
+
+
+#endif //BOOST_BOOST_NUMERIC_ODEINT_STANDARD_ALGEBRA_HPP_INCLUDED

Added: sandbox/odeint/branches/karsten/boost/numeric/odeint/algebra/standard_operations.hpp
==============================================================================
--- (empty file)
+++ sandbox/odeint/branches/karsten/boost/numeric/odeint/algebra/standard_operations.hpp 2010-07-08 11:11:44 EDT (Thu, 08 Jul 2010)
@@ -0,0 +1,49 @@
+/*
+ boost header: BOOST_NUMERIC_ODEINT/standard_operations.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_STANDARD_OPERATIONS_HPP_INCLUDED
+#define BOOST_BOOST_NUMERIC_ODEINT_STANDARD_OPERATIONS_HPP_INCLUDED
+
+namespace boost {
+namespace numeric {
+namespace odeint {
+
+
+/*
+ * have to be changed if thrust device_vector or gsl_vector are used
+ */
+template< class Time >
+struct standard_operations
+{
+ typedef Time time_type;
+
+ struct increment
+ {
+ time_type m_dt;
+
+ increment( time_type dt ) : m_dt( dt ) { }
+
+ template< class T1 , class T2 >
+ void operator()( T1 &t1 , const T2 &t2 ) const
+ {
+ t1 += m_dt * t2;
+ }
+ };
+};
+
+
+} // odeint
+} // numeric
+} // boost
+
+
+#endif //BOOST_BOOST_NUMERIC_ODEINT_STANDARD_OPERATIONS_HPP_INCLUDED

Added: sandbox/odeint/branches/karsten/boost/numeric/odeint/algebra/standard_resize.hpp
==============================================================================
--- (empty file)
+++ sandbox/odeint/branches/karsten/boost/numeric/odeint/algebra/standard_resize.hpp 2010-07-08 11:11:44 EDT (Thu, 08 Jul 2010)
@@ -0,0 +1,54 @@
+/*
+ boost header: BOOST_NUMERIC_ODEINT/standard_resize.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_STANDARD_RESIZE_HPP_INCLUDED
+#define BOOST_BOOST_NUMERIC_ODEINT_STANDARD_RESIZE_HPP_INCLUDED
+
+namespace boost {
+namespace numeric {
+namespace odeint {
+
+
+template< class Container >
+struct is_resizeable
+{
+ struct type : public boost::true_type { };
+ const static bool value = type::value;
+};
+
+
+template< class Container >
+void resize( const Container &x , Container &dxdt )
+{
+ dxdt.resize( x.size() );
+}
+
+template< class Container >
+bool same_size( const Container &x1 , const Container &x2 )
+{
+ return ( x1.size() == x2.size() );
+}
+
+template< class Container >
+void adjust_size( const Container &x1 , Container &x2 )
+{
+ if( !same_size( x1 , x2 ) ) resize( x1 , x2 );
+}
+
+
+
+} // odeint
+} // numeric
+} // boost
+
+
+#endif //BOOST_BOOST_NUMERIC_ODEINT_STANDARD_RESIZE_HPP_INCLUDED

Added: sandbox/odeint/branches/karsten/boost/numeric/odeint/algebra/tr1_array_resize.hpp
==============================================================================
--- (empty file)
+++ sandbox/odeint/branches/karsten/boost/numeric/odeint/algebra/tr1_array_resize.hpp 2010-07-08 11:11:44 EDT (Thu, 08 Jul 2010)
@@ -0,0 +1,34 @@
+/*
+ boost header: BOOST_NUMERIC_ODEINT/tr1_array_resize.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_TR1_ARRAY_RESIZE_HPP_INCLUDED
+#define BOOST_BOOST_NUMERIC_ODEINT_TR1_ARRAY_RESIZE_HPP_INCLUDED
+
+
+namespace boost {
+namespace numeric {
+namespace odeint {
+
+template< class T , size_t N >
+struct is_resizeable< std::tr1::array< T , N > >
+{
+ struct type : public boost::false_type { };
+ const static bool value = type::value;
+};
+
+
+} // odeint
+} // numeric
+} // boost
+
+
+#endif //BOOST_BOOST_NUMERIC_ODEINT_TR1_ARRAY_RESIZE_HPP_INCLUDED

Added: sandbox/odeint/branches/karsten/boost/numeric/odeint/algebra/vector_space_algebra.hpp
==============================================================================
--- (empty file)
+++ sandbox/odeint/branches/karsten/boost/numeric/odeint/algebra/vector_space_algebra.hpp 2010-07-08 11:11:44 EDT (Thu, 08 Jul 2010)
@@ -0,0 +1,37 @@
+/*
+ boost header: BOOST_NUMERIC_ODEINT/vector_space_algebra.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_VECTOR_SPACE_ALGEBRA_HPP_INCLUDED
+#define BOOST_BOOST_NUMERIC_ODEINT_VECTOR_SPACE_ALGEBRA_HPP_INCLUDED
+
+namespace boost {
+namespace numeric {
+namespace odeint {
+
+
+struct vector_space_algebra
+{
+ template< class StateType1 , class StateType2 , class Operation >
+ void transform2( StateType1 &s1 , StateType2 &s2 , Operation op )
+ {
+ // ToDo : build checks, that the +-*/ operators are well defined
+ op( s1 , s2 );
+ }
+};
+
+
+} // odeint
+} // numeric
+} // boost
+
+
+#endif //BOOST_BOOST_NUMERIC_ODEINT_VECTOR_SPACE_ALGEBRA_HPP_INCLUDED

Added: sandbox/odeint/branches/karsten/boost/numeric/odeint/stepper/detail/macros.hpp
==============================================================================
--- (empty file)
+++ sandbox/odeint/branches/karsten/boost/numeric/odeint/stepper/detail/macros.hpp 2010-07-08 11:11:44 EDT (Thu, 08 Jul 2010)
@@ -0,0 +1,28 @@
+/*
+ boost header: BOOST_NUMERIC_ODEINT_DETAIL/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_DETAIL_MACROS_HPP_INCLUDED
+#define BOOST_BOOST_NUMERIC_ODEINT_DETAIL_MACROS_HPP_INCLUDED
+
+
+#define BOOST_ODEINT_EXPLICIT_STEPPERS_TYPEDEFS( STEPPER , ORDER ) \
+typedef explicit_stepper_base< \
+STEPPER< State , Time , Algebra , Operations , AdjustSizePolicy > , \
+ORDER , State , Time , Algebra , Operations , AdjustSizePolicy > stepper_base_type; \
+typedef typename stepper_base_type::state_type state_type; \
+typedef typename stepper_base_type::time_type time_type; \
+typedef typename stepper_base_type::algebra_type algebra_type; \
+typedef typename stepper_base_type::operations_type operations_type; \
+typedef typename stepper_base_type::adjust_size_policy adjust_size_policy
+
+
+#endif //BOOST_BOOST_NUMERIC_ODEINT_DETAIL_MACROS_HPP_INCLUDED

Added: sandbox/odeint/branches/karsten/boost/numeric/odeint/stepper/explicit_euler.hpp
==============================================================================
--- (empty file)
+++ sandbox/odeint/branches/karsten/boost/numeric/odeint/stepper/explicit_euler.hpp 2010-07-08 11:11:44 EDT (Thu, 08 Jul 2010)
@@ -0,0 +1,88 @@
+/*
+ boost header: BOOST_NUMERIC_ODEINT/explicit_euler.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_EXPLICIT_EULER_HPP_INCLUDED
+#define BOOST_BOOST_NUMERIC_ODEINT_EXPLICIT_EULER_HPP_INCLUDED
+
+#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>
+
+namespace boost {
+namespace numeric {
+namespace odeint {
+
+
+template<
+ class State ,
+ class Time = double ,
+ class Algebra = standard_algebra< State > ,
+ class Operations = standard_operations< Time > ,
+ class AdjustSizePolicy = adjust_size_initially_tag
+ >
+class explicit_euler
+: public explicit_stepper_base<
+ explicit_euler< State , Time , Algebra , Operations , AdjustSizePolicy > ,
+ 1 , State , Time , Algebra , Operations , AdjustSizePolicy >
+{
+public :
+
+
+ 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 )
+ {
+ algebra_type::transform2( x , dxdt , typename operations_type::increment( dt ) );
+ }
+
+
+
+
+private:
+
+ void adjust_size_impl( const state_type &x )
+ {
+ adjust_size( x , m_dxdt );
+ }
+
+
+ state_type m_dxdt;
+};
+
+} // odeint
+} // numeric
+} // boost
+
+
+#endif //BOOST_BOOST_NUMERIC_ODEINT_EXPLICIT_EULER_HPP_INCLUDED

Added: sandbox/odeint/branches/karsten/boost/numeric/odeint/stepper/explicit_stepper_base.hpp
==============================================================================
--- (empty file)
+++ sandbox/odeint/branches/karsten/boost/numeric/odeint/stepper/explicit_stepper_base.hpp 2010-07-08 11:11:44 EDT (Thu, 08 Jul 2010)
@@ -0,0 +1,105 @@
+/*
+ boost header: BOOST_NUMERIC_ODEINT/explicit_stepper_base.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_EXPLICIT_STEPPER_BASE_HPP_INCLUDED
+#define BOOST_BOOST_NUMERIC_ODEINT_EXPLICIT_STEPPER_BASE_HPP_INCLUDED
+
+namespace boost {
+namespace numeric {
+namespace odeint {
+
+
+
+struct adjust_size_manually_tag {};
+struct adjust_size_initially_tag {};
+struct adjust_size_always_tag {};
+
+
+template<
+ class Stepper ,
+ unsigned short Order ,
+ class State ,
+ class Time ,
+ class Algebra ,
+ class Operations ,
+ class AdjustSizePolicy
+>
+class explicit_stepper_base
+{
+public:
+
+ typedef State state_type;
+ typedef Time time_type;
+ typedef Algebra algebra_type;
+ typedef Operations operations_type;
+ typedef AdjustSizePolicy adjust_size_policy;
+ typedef Stepper stepper_type;
+
+ typedef unsigned short order_type;
+ static const order_type order_value = Order;
+
+ explicit_stepper_base( void ) : m_is_initialized( false ) { }
+
+ stepper_type& stepper( void ) { return *static_cast< stepper_type* >( this ); }
+
+ const stepper_type& stepper( void ) const {return *static_cast< const stepper_type* >( 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() );
+ }
+
+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 )
+ {
+ }
+
+
+ void adjust_size_by_policy( const state_type &x , adjust_size_manually_tag )
+ {
+ }
+
+ 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 )
+ {
+ do_adjust_size( x , typename is_resizeable< state_type >::type() );
+ }
+
+private:
+
+ bool m_is_initialized;
+};
+
+
+
+} // odeint
+} // numeric
+} // boost
+
+
+#endif //BOOST_BOOST_NUMERIC_ODEINT_EXPLICIT_STEPPER_BASE_HPP_INCLUDED

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-08 11:11:44 EDT (Thu, 08 Jul 2010)
@@ -12,7 +12,10 @@
       <include>../../../..
       <include>$BOOST_ROOT
     ;
+
+lib libgsl : : <name>gsl ;
+lib libgslcblas : : <name>gslcblas ;
 
 test-suite "odeint"
- : [ run check_stepper_concepts.cpp ]
+ : [ run check_stepper_concepts.cpp libgsl libgslcblas ]
     ;

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-08 11:11:44 EDT (Thu, 08 Jul 2010)
@@ -11,59 +11,68 @@
 */
 
 #include <vector>
+#include <cmath>
 #include <tr1/array>
 
 #include <boost/test/unit_test.hpp>
 
+#include <boost/numeric/odeint.hpp>
+#include <boost/numeric/odeint/algebra/tr1_array_resize.hpp>
+
+#include "vector_space_1d.hpp"
+#include "gsl_vector_adaptor.hpp"
+
+using std::vector;
+
 using namespace boost::unit_test;
-// using namespace boost::numeric::odeint;
+using namespace boost::numeric::odeint;
 
+typedef std::vector< double > state_type1;
+typedef gsl_vector state_type2;
+typedef vector_space_1d< double > state_type3;
+typedef std::tr1::array< double , 1 > state_type4;
 
+void constant_system1( const state_type1 &x , state_type1 &dxdt , double t )
+{
+ dxdt[0] = 1.0;
+}
 
+void constant_system2( const state_type2 &x , state_type2 &dxdt , double t )
+{
+ gsl_vector_set( &dxdt , 0 , 1.0 );
+}
 
-template< class Container >
-struct constant_system
+void constant_system3( const state_type3 &x , state_type3 &dxdt , double t )
 {
- void operator()( const Container &x , Container &dxdt , double t )
- {
- dxdt[0] = 1.0;
- }
-};
+ dxdt.m_x = 1.0;
+}
+
+void constant_system4( const state_type4 &x , state_type4 &dxdt , double t )
+{
+ dxdt[0] = 1.0;
+}
+
 
 
 const double eps = 1.0e-14;
 
-//template< class Stepper >
-//void check_stepper_concept( Stepper &stepper ,
-// typename Stepper::order_type order_step )
-//{
-// typedef Stepper stepper_type;
-// typedef typename stepper_type::container_type container_type;
-// typedef typename stepper_type::traits_type traits_type;
-// typedef typename stepper_type::value_type value_type;
-// typedef typename stepper_type::order_type order_type;
-// typedef typename stepper_type::time_type time_type;
-//
-// constant_system< container_type > con;
-//
-// BOOST_CHECK_EQUAL( order_step , stepper.order_step() );
-//
-// container_type x( 1 , 0.0 ) ;
-// stepper.adjust_size( x );
-// stepper.do_step( con , x , 0.0 , 0.1 );
-// BOOST_CHECK_SMALL( fabs( x[0] - 0.1 ) , eps );
-//
-// container_type dxdt( 1 , 1.0 );
-// stepper.do_step( con , x , dxdt , 0.0 , 0.1 );
-// BOOST_CHECK_SMALL( fabs( x[0] - 0.2 ) , eps );
-//
-// stepper_type stepper2( x );
-// stepper_type stepper3;
-//}
-//
-//
-//
-//
+
+template< class Stepper , class System >
+void check_stepper_concept( Stepper &stepper , System system , typename Stepper::state_type &x )
+{
+ typedef Stepper stepper_type;
+ typedef typename stepper_type::state_type container_type;
+ typedef typename stepper_type::order_type order_type;
+ typedef typename stepper_type::time_type time_type;
+
+ stepper.do_step( system , x , 0.0 , 0.1 );
+ double xval = * boost::begin( x );
+ BOOST_CHECK_SMALL( fabs( xval - 0.1 ) , eps );
+}
+
+
+
+
 //template< class ErrorStepper >
 //void check_error_stepper_concept(
 // ErrorStepper &stepper ,
@@ -186,10 +195,29 @@
 //
 
 
+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_array( void )
+{
+ state_type4 x;
+ x[0] = 0.0;
+ explicit_euler< state_type4 > euler;
+ check_stepper_concept( euler , constant_system4 , x );
+}
+
 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_concept ) );
 
     return test;

Modified: sandbox/odeint/branches/karsten/libs/numeric/odeint/test/gsl_vector_adaptor.hpp
==============================================================================
--- sandbox/odeint/branches/karsten/libs/numeric/odeint/test/gsl_vector_adaptor.hpp (original)
+++ sandbox/odeint/branches/karsten/libs/numeric/odeint/test/gsl_vector_adaptor.hpp 2010-07-08 11:11:44 EDT (Thu, 08 Jul 2010)
@@ -15,6 +15,8 @@
 
 #include <gsl/gsl_vector.h>
 
+#include <boost/range.hpp>
+
 namespace boost
 {
         // ToDo define gsl_vector_iterator which increments x by stride
@@ -26,17 +28,19 @@
         };
 
         template<>
- range_iterator< gsl_vector > begin( gsl_vector &r )
+ range_iterator< gsl_vector >::type begin( gsl_vector &r )
         {
                 return r.data;
         }
 
         template<>
- range_iterator< gsl_vector > end( gsl_vector &r )
+ range_iterator< gsl_vector >::type end( gsl_vector &r )
         {
                 return r.data + r.size;
         }
 
+
+
 }
 
 #endif // GSL_VECTOR_ADAPTOR_HPP_INCLUDED


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