Chris@16: /* Chris@16: [auto_generated] Chris@16: boost/numeric/odeint/stepper/adams_moulton.hpp Chris@16: Chris@16: [begin_description] Chris@16: Implementation of the Adams-Moulton method. This is method is not a real stepper, it is more a helper class Chris@16: which computes the corrector step in the Adams-Bashforth-Moulton method. Chris@16: [end_description] Chris@16: Chris@101: Copyright 2011-2012 Karsten Ahnert Chris@101: Copyright 2011-2013 Mario Mulansky Chris@101: Copyright 2012 Christoph Koke Chris@16: Chris@16: Distributed under the Boost Software License, Version 1.0. Chris@16: (See accompanying file LICENSE_1_0.txt or Chris@16: copy at http://www.boost.org/LICENSE_1_0.txt) Chris@16: */ Chris@16: Chris@16: Chris@16: #ifndef BOOST_NUMERIC_ODEINT_STEPPER_ADAMS_MOULTON_HPP_INCLUDED Chris@16: #define BOOST_NUMERIC_ODEINT_STEPPER_ADAMS_MOULTON_HPP_INCLUDED Chris@16: Chris@16: Chris@16: #include Chris@16: Chris@16: #include Chris@16: #include Chris@101: #include Chris@101: #include Chris@16: Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: Chris@16: #include Chris@16: #include Chris@16: Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: Chris@16: Chris@16: Chris@16: Chris@16: namespace boost { Chris@16: namespace numeric { Chris@16: namespace odeint { Chris@16: Chris@16: Chris@16: /* Chris@16: * Static implicit Adams-Moulton multistep-solver without step size control and without dense output. Chris@16: */ Chris@16: template< Chris@16: size_t Steps , Chris@16: class State , Chris@16: class Value = double , Chris@16: class Deriv = State , Chris@16: class Time = Value , Chris@101: class Algebra = typename algebra_dispatcher< State >::algebra_type , Chris@101: class Operations = typename operations_dispatcher< State >::operations_type , Chris@16: class Resizer = initially_resizer Chris@16: > Chris@16: class adams_moulton Chris@16: { Chris@16: private: Chris@16: Chris@16: Chris@16: public : Chris@16: Chris@16: typedef State state_type; Chris@16: typedef state_wrapper< state_type > wrapped_state_type; Chris@16: typedef Value value_type; Chris@16: typedef Deriv deriv_type; Chris@16: typedef state_wrapper< deriv_type > wrapped_deriv_type; Chris@16: typedef Time time_type; Chris@16: typedef Algebra algebra_type; Chris@16: typedef Operations operations_type; Chris@16: typedef Resizer resizer_type; Chris@16: typedef stepper_tag stepper_category; Chris@16: Chris@16: typedef adams_moulton< Steps , State , Value , Deriv , Time , Algebra , Operations , Resizer > stepper_type; Chris@16: Chris@16: static const size_t steps = Steps; Chris@16: Chris@16: typedef unsigned short order_type; Chris@16: static const order_type order_value = steps + 1; Chris@16: Chris@16: typedef detail::rotating_buffer< wrapped_deriv_type , steps > step_storage_type; Chris@16: Chris@16: adams_moulton( ) Chris@16: : m_coefficients() , m_dxdt() , m_resizer() , Chris@16: m_algebra_instance() , m_algebra( m_algebra_instance ) Chris@16: { } Chris@16: Chris@16: adams_moulton( algebra_type &algebra ) Chris@16: : m_coefficients() , m_dxdt() , m_resizer() , Chris@16: m_algebra_instance() , m_algebra( algebra ) Chris@16: { } Chris@16: Chris@16: adams_moulton& operator=( const adams_moulton &stepper ) Chris@16: { Chris@16: m_dxdt = stepper.m_dxdt; Chris@16: m_resizer = stepper.m_resizer; Chris@16: m_algebra = stepper.m_algebra; Chris@16: return *this; Chris@16: } Chris@16: Chris@16: order_type order( void ) const { return order_value; } Chris@16: Chris@16: Chris@16: /* Chris@16: * Version 1 : do_step( system , x , t , dt , buf ); Chris@16: * Chris@16: * solves the forwarding problem Chris@16: */ Chris@101: template< class System , class StateInOut , class StateIn , class ABBuf > Chris@101: void do_step( System system , StateInOut &x , StateIn const & pred , time_type t , time_type dt , const ABBuf &buf ) Chris@16: { Chris@101: do_step( system , x , pred , t , x , dt , buf ); Chris@16: } Chris@16: Chris@101: template< class System , class StateInOut , class StateIn , class ABBuf > Chris@101: void do_step( System system , const StateInOut &x , StateIn const & pred , time_type t , time_type dt , const ABBuf &buf ) Chris@16: { Chris@101: do_step( system , x , pred , t , x , dt , buf ); Chris@16: } Chris@16: Chris@16: Chris@16: Chris@16: /* Chris@16: * Version 2 : do_step( system , in , t , out , dt , buf ); Chris@16: * Chris@16: * solves the forwarding problem Chris@16: */ Chris@101: template< class System , class StateIn , class PredIn , class StateOut , class ABBuf > Chris@101: void do_step( System system , const StateIn &in , const PredIn &pred , time_type t , StateOut &out , time_type dt , const ABBuf &buf ) Chris@16: { Chris@101: do_step_impl( system , in , pred , t , out , dt , buf ); Chris@16: } Chris@16: Chris@101: template< class System , class StateIn , class PredIn , class StateOut , class ABBuf > Chris@101: void do_step( System system , const StateIn &in , const PredIn &pred , time_type t , const StateOut &out , time_type dt , const ABBuf &buf ) Chris@16: { Chris@101: do_step_impl( system , in , pred , t , out , dt , buf ); Chris@16: } Chris@16: Chris@16: Chris@16: Chris@16: template< class StateType > Chris@16: void adjust_size( const StateType &x ) Chris@16: { Chris@16: resize_impl( x ); Chris@16: } Chris@16: Chris@16: algebra_type& algebra() Chris@16: { return m_algebra; } Chris@16: Chris@16: const algebra_type& algebra() const Chris@16: { return m_algebra; } Chris@16: Chris@16: Chris@16: private: Chris@16: Chris@101: Chris@101: template< class System , class StateIn , class PredIn , class StateOut , class ABBuf > Chris@101: void do_step_impl( System system , const StateIn &in , const PredIn &pred , time_type t , StateOut &out , time_type dt , const ABBuf &buf ) Chris@101: { Chris@101: typename odeint::unwrap_reference< System >::type &sys = system; Chris@101: m_resizer.adjust_size( in , detail::bind( &stepper_type::template resize_impl , detail::ref( *this ) , detail::_1 ) ); Chris@101: sys( pred , m_dxdt.m_v , t ); Chris@101: detail::adams_moulton_call_algebra< steps , algebra_type , operations_type >()( m_algebra , in , out , m_dxdt.m_v , buf , m_coefficients , dt ); Chris@101: } Chris@101: Chris@101: Chris@16: template< class StateIn > Chris@16: bool resize_impl( const StateIn &x ) Chris@16: { Chris@16: return adjust_size_by_resizeability( m_dxdt , x , typename is_resizeable::type() ); Chris@16: } Chris@16: Chris@16: Chris@16: const detail::adams_moulton_coefficients< value_type , steps > m_coefficients; Chris@16: wrapped_deriv_type m_dxdt; Chris@16: resizer_type m_resizer; Chris@16: Chris@16: protected: Chris@16: Chris@16: algebra_type m_algebra_instance; Chris@16: algebra_type &m_algebra; Chris@16: }; Chris@16: Chris@16: Chris@16: Chris@16: Chris@16: } // odeint Chris@16: } // numeric Chris@16: } // boost Chris@16: Chris@16: Chris@16: Chris@16: #endif // BOOST_NUMERIC_ODEINT_STEPPER_ADAMS_MOULTON_HPP_INCLUDED