File indexing completed on 2025-01-18 09:42:56
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019 #ifndef BOOST_NUMERIC_ODEINT_STEPPER_EULER_HPP_INCLUDED
0020 #define BOOST_NUMERIC_ODEINT_STEPPER_EULER_HPP_INCLUDED
0021
0022
0023 #include <boost/numeric/odeint/stepper/base/explicit_stepper_base.hpp>
0024 #include <boost/numeric/odeint/util/resizer.hpp>
0025 #include <boost/numeric/odeint/algebra/range_algebra.hpp>
0026 #include <boost/numeric/odeint/algebra/default_operations.hpp>
0027 #include <boost/numeric/odeint/algebra/algebra_dispatcher.hpp>
0028 #include <boost/numeric/odeint/algebra/operations_dispatcher.hpp>
0029
0030 namespace boost {
0031 namespace numeric {
0032 namespace odeint {
0033
0034
0035 template<
0036 class State ,
0037 class Value = double ,
0038 class Deriv = State ,
0039 class Time = Value ,
0040 class Algebra = typename algebra_dispatcher< State >::algebra_type ,
0041 class Operations = typename operations_dispatcher< State >::operations_type ,
0042 class Resizer = initially_resizer
0043 >
0044 #ifndef DOXYGEN_SKIP
0045 class euler
0046 : public explicit_stepper_base<
0047 euler< State , Value , Deriv , Time , Algebra , Operations , Resizer > ,
0048 1 , State , Value , Deriv , Time , Algebra , Operations , Resizer >
0049 #else
0050 class euler : public explicit_stepper_base
0051 #endif
0052 {
0053 public :
0054
0055 #ifndef DOXYGEN_SKIP
0056 typedef explicit_stepper_base< euler< State , Value , Deriv , Time , Algebra , Operations , Resizer > , 1 , State , Value , Deriv , Time , Algebra , Operations , Resizer > stepper_base_type;
0057 #else
0058 typedef explicit_stepper_base< euler< ... > , ... > stepper_base_type;
0059 #endif
0060 typedef typename stepper_base_type::state_type state_type;
0061 typedef typename stepper_base_type::value_type value_type;
0062 typedef typename stepper_base_type::deriv_type deriv_type;
0063 typedef typename stepper_base_type::time_type time_type;
0064 typedef typename stepper_base_type::algebra_type algebra_type;
0065 typedef typename stepper_base_type::operations_type operations_type;
0066 typedef typename stepper_base_type::resizer_type resizer_type;
0067
0068 #ifndef DOXYGEN_SKIP
0069 typedef typename stepper_base_type::stepper_type stepper_type;
0070 typedef typename stepper_base_type::wrapped_state_type wrapped_state_type;
0071 typedef typename stepper_base_type::wrapped_deriv_type wrapped_deriv_type;
0072 #endif
0073
0074
0075 euler( const algebra_type &algebra = algebra_type() ) : stepper_base_type( algebra )
0076 { }
0077
0078 template< class System , class StateIn , class DerivIn , class StateOut >
0079 void do_step_impl( System , const StateIn &in , const DerivIn &dxdt , time_type , StateOut &out , time_type dt )
0080 {
0081 stepper_base_type::m_algebra.for_each3( out , in , dxdt ,
0082 typename operations_type::template scale_sum2< value_type , time_type >( 1.0 , dt ) );
0083
0084 }
0085
0086 template< class StateOut , class StateIn1 , class StateIn2 >
0087 void calc_state( StateOut &x , time_type t , const StateIn1 &old_state , time_type t_old , const StateIn2 & , time_type ) const
0088 {
0089 const time_type delta = t - t_old;
0090 stepper_base_type::m_algebra.for_each3( x , old_state , stepper_base_type::m_dxdt.m_v ,
0091 typename operations_type::template scale_sum2< value_type , time_type >( 1.0 , delta ) );
0092 }
0093
0094 template< class StateType >
0095 void adjust_size( const StateType &x )
0096 {
0097 stepper_base_type::adjust_size( x );
0098 }
0099 };
0100
0101
0102
0103
0104
0105
0106
0107
0108
0109
0110
0111
0112
0113
0114
0115
0116
0117
0118
0119
0120
0121
0122
0123
0124
0125
0126
0127
0128
0129
0130
0131
0132
0133
0134
0135
0136
0137
0138
0139
0140
0141
0142
0143
0144
0145
0146
0147
0148
0149
0150
0151
0152
0153
0154
0155
0156
0157
0158
0159
0160
0161 }
0162 }
0163 }
0164
0165
0166 #endif