annotate DEPENDENCIES/generic/include/boost/numeric/odeint/stepper/euler.hpp @ 125:34e428693f5d vext

Vext -> Repoint
author Chris Cannam
date Thu, 14 Jun 2018 11:15:39 +0100
parents c530137014c0
children
rev   line source
Chris@16 1 /*
Chris@16 2 [auto_generated]
Chris@16 3 boost/numeric/odeint/stepper/euler.hpp
Chris@16 4
Chris@16 5 [begin_description]
Chris@16 6 Implementation of the classical explicit Euler stepper. This method is really simple and should only
Chris@16 7 be used for demonstration purposes.
Chris@16 8 [end_description]
Chris@16 9
Chris@101 10 Copyright 2010-2013 Karsten Ahnert
Chris@101 11 Copyright 2010-2013 Mario Mulansky
Chris@16 12
Chris@16 13 Distributed under the Boost Software License, Version 1.0.
Chris@16 14 (See accompanying file LICENSE_1_0.txt or
Chris@16 15 copy at http://www.boost.org/LICENSE_1_0.txt)
Chris@16 16 */
Chris@16 17
Chris@16 18
Chris@16 19 #ifndef BOOST_NUMERIC_ODEINT_STEPPER_EULER_HPP_INCLUDED
Chris@16 20 #define BOOST_NUMERIC_ODEINT_STEPPER_EULER_HPP_INCLUDED
Chris@16 21
Chris@16 22
Chris@16 23 #include <boost/numeric/odeint/stepper/base/explicit_stepper_base.hpp>
Chris@16 24 #include <boost/numeric/odeint/util/resizer.hpp>
Chris@16 25 #include <boost/numeric/odeint/algebra/range_algebra.hpp>
Chris@16 26 #include <boost/numeric/odeint/algebra/default_operations.hpp>
Chris@101 27 #include <boost/numeric/odeint/algebra/algebra_dispatcher.hpp>
Chris@101 28 #include <boost/numeric/odeint/algebra/operations_dispatcher.hpp>
Chris@16 29
Chris@16 30 namespace boost {
Chris@16 31 namespace numeric {
Chris@16 32 namespace odeint {
Chris@16 33
Chris@16 34
Chris@16 35 template<
Chris@16 36 class State ,
Chris@16 37 class Value = double ,
Chris@16 38 class Deriv = State ,
Chris@16 39 class Time = Value ,
Chris@101 40 class Algebra = typename algebra_dispatcher< State >::algebra_type ,
Chris@101 41 class Operations = typename operations_dispatcher< State >::operations_type ,
Chris@16 42 class Resizer = initially_resizer
Chris@16 43 >
Chris@16 44 #ifndef DOXYGEN_SKIP
Chris@16 45 class euler
Chris@16 46 : public explicit_stepper_base<
Chris@16 47 euler< State , Value , Deriv , Time , Algebra , Operations , Resizer > ,
Chris@16 48 1 , State , Value , Deriv , Time , Algebra , Operations , Resizer >
Chris@16 49 #else
Chris@16 50 class euler : public explicit_stepper_base
Chris@16 51 #endif
Chris@16 52 {
Chris@16 53 public :
Chris@16 54
Chris@16 55 #ifndef DOXYGEN_SKIP
Chris@16 56 typedef explicit_stepper_base< euler< State , Value , Deriv , Time , Algebra , Operations , Resizer > , 1 , State , Value , Deriv , Time , Algebra , Operations , Resizer > stepper_base_type;
Chris@16 57 #else
Chris@16 58 typedef explicit_stepper_base< euler< ... > , ... > stepper_base_type;
Chris@16 59 #endif
Chris@16 60 typedef typename stepper_base_type::state_type state_type;
Chris@16 61 typedef typename stepper_base_type::value_type value_type;
Chris@16 62 typedef typename stepper_base_type::deriv_type deriv_type;
Chris@16 63 typedef typename stepper_base_type::time_type time_type;
Chris@16 64 typedef typename stepper_base_type::algebra_type algebra_type;
Chris@16 65 typedef typename stepper_base_type::operations_type operations_type;
Chris@16 66 typedef typename stepper_base_type::resizer_type resizer_type;
Chris@16 67
Chris@16 68 #ifndef DOXYGEN_SKIP
Chris@16 69 typedef typename stepper_base_type::stepper_type stepper_type;
Chris@16 70 typedef typename stepper_base_type::wrapped_state_type wrapped_state_type;
Chris@16 71 typedef typename stepper_base_type::wrapped_deriv_type wrapped_deriv_type;
Chris@16 72 #endif
Chris@16 73
Chris@16 74
Chris@16 75 euler( const algebra_type &algebra = algebra_type() ) : stepper_base_type( algebra )
Chris@16 76 { }
Chris@16 77
Chris@16 78 template< class System , class StateIn , class DerivIn , class StateOut >
Chris@101 79 void do_step_impl( System /* system */ , const StateIn &in , const DerivIn &dxdt , time_type /* t */ , StateOut &out , time_type dt )
Chris@16 80 {
Chris@16 81 stepper_base_type::m_algebra.for_each3( out , in , dxdt ,
Chris@16 82 typename operations_type::template scale_sum2< value_type , time_type >( 1.0 , dt ) );
Chris@16 83
Chris@16 84 }
Chris@16 85
Chris@16 86 template< class StateOut , class StateIn1 , class StateIn2 >
Chris@101 87 void calc_state( StateOut &x , time_type t , const StateIn1 &old_state , time_type t_old , const StateIn2 & /*current_state*/ , time_type /* t_new */ ) const
Chris@16 88 {
Chris@16 89 const time_type delta = t - t_old;
Chris@16 90 stepper_base_type::m_algebra.for_each3( x , old_state , stepper_base_type::m_dxdt.m_v ,
Chris@16 91 typename operations_type::template scale_sum2< value_type , time_type >( 1.0 , delta ) );
Chris@16 92 }
Chris@16 93
Chris@16 94 template< class StateType >
Chris@16 95 void adjust_size( const StateType &x )
Chris@16 96 {
Chris@16 97 stepper_base_type::adjust_size( x );
Chris@16 98 }
Chris@16 99 };
Chris@16 100
Chris@16 101
Chris@16 102
Chris@16 103 /********** DOXYGEN ***********/
Chris@16 104
Chris@16 105 /**
Chris@16 106 * \class euler
Chris@16 107 * \brief An implementation of the Euler method.
Chris@16 108 *
Chris@16 109 * The Euler method is a very simply solver for ordinary differential equations. This method should not be used
Chris@16 110 * for real applications. It is only useful for demonstration purposes. Step size control is not provided but
Chris@16 111 * trivial continuous output is available.
Chris@16 112 *
Chris@16 113 * This class derives from explicit_stepper_base and inherits its interface via CRTP (current recurring template pattern),
Chris@16 114 * see explicit_stepper_base
Chris@16 115 *
Chris@16 116 * \tparam State The state type.
Chris@16 117 * \tparam Value The value type.
Chris@16 118 * \tparam Deriv The type representing the time derivative of the state.
Chris@16 119 * \tparam Time The time representing the independent variable - the time.
Chris@16 120 * \tparam Algebra The algebra type.
Chris@16 121 * \tparam Operations The operations type.
Chris@16 122 * \tparam Resizer The resizer policy type.
Chris@16 123 */
Chris@16 124
Chris@16 125 /**
Chris@16 126 * \fn euler::euler( const algebra_type &algebra )
Chris@16 127 * \brief Constructs the euler class. This constructor can be used as a default
Chris@16 128 * constructor of the algebra has a default constructor.
Chris@16 129 * \param algebra A copy of algebra is made and stored inside explicit_stepper_base.
Chris@16 130 */
Chris@16 131
Chris@16 132 /**
Chris@16 133 * \fn euler::do_step_impl( System system , const StateIn &in , const DerivIn &dxdt , time_type t , StateOut &out , time_type dt )
Chris@16 134 * \brief This method performs one step. The derivative `dxdt` of `in` at the time `t` is passed to the method.
Chris@16 135 * The result is updated out of place, hence the input is in `in` and the output in `out`.
Chris@16 136 * Access to this step functionality is provided by explicit_stepper_base and
Chris@16 137 * `do_step_impl` should not be called directly.
Chris@16 138 *
Chris@16 139 * \param system The system function to solve, hence the r.h.s. of the ODE. It must fulfill the
Chris@16 140 * Simple System concept.
Chris@16 141 * \param in The state of the ODE which should be solved. in is not modified in this method
Chris@16 142 * \param dxdt The derivative of x at t.
Chris@16 143 * \param t The value of the time, at which the step should be performed.
Chris@16 144 * \param out The result of the step is written in out.
Chris@16 145 * \param dt The step size.
Chris@16 146 */
Chris@16 147
Chris@16 148
Chris@16 149 /**
Chris@16 150 * \fn euler::calc_state( StateOut &x , time_type t , const StateIn1 &old_state , time_type t_old , const StateIn2 &current_state , time_type t_new ) const
Chris@16 151 * \brief This method is used for continuous output and it calculates the state `x` at a time `t` from the
Chris@16 152 * knowledge of two states `old_state` and `current_state` at time points `t_old` and `t_new`.
Chris@16 153 */
Chris@16 154
Chris@16 155 /**
Chris@16 156 * \fn euler::adjust_size( const StateType &x )
Chris@16 157 * \brief Adjust the size of all temporaries in the stepper manually.
Chris@16 158 * \param x A state from which the size of the temporaries to be resized is deduced.
Chris@16 159 */
Chris@16 160
Chris@16 161 } // odeint
Chris@16 162 } // numeric
Chris@16 163 } // boost
Chris@16 164
Chris@16 165
Chris@16 166 #endif // BOOST_NUMERIC_ODEINT_STEPPER_EULER_HPP_INCLUDED