Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r72153 - in sandbox/odeint/branches/karsten: boost/numeric/odeint/stepper boost/numeric/odeint/stepper/detail libs/numeric/odeint/doc/html libs/numeric/odeint/regression_test libs/numeric/odeint/test
From: karsten.ahnert_at_[hidden]
Date: 2011-05-25 02:22:47


Author: karsten
Date: 2011-05-25 02:22:45 EDT (Wed, 25 May 2011)
New Revision: 72153
URL: http://svn.boost.org/trac/boost/changeset/72153

Log:
adams moultons and some tests
Added:
   sandbox/odeint/branches/karsten/boost/numeric/odeint/stepper/adams_moulton.hpp (contents, props changed)
   sandbox/odeint/branches/karsten/boost/numeric/odeint/stepper/detail/adams_moulton_coefficients.hpp (contents, props changed)
   sandbox/odeint/branches/karsten/libs/numeric/odeint/regression_test/adams_bashforth.cpp (contents, props changed)
Text files modified:
   sandbox/odeint/branches/karsten/boost/numeric/odeint/stepper/adams_bashforth.hpp | 15 +++++---
   sandbox/odeint/branches/karsten/boost/numeric/odeint/stepper/detail/adams_bashforth_call_algebra.hpp | 72 ++++++++++++++++++++++++++-------------
   sandbox/odeint/branches/karsten/libs/numeric/odeint/doc/html/index.html | 4 +-
   sandbox/odeint/branches/karsten/libs/numeric/odeint/regression_test/Jamfile | 4 ++
   sandbox/odeint/branches/karsten/libs/numeric/odeint/test/adams_bashforth.cpp | 27 +++++++++++++-
   5 files changed, 87 insertions(+), 35 deletions(-)

Modified: sandbox/odeint/branches/karsten/boost/numeric/odeint/stepper/adams_bashforth.hpp
==============================================================================
--- sandbox/odeint/branches/karsten/boost/numeric/odeint/stepper/adams_bashforth.hpp (original)
+++ sandbox/odeint/branches/karsten/boost/numeric/odeint/stepper/adams_bashforth.hpp 2011-05-25 02:22:45 EDT (Wed, 25 May 2011)
@@ -9,8 +9,6 @@
 #define BOOST_NUMERIC_ODEINT_STEPPER_ADAMS_BASHFORTH_HPP_
 
 #include <boost/ref.hpp>
-#include <boost/array.hpp>
-#include <boost/circular_buffer.hpp>
 
 #include <boost/numeric/odeint/algebra/range_algebra.hpp>
 #include <boost/numeric/odeint/algebra/default_operations.hpp>
@@ -225,17 +223,22 @@
         }
 
         template< class ExplicitStepper , class System , class StateIn >
- void initialize( ExplicitStepper explicit_stepper , System system , const StateIn &x , const time_type &t , const time_type &dt )
+ void initialize( ExplicitStepper explicit_stepper , System system , StateIn &x , time_type &t , const time_type &dt )
         {
                 typename boost::unwrap_reference< ExplicitStepper >::type &stepper = explicit_stepper;
                 typename boost::unwrap_reference< System >::type &sys = system;
 
- // ToDo : implement
-
+ for( size_t i=0 ; i<steps-1 ; ++i )
+ {
+ if( i != 0 ) m_step_storage.rotate();
+ sys( x , m_step_storage[0] , t );
+ stepper.do_step( system , x , m_step_storage[0] , t , dt );
+ t += dt;
+ }
         }
 
         template< class System , class StateIn >
