123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415 |
- #ifndef BOOST_NUMERIC_ODEINT_STEPPER_BASE_EXPLICIT_STEPPER_BASE_HPP_INCLUDED
- #define BOOST_NUMERIC_ODEINT_STEPPER_BASE_EXPLICIT_STEPPER_BASE_HPP_INCLUDED
- #include <boost/utility/enable_if.hpp>
- #include <boost/type_traits/is_same.hpp>
- #include <boost/numeric/odeint/util/bind.hpp>
- #include <boost/numeric/odeint/util/unwrap_reference.hpp>
- #include <boost/numeric/odeint/util/state_wrapper.hpp>
- #include <boost/numeric/odeint/util/resizer.hpp>
- #include <boost/numeric/odeint/util/is_resizeable.hpp>
- #include <boost/numeric/odeint/stepper/stepper_categories.hpp>
- #include <boost/numeric/odeint/stepper/base/algebra_stepper_base.hpp>
- namespace boost {
- namespace numeric {
- namespace odeint {
- template<
- class Stepper ,
- unsigned short Order ,
- class State ,
- class Value ,
- class Deriv ,
- class Time ,
- class Algebra ,
- class Operations ,
- class Resizer
- >
- class explicit_stepper_base : public algebra_stepper_base< Algebra , Operations >
- {
- public:
- #ifndef DOXYGEN_SKIP
- typedef explicit_stepper_base< Stepper , Order , State , Value , Deriv , Time , Algebra , Operations , Resizer > internal_stepper_base_type;
- #endif
- typedef State state_type;
- typedef Value value_type;
- typedef Deriv deriv_type;
- typedef Time time_type;
- typedef Resizer resizer_type;
- typedef Stepper stepper_type;
- typedef stepper_tag stepper_category;
- typedef algebra_stepper_base< Algebra , Operations > algebra_stepper_base_type;
- typedef typename algebra_stepper_base_type::algebra_type algebra_type;
- typedef typename algebra_stepper_base_type::operations_type operations_type;
- typedef unsigned short order_type;
- #ifndef DOXYGEN_SKIP
- typedef state_wrapper< state_type > wrapped_state_type;
- typedef state_wrapper< deriv_type > wrapped_deriv_type;
- #endif
- static const order_type order_value = Order;
- explicit_stepper_base( const algebra_type &algebra = algebra_type() )
- : algebra_stepper_base_type( algebra )
- { }
-
- order_type order( void ) const
- {
- return order_value;
- }
-
- template< class System , class StateInOut >
- void do_step( System system , StateInOut &x , time_type t , time_type dt )
- {
- do_step_v1( system , x , t , dt );
- }
-
- template< class System , class StateInOut >
- void do_step( System system , const StateInOut &x , time_type t , time_type dt )
- {
- do_step_v1( system , x , t , dt );
- }
-
- template< class System , class StateInOut , class DerivIn >
- typename boost::disable_if< boost::is_same< DerivIn , time_type > , void >::type
- do_step( System system , StateInOut &x , const DerivIn &dxdt , time_type t , time_type dt )
- {
- this->stepper().do_step_impl( system , x , dxdt , t , x , dt );
- }
-
- template < class System, class StateInOut, class DerivIn >
- void do_step_dxdt_impl( System system, StateInOut &x, const DerivIn &dxdt,
- time_type t, time_type dt )
- {
- this->stepper().do_step_impl( system , x , dxdt , t , x , dt );
- }
-
- template< class System , class StateIn , class StateOut >
- void do_step( System system , const StateIn &in , time_type t , StateOut &out , time_type dt )
- {
- typename odeint::unwrap_reference< System >::type &sys = system;
- m_resizer.adjust_size(in, [this](auto&& arg) { return this->resize_impl<StateIn>(std::forward<decltype(arg)>(arg)); });
- sys( in , m_dxdt.m_v ,t );
- this->stepper().do_step_impl( system , in , m_dxdt.m_v , t , out , dt );
- }
-
- template< class System , class StateIn , class DerivIn , class StateOut >
- void do_step( System system , const StateIn &in , const DerivIn &dxdt , time_type t , StateOut &out , time_type dt )
- {
- this->stepper().do_step_impl( system , in , dxdt , t , out , dt );
- }
-
- template < class System, class StateIn, class DerivIn, class StateOut >
- void do_step_dxdt_impl( System system, const StateIn &in,
- const DerivIn &dxdt, time_type t, StateOut &out,
- time_type dt )
- {
- this->stepper().do_step_impl( system , in , dxdt , t , out , dt );
- }
- template< class StateIn >
- void adjust_size( const StateIn &x )
- {
- resize_impl( x );
- }
- private:
- stepper_type& stepper( void )
- {
- return *static_cast< stepper_type* >( this );
- }
- const stepper_type& stepper( void ) const
- {
- return *static_cast< const stepper_type* >( this );
- }
- template< class StateIn >
- bool resize_impl( const StateIn &x )
- {
- return adjust_size_by_resizeability( m_dxdt , x , typename is_resizeable<deriv_type>::type() );
- }
- template< class System , class StateInOut >
- void do_step_v1( System system , StateInOut &x , time_type t , time_type dt )
- {
- typename odeint::unwrap_reference< System >::type &sys = system;
- m_resizer.adjust_size(x, [this](auto&& arg) { return this->resize_impl<StateInOut>(std::forward<decltype(arg)>(arg)); });
- sys( x , m_dxdt.m_v ,t );
- this->stepper().do_step_impl( system , x , m_dxdt.m_v , t , x , dt );
- }
- resizer_type m_resizer;
- protected:
- wrapped_deriv_type m_dxdt;
- };
-
-
-
-
-
-
-
- }
- }
- }
- #endif
|