comparison DEPENDENCIES/generic/include/boost/numeric/odeint/stepper/euler.hpp @ 16:2665513ce2d3

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