- void initialize( System system , const StateIn &x , const time_type &t , const time_type &dt )
+ void initialize( System system , StateIn &x , time_type &t , const time_type &dt )
         {
                 explicit_rk4< state_type , value_type , deriv_type , time_type , algebra_type , operations_type , adjust_size_initially_tag > rk4;
                 initialize( boost::ref( rk4 ) , system , x , t , dt );

Added: sandbox/odeint/branches/karsten/boost/numeric/odeint/stepper/adams_moulton.hpp
==============================================================================
--- (empty file)
+++ sandbox/odeint/branches/karsten/boost/numeric/odeint/stepper/adams_moulton.hpp 2011-05-25 02:22:45 EDT (Wed, 25 May 2011)
@@ -0,0 +1,150 @@
+/*
+ * adam_moulton.hpp
+ *
+ * Created on: May 15, 2011
+ * Author: karsten
+ */
+
+#ifndef BOOST_NUMERIC_ODEINT_STEPPER_ADAMS_MOULTON_HPP_
+#define BOOST_NUMERIC_ODEINT_STEPPER_ADAMS_MOULTON_HPP_
+
+#include <boost/ref.hpp>
+
+#include <boost/numeric/odeint/algebra/range_algebra.hpp>
+#include <boost/numeric/odeint/algebra/default_operations.hpp>
+
+#include <boost/numeric/odeint/util/size_adjuster.hpp>
+
+#include <boost/numeric/odeint/stepper/stepper_categories.hpp>
+#include <boost/numeric/odeint/stepper/explicit_rk4.hpp>
+
+#include <boost/numeric/odeint/stepper/detail/adams_bashforth_call_algebra.hpp>
+#include <boost/numeric/odeint/stepper/detail/adams_moulton_coefficients.hpp>
+#include <boost/numeric/odeint/stepper/detail/rotating_buffer.hpp>
+
+
+
+
+
+
+namespace boost {
+namespace numeric {
+namespace odeint {
+
+
+/*
+ * Static implicit Adams-Moulton multistep-solver without step size control and without dense output.
+ *
+ * # Define the number of steps
+ */
+template<
+ size_t Steps ,
+ class State ,
+ class Value = double ,
+ class Deriv = State ,
+ class Time = Value ,
+ class Algebra = range_algebra ,
+ class Operations = default_operations ,
+ class AdjustSizePolicy = adjust_size_initially_tag
+ >
+class adam_moulton
+{
+private:
+
+ void initialize( void )
+ {
+ }
+
+ void copy( const adam_moulton &stepper )
+ {
+ }
+
+public :
+
+ typedef State state_type;
+ typedef Value value_type;
+ typedef Deriv deriv_type;
+ typedef Time time_type;
+ typedef Algebra algebra_type;
+ typedef Operations operations_type;
+ typedef AdjustSizePolicy adjust_size_policy;
+ typedef stepper_tag stepper_category;
+
+ static const size_t steps = Steps;
+
+ typedef unsigned short order_type;
+ static const order_type order_value = steps + 1;
+
+ typedef detail::rotating_buffer< deriv_type , steps > step_storage_type;
+
+
+ order_type order( void ) const { return order_value; }
+
+
+
+ adam_moulton( void )
+ : m_coefficients()
+ {
+ initialize();
+ }
+
+ adam_moulton( const adam_moulton &stepper )
+ : m_coefficients()
+ {
+ initialize();
+ copy( stepper );
+ }
+
+ adam_moulton& operator=( const adam_moulton &stepper )
+ {
+ copy( stepper );
+ return *this;
+ }
+
+
+ /*
+ * Version 1 : do_step( system , x , t , dt );
+ *
+ * solves the forwarding problem
+ */
+ template< class System , class StateInOut >
+ void do_step( System system , StateInOut &x , const time_type &t , const time_type &dt , const )
+ {
+ do_step( system , x , t , x , dt );
+ }
+
+ template< class System , class StateInOut >
+ void do_step( System system , const StateInOut &x , const time_type &t , const time_type &dt )
+ {
+ do_step( system , x , t , x , dt );
+ }
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+private:
+
+ const detail::adams_moulton_coefficients< value_type , steps > m_coefficients;
+};
+
+
+
+
+} // odeint
+} // numeric
+} // boost
+
+
+
+#endif /* BOOST_NUMERIC_ODEINT_STEPPER_ADAMS_MOULTON_HPP_ */

Modified: sandbox/odeint/branches/karsten/boost/numeric/odeint/stepper/detail/adams_bashforth_call_algebra.hpp
==============================================================================
--- sandbox/odeint/branches/karsten/boost/numeric/odeint/stepper/detail/adams_bashforth_call_algebra.hpp (original)
+++ sandbox/odeint/branches/karsten/boost/numeric/odeint/stepper/detail/adams_bashforth_call_algebra.hpp 2011-05-25 02:22:45 EDT (Wed, 25 May 2011)
@@ -8,7 +8,7 @@
 #ifndef BOOST_NUMERIC_ODEINT_STEPPER_DETAIL_ADAMS_BASHFORTH_CALL_ALGEBRA_HPP_
 #define BOOST_NUMERIC_ODEINT_STEPPER_DETAIL_ADAMS_BASHFORTH_CALL_ALGEBRA_HPP_
 
-#include <boost/array.hpp>
+#include <cassert>
 
 
 namespace boost {
@@ -22,10 +22,11 @@
 template< class Algebra , class Operations >
 struct call_algebra< 1 , Algebra , Operations >
 {
- template< class StateIn , class StateOut , class StepStorage , class Coefficients , class Value >
- void operator()( const StateIn &in , StateOut &out , const StepStorage &steps , const Coefficients &coef , const Value &dt ) const
+ template< class StateIn , class StateOut , class StepStorage , class Coefficients , class Time >
+ void operator()( const StateIn &in , StateOut &out , const StepStorage &steps , const Coefficients &coef , const Time &dt ) const
         {
-
+ typedef typename Coefficients::value_type value_type;
+ Algebra::for_each3( out , in , steps[0] , typename Operations::template scale_sum2< value_type , Time >( 1.0 , dt * coef[0] ) );
         }
 };
 
@@ -33,10 +34,12 @@
 template< class Algebra , class Operations >
 struct call_algebra< 2 , Algebra , Operations >
 {
- template< class StateIn , class StateOut , class StepStorage , class Coefficients , class Value >
- void operator()( const StateIn &in , StateOut &out , const StepStorage &steps , const Coefficients &coef , const Value &dt ) const
+ template< class StateIn , class StateOut , class StepStorage , class Coefficients , class Time >
+ void operator()( const StateIn &in , StateOut &out , const StepStorage &steps , const Coefficients &coef , const Time &dt ) const
         {
-
+ typedef typename Coefficients::value_type value_type;
+ Algebra::for_each4( out , in , steps[0] , steps[1] ,
+ typename Operations::template scale_sum3< value_type , Time , Time >( 1.0 , dt * coef[0] , dt * coef[1] ) );
         }
 };
 
@@ -44,10 +47,12 @@
 template< class Algebra , class Operations >
 struct call_algebra< 3 , Algebra , Operations >
 {
- template< class StateIn , class StateOut , class StepStorage , class Coefficients , class Value >
- void operator()( const StateIn &in , StateOut &out , const StepStorage &steps , const Coefficients &coef , const Value &dt ) const
+ template< class StateIn , class StateOut , class StepStorage , class Coefficients , class Time >
+ void operator()( const StateIn &in , StateOut &out , const StepStorage &steps , const Coefficients &coef , const Time &dt ) const
         {
-
+ typedef typename Coefficients::value_type value_type;
+ Algebra::for_each5( out , in , steps[0] , steps[1] , steps[2] ,
+ typename Operations::template scale_sum4< value_type , Time , Time >( 1.0 , dt * coef[0] , dt * coef[1] , dt * coef[2] ) );
         }
 };
 
@@ -55,10 +60,13 @@
 template< class Algebra , class Operations >
 struct call_algebra< 4 , Algebra , Operations >
 {
- template< class StateIn , class StateOut , class StepStorage , class Coefficients , class Value >
- void operator()( const StateIn &in , StateOut &out , const StepStorage &steps , const Coefficients &coef , const Value &dt ) const
+ template< class StateIn , class StateOut , class StepStorage , class Coefficients , class Time >
+ void operator()( const StateIn &in , StateOut &out , const StepStorage &steps , const Coefficients &coef , const Time &dt ) const
         {
-
+ typedef typename Coefficients::value_type value_type;
+ Algebra::for_each6( out , in , steps[0] , steps[1] , steps[2] , steps[3] ,
+ typename Operations::template scale_sum5< value_type , Time , Time , Time >(
+ 1.0 , dt * coef[0] , dt * coef[1] , dt * coef[2] , dt * coef[3] ) );
         }
 };
 
@@ -66,10 +74,13 @@
 template< class Algebra , class Operations >
 struct call_algebra< 5 , Algebra , Operations >
 {
- template< class StateIn , class StateOut , class StepStorage , class Coefficients , class Value >
- void operator()( const StateIn &in , StateOut &out , const StepStorage &steps , const Coefficients &coef , const Value &dt ) const
+ template< class StateIn , class StateOut , class StepStorage , class Coefficients , class Time >
+ void operator()( const StateIn &in , StateOut &out , const StepStorage &steps , const Coefficients &coef , const Time &dt ) const
         {
-
+ typedef typename Coefficients::value_type value_type;
+ Algebra::for_each7( out , in , steps[0] , steps[1] , steps[2] , steps[3] , steps[4] ,
+ typename Operations::template scale_sum6< value_type , Time , Time , Time , Time >(
+ 1.0 , dt * coef[0] , dt * coef[1] , dt * coef[2] , dt * coef[3] , dt * coef[4] ) );
         }
 };
 
@@ -77,10 +88,13 @@
 template< class Algebra , class Operations >
 struct call_algebra< 6 , Algebra , Operations >
 {
- template< class StateIn , class StateOut , class StepStorage , class Coefficients , class Value >
- void operator()( const StateIn &in , StateOut &out , const StepStorage &steps , const Coefficients &coef , const Value &dt ) const
+ template< class StateIn , class StateOut , class StepStorage , class Coefficients , class Time >
+ void operator()( const StateIn &in , StateOut &out , const StepStorage &steps , const Coefficients &coef , const Time &dt ) const
         {
-
+ typedef typename Coefficients::value_type value_type;
+ Algebra::for_each8( out , in , steps[0] , steps[1] , steps[2] , steps[3] , steps[4] , steps[5] ,
+ typename Operations::template scale_sum7< value_type , Time , Time , Time , Time , Time >(
+ 1.0 , dt * coef[0] , dt * coef[1] , dt * coef[2] , dt * coef[3] , dt * coef[4] , dt * coef[5] ) );
         }
 };
 
@@ -88,10 +102,14 @@
 template< class Algebra , class Operations >
 struct call_algebra< 7 , Algebra , Operations >
 {
- template< class StateIn , class StateOut , class StepStorage , class Coefficients , class Value >
- void operator()( const StateIn &in , StateOut &out , const StepStorage &steps , const Coefficients &coef , const Value &dt ) const
+ template< class StateIn , class StateOut , class StepStorage , class Coefficients , class Time >
+ void operator()( const StateIn &in , StateOut &out , const StepStorage &steps , const Coefficients &coef , const Time &dt ) const
         {
-
+ assert( false ); // not implemented
+// typedef typename Coefficients::value_type value_type;
+// Algebra::for_each9( out , in , steps[0] , steps[1] , steps[2] , steps[3] , steps[4] , steps[5] , steps[6]
+// typename Operations::template scale_sum8< value_type , Time , Time , Time , Time , Time , Time >(
+// 1.0 , dt * coef[0] , dt * coef[1] , dt * coef[2] , dt * coef[3] , dt * coef[4] , dt * coef[5] , dt * coef[6] ) );
         }
 };
 
@@ -99,10 +117,14 @@
 template< class Algebra , class Operations >
 struct call_algebra< 8 , Algebra , Operations >
 {
- template< class StateIn , class StateOut , class StepStorage , class Coefficients , class Value >
- void operator()( const StateIn &in , StateOut &out , const StepStorage &steps , const Coefficients &coef , const Value &dt ) const
+ template< class StateIn , class StateOut , class StepStorage , class Coefficients , class Time >
+ void operator()( const StateIn &in , StateOut &out , const StepStorage &steps , const Coefficients &coef , const Time &dt ) const
         {
-
+ assert( false ); // not implemented
+// typedef typename Coefficients::value_type value_type;
+// Algebra::for_each10( out , in , steps[0] , steps[1] , steps[2] , steps[3] , steps[4] , steps[5] , steps[6] , steps[7] ,
+// typename Operations::template scale_sum9< value_type , Time , Time , Time , Time , Time , Time , Time >(
+// 1.0 , dt * coef[0] , dt * coef[1] , dt * coef[2] , dt * coef[3] , dt * coef[4] , dt * coef[5] , dt * coef[6] , dt * coef[7] ) );
         }
 };
 

Added: sandbox/odeint/branches/karsten/boost/numeric/odeint/stepper/detail/adams_moulton_coefficients.hpp
==============================================================================
--- (empty file)
+++ sandbox/odeint/branches/karsten/boost/numeric/odeint/stepper/detail/adams_moulton_coefficients.hpp 2011-05-25 02:22:45 EDT (Wed, 25 May 2011)
@@ -0,0 +1,158 @@
+/*
+ * adam_moulton_coefficients.hpp
+ *
+ * Created on: May 15, 2011
+ * Author: karsten
+ */
+
+#ifndef BOOST_NUMERIC_ODEINT_STEPPER_DETAIL_ADAMS_MOULTON_COEFFICIENTS_HPP_
+#define BOOST_NUMERIC_ODEINT_STEPPER_DETAIL_ADAMS_MOULTON_COEFFICIENTS_HPP_
+
+#include <boost/array.hpp>
+
+
+namespace boost {
+namespace numeric {
+namespace odeint {
+namespace detail {
+
+template< class Value , size_t Steps >
+class adam_moulton_coefficients ;
+
+template< class Value >
+class adam_moulton_coefficients< Value , 1 > : public boost::array< Value , 1 >
+{
+public:
+ adam_moulton_coefficients( void )
+ : boost::array< Value , 1 >()
+ {
+ (*this)[0] = static_cast< Value >( 1.0 );
+ }
+};
+
+
+template< class Value >
+class adam_moulton_coefficients< Value , 2 > : public boost::array< Value , 2 >
+{
+public:
+ adam_moulton_coefficients( void )
+ : boost::array< Value , 2 >()
+ {
+ (*this)[0] = static_cast< Value >( 3.0 ) / static_cast< Value >( 2.0 );
+ (*this)[1] = -static_cast< Value >( 1.0 ) / static_cast< Value >( 2.0 );
+ }
+};
+
+
+template< class Value >
+class adam_moulton_coefficients< Value , 3 > : public boost::array< Value , 3 >
+{
+public:
+ adam_moulton_coefficients( void )
+ : boost::array< Value , 3 >()
+ {
+ (*this)[0] = static_cast< Value >( 23.0 ) / static_cast< Value >( 12.0 );
+ (*this)[1] = -static_cast< Value >( 4.0 ) / static_cast< Value >( 3.0 );
+ (*this)[2] = static_cast< Value >( 5.0 ) / static_cast< Value >( 12.0 );
+ }
+};
+
+
+template< class Value >
+class adam_moulton_coefficients< Value , 4 > : public boost::array< Value , 4 >
+{
+public:
+ adam_moulton_coefficients( void )
+ : boost::array< Value , 4 >()
+ {
+ (*this)[0] = static_cast< Value >( 55.0 ) / static_cast< Value >( 24.0 );
+ (*this)[1] = -static_cast< Value >( 59.0 ) / static_cast< Value >( 24.0 );
+ (*this)[2] = static_cast< Value >( 37.0 ) / static_cast< Value >( 24.0 );
+ (*this)[3] = -static_cast< Value >( 3.0 ) / static_cast< Value >( 8.0 );
+ }
+};
+
+
+template< class Value >
+class adam_moulton_coefficients< Value , 5 > : public boost::array< Value , 5 >
+{
+public:
+ adam_moulton_coefficients( void )
+ : boost::array< Value , 5 >()
+ {
+ (*this)[0] = static_cast< Value >( 1901.0 ) / static_cast< Value >( 720.0 );
+ (*this)[1] = -static_cast< Value >( 1387.0 ) / static_cast< Value >( 360.0 );
+ (*this)[2] = static_cast< Value >( 109.0 ) / static_cast< Value >( 30.0 );
+ (*this)[3] = -static_cast< Value >( 637.0 ) / static_cast< Value >( 360.0 );
+ (*this)[4] = static_cast< Value >( 251.0 ) / static_cast< Value >( 720.0 );
+ }
+};
+
+
+template< class Value >
+class adam_moulton_coefficients< Value , 6 > : public boost::array< Value , 6 >
+{
+public:
+ adam_moulton_coefficients( void )
+ : boost::array< Value , 6 >()
+ {
+ (*this)[0] = static_cast< Value >( 4277.0 ) / static_cast< Value >( 1440.0 );
+ (*this)[1] = -static_cast< Value >( 2641.0 ) / static_cast< Value >( 480.0 );
+ (*this)[2] = static_cast< Value >( 4991.0 ) / static_cast< Value >( 720.0 );
+ (*this)[3] = -static_cast< Value >( 3649.0 ) / static_cast< Value >( 720.0 );
+ (*this)[4] = static_cast< Value >( 959.0 ) / static_cast< Value >( 480.0 );
+ (*this)[5] = -static_cast< Value >( 95.0 ) / static_cast< Value >( 288.0 );
+ }
+};
+
+
+template< class Value >
+class adam_moulton_coefficients< Value , 7 > : public boost::array< Value , 7 >
+{
+public:
+ adam_moulton_coefficients( void )
+ : boost::array< Value , 7 >()
+ {
+ (*this)[0] = static_cast< Value >( 198721.0 ) / static_cast< Value >( 60480.0 );
+ (*this)[1] = -static_cast< Value >( 18637.0 ) / static_cast< Value >( 2520.0 );
+ (*this)[2] = static_cast< Value >( 235183.0 ) / static_cast< Value >( 20160.0 );
+ (*this)[3] = -static_cast< Value >( 10754.0 ) / static_cast< Value >( 945.0 );
+ (*this)[4] = static_cast< Value >( 135713.0 ) / static_cast< Value >( 20160.0 );
+ (*this)[5] = -static_cast< Value >( 5603.0 ) / static_cast< Value >( 2520.0 );
+ (*this)[6] = static_cast< Value >( 19087.0 ) / static_cast< Value >( 60480.0 );
+ }
+};
+
+
+template< class Value >
+class adam_moulton_coefficients< Value , 8 > : public boost::array< Value , 8 >
+{
+public:
+ adam_moulton_coefficients( void )
+ : boost::array< Value , 8 >()
+ {
+ (*this)[0] = static_cast< Value >( 16083.0 ) / static_cast< Value >( 4480.0 );
+ (*this)[1] = -static_cast< Value >( 1152169.0 ) / static_cast< Value >( 120960.0 );
+ (*this)[2] = static_cast< Value >( 242653.0 ) / static_cast< Value >( 13440.0 );
+ (*this)[3] = -static_cast< Value >( 296053.0 ) / static_cast< Value >( 13440.0 );
+ (*this)[4] = static_cast< Value >( 2102243.0 ) / static_cast< Value >( 120960.0 );
+ (*this)[5] = -static_cast< Value >( 115747.0 ) / static_cast< Value >( 13440.0 );
+ (*this)[6] = static_cast< Value >( 32863.0 ) / static_cast< Value >( 13440.0 );
+ (*this)[7] = -static_cast< Value >( 5257.0 ) / static_cast< Value >( 17280.0 );
+ }
+};
+
+
+
+
+
+
+
+} // detail
+} // odeint
+} // numeric
+} // boost
+
+
+
+#endif /* BOOST_NUMERIC_ODEINT_STEPPER_DETAIL_ADAMS_MOULTON_COEFFICIENTS_HPP_ */

Modified: sandbox/odeint/branches/karsten/libs/numeric/odeint/doc/html/index.html
==============================================================================
--- sandbox/odeint/branches/karsten/libs/numeric/odeint/doc/html/index.html (original)
+++ sandbox/odeint/branches/karsten/libs/numeric/odeint/doc/html/index.html 2011-05-25 02:22:45 EDT (Wed, 25 May 2011)
@@ -23,7 +23,7 @@
 </h3></div></div>
 <div><p class="copyright">Copyright &#169; 2009 -2011 Karsten Ahnert and Mario Mulansky</p></div>
 <div><div class="legalnotice">
-<a name="id563812"></a><p>
+<a name="id563836"></a><p>
         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)
       </p>
@@ -108,7 +108,7 @@
 </div>
 </div>
 <table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
-<td align="left"><p><small>Last revised: May 18, 2011 at 12:40:07 GMT</small></p></td>
+<td align="left"><p><small>Last revised: May 21, 2011 at 09:07:12 GMT</small></p></td>
 <td align="right"><div class="copyright-footer"></div></td>
 </tr></table>
 <hr>

Modified: sandbox/odeint/branches/karsten/libs/numeric/odeint/regression_test/Jamfile
==============================================================================
--- sandbox/odeint/branches/karsten/libs/numeric/odeint/regression_test/Jamfile (original)
+++ sandbox/odeint/branches/karsten/libs/numeric/odeint/regression_test/Jamfile 2011-05-25 02:22:45 EDT (Wed, 25 May 2011)
@@ -36,4 +36,8 @@
         
 exe hamiltonian_steppers
         : hamiltonian_steppers.cpp
+ ;
+
+exe adams_bashforth
+ : adams_bashforth.cpp
         ;
\ No newline at end of file

Added: sandbox/odeint/branches/karsten/libs/numeric/odeint/regression_test/adams_bashforth.cpp
==============================================================================
--- (empty file)
+++ sandbox/odeint/branches/karsten/libs/numeric/odeint/regression_test/adams_bashforth.cpp 2011-05-25 02:22:45 EDT (Wed, 25 May 2011)
@@ -0,0 +1,63 @@
+/*
+ * adams_bashforth.cpp
+ *
+ * Created on: May 18, 2011
+ * Author: karsten
+ */
+
+#include <ostream>
+#include <iostream>
+
+#include <boost/array.hpp>
+#include <boost/numeric/odeint/stepper/adams_bashforth.hpp>
+#include <boost/numeric/odeint/integrate/integrate_n_steps.hpp>
+
+using namespace std;
+using namespace boost::numeric::odeint;
+
+typedef double value_type;
+typedef boost::array< value_type , 3 > state_type;
+
+struct lorenz
+{
+ template< class State , class Deriv , class Value >
+ void operator()( const State &_x , Deriv &_dxdt , const Value &dt ) const
+ {
+ const value_type sigma = 10.0;
+ const value_type R = 28.0;
+ const value_type b = 8.0 / 3.0;
+
+ typename boost::range_iterator< const State >::type x = boost::begin( _x );
+ typename boost::range_iterator< Deriv >::type dxdt = boost::begin( _dxdt );
+
+ dxdt[0] = sigma * ( x[1] - x[0] );
+ dxdt[1] = R * x[0] - x[1] - x[0] * x[2];
+ dxdt[2] = x[0]*x[1] - b * x[2];
+ }
+};
+
+struct writing_observer
+{
+ std::ostream &m_out;
+ writing_observer( std::ostream &out ) : m_out( out ) { }
+
+ template< class State , class Value >
+ void operator()( const State &x , const Value &t )
+ {
+ m_out << t << "\t" << x[0] << "\t" << x[1] << "\t" << x[2] << "\n";
+ }
+};
+
+
+int main( int argc , char **argv )
+{
+ state_type x = {{ 10.0 , 10.0 , 10.0 }};
+
+ const double dt = 0.01;
+ double t = 0.0;
+
+ adams_bashforth< 3 , state_type > stepper;
+ stepper.initialize( lorenz() , x , t , dt );
+
+ integrate_n_steps( stepper , lorenz() , x , t , dt , 10000 , writing_observer( cout ) );
+}

Modified: sandbox/odeint/branches/karsten/libs/numeric/odeint/test/adams_bashforth.cpp
==============================================================================
--- sandbox/odeint/branches/karsten/libs/numeric/odeint/test/adams_bashforth.cpp (original)
+++ sandbox/odeint/branches/karsten/libs/numeric/odeint/test/adams_bashforth.cpp 2011-05-25 02:22:45 EDT (Wed, 25 May 2011)
@@ -18,6 +18,11 @@
 
 #include <boost/test/unit_test.hpp>
 
+#include <boost/mpl/list.hpp>
+#include <boost/mpl/size_t.hpp>
+#include <boost/mpl/range_c.hpp>
+
+
 #include <boost/numeric/odeint/stepper/detail/adams_bashforth_coefficients.hpp>
 #include <boost/numeric/odeint/stepper/detail/rotating_buffer.hpp>
 #include <boost/numeric/odeint/stepper/adams_bashforth.hpp>
@@ -99,6 +104,24 @@
         BOOST_CHECK_CLOSE( s1.step_storage()[1][0] , s3.step_storage()[1][0] , 1.0e-14 );
 }
 
+typedef boost::mpl::range_c< size_t , 1 , 6 > vector_of_steps;
+
+BOOST_AUTO_TEST_CASE_TEMPLATE( test_init_and_steps , step_type , vector_of_steps )
+{
+ const static size_t steps = step_type::value;
+ typedef boost::array< value_type , 3 > state_type;
+
+ adams_bashforth< steps , state_type > stepper;
+ state_type x = {{ 10.0 , 10.0 , 10.0 }};
+ const value_type dt = 0.01;
+ value_type t = 0.0;
+
+ stepper.initialize( lorenz() , x , t , dt );
+ BOOST_CHECK_CLOSE( t , value_type( steps - 1 ) * dt , 1.0e-14 );
+
+ stepper.do_step( lorenz() , x , t , dt );
+}
+
 BOOST_AUTO_TEST_CASE( test_instantiation )
 {
         typedef boost::array< double , 3 > state_type;
@@ -119,8 +142,8 @@
         s4.do_step( lorenz() , x , t , dt );
         s5.do_step( lorenz() , x , t , dt );
         s6.do_step( lorenz() , x , t , dt );
- s7.do_step( lorenz() , x , t , dt );
- s8.do_step( lorenz() , x , t , dt );
+// s7.do_step( lorenz() , x , t , dt );
+// s8.do_step( lorenz() , x , t , dt );
 }
 
 


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