Mercurial > hg > vamp-build-and-test
comparison DEPENDENCIES/generic/include/boost/numeric/odeint/stepper/runge_kutta4.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/runge_kutta4.hpp | |
4 | |
5 [begin_description] | |
6 Implementation of the classical Runge-Kutta stepper with the generic stepper. | |
7 [end_description] | |
8 | |
9 Copyright 2009-2011 Karsten Ahnert | |
10 Copyright 2009-2011 Mario Mulansky | |
11 | |
12 Distributed under the Boost Software License, Version 1.0. | |
13 (See accompanying file LICENSE_1_0.txt or | |
14 copy at http://www.boost.org/LICENSE_1_0.txt) | |
15 */ | |
16 | |
17 | |
18 #ifndef BOOST_NUMERIC_ODEINT_STEPPER_RUNGE_KUTTA4_HPP_INCLUDED | |
19 #define BOOST_NUMERIC_ODEINT_STEPPER_RUNGE_KUTTA4_HPP_INCLUDED | |
20 | |
21 | |
22 | |
23 | |
24 #include <boost/fusion/container/vector.hpp> | |
25 #include <boost/fusion/container/generation/make_vector.hpp> | |
26 | |
27 #include <boost/numeric/odeint/stepper/explicit_generic_rk.hpp> | |
28 #include <boost/numeric/odeint/algebra/range_algebra.hpp> | |
29 #include <boost/numeric/odeint/algebra/default_operations.hpp> | |
30 | |
31 #include <boost/array.hpp> | |
32 | |
33 #include <boost/numeric/odeint/util/resizer.hpp> | |
34 | |
35 | |
36 | |
37 namespace boost { | |
38 namespace numeric { | |
39 namespace odeint { | |
40 | |
41 #ifndef DOXYGEN_SKIP | |
42 template< class Value = double > | |
43 struct rk4_coefficients_a1 : boost::array< Value , 1 > | |
44 { | |
45 rk4_coefficients_a1( void ) | |
46 { | |
47 (*this)[0] = static_cast< Value >( 1 ) / static_cast< Value >( 2 ); | |
48 } | |
49 }; | |
50 | |
51 template< class Value = double > | |
52 struct rk4_coefficients_a2 : boost::array< Value , 2 > | |
53 { | |
54 rk4_coefficients_a2( void ) | |
55 { | |
56 (*this)[0] = static_cast<Value>(0); | |
57 (*this)[1] = static_cast< Value >( 1 ) / static_cast< Value >( 2 ); | |
58 } | |
59 }; | |
60 | |
61 | |
62 template< class Value = double > | |
63 struct rk4_coefficients_a3 : boost::array< Value , 3 > | |
64 { | |
65 rk4_coefficients_a3( void ) | |
66 { | |
67 (*this)[0] = static_cast<Value>(0); | |
68 (*this)[1] = static_cast<Value>(0); | |
69 (*this)[2] = static_cast<Value>(1); | |
70 } | |
71 }; | |
72 | |
73 template< class Value = double > | |
74 struct rk4_coefficients_b : boost::array< Value , 4 > | |
75 { | |
76 rk4_coefficients_b( void ) | |
77 { | |
78 (*this)[0] = static_cast<Value>(1)/static_cast<Value>(6); | |
79 (*this)[1] = static_cast<Value>(1)/static_cast<Value>(3); | |
80 (*this)[2] = static_cast<Value>(1)/static_cast<Value>(3); | |
81 (*this)[3] = static_cast<Value>(1)/static_cast<Value>(6); | |
82 } | |
83 }; | |
84 | |
85 template< class Value = double > | |
86 struct rk4_coefficients_c : boost::array< Value , 4 > | |
87 { | |
88 rk4_coefficients_c( void ) | |
89 { | |
90 (*this)[0] = static_cast<Value>(0); | |
91 (*this)[1] = static_cast< Value >( 1 ) / static_cast< Value >( 2 ); | |
92 (*this)[2] = static_cast< Value >( 1 ) / static_cast< Value >( 2 ); | |
93 (*this)[3] = static_cast<Value>(1); | |
94 } | |
95 }; | |
96 #endif | |
97 | |
98 | |
99 | |
100 template< | |
101 class State , | |
102 class Value = double , | |
103 class Deriv = State , | |
104 class Time = Value , | |
105 class Algebra = range_algebra , | |
106 class Operations = default_operations , | |
107 class Resizer = initially_resizer | |
108 > | |
109 #ifndef DOXYGEN_SKIP | |
110 class runge_kutta4 : public explicit_generic_rk< 4 , 4 , State , Value , Deriv , Time , | |
111 Algebra , Operations , Resizer > | |
112 #else | |
113 class runge_kutta4 : public explicit_generic_rk | |
114 #endif | |
115 { | |
116 | |
117 public: | |
118 | |
119 #ifndef DOXYGEN_SKIP | |
120 typedef explicit_generic_rk< 4 , 4 , State , Value , Deriv , Time , | |
121 Algebra , Operations , Resizer > stepper_base_type; | |
122 #endif | |
123 typedef typename stepper_base_type::state_type state_type; | |
124 typedef typename stepper_base_type::value_type value_type; | |
125 typedef typename stepper_base_type::deriv_type deriv_type; | |
126 typedef typename stepper_base_type::time_type time_type; | |
127 typedef typename stepper_base_type::algebra_type algebra_type; | |
128 typedef typename stepper_base_type::operations_type operations_type; | |
129 typedef typename stepper_base_type::resizer_type resizer_type; | |
130 | |
131 #ifndef DOXYGEN_SKIP | |
132 typedef typename stepper_base_type::wrapped_state_type wrapped_state_type; | |
133 typedef typename stepper_base_type::wrapped_deriv_type wrapped_deriv_type; | |
134 typedef typename stepper_base_type::stepper_type stepper_type; | |
135 #endif | |
136 | |
137 runge_kutta4( const algebra_type &algebra = algebra_type() ) : stepper_base_type( | |
138 boost::fusion::make_vector( rk4_coefficients_a1<Value>() , rk4_coefficients_a2<Value>() , rk4_coefficients_a3<Value>() ) , | |
139 rk4_coefficients_b<Value>() , rk4_coefficients_c<Value>() , algebra ) | |
140 { } | |
141 | |
142 }; | |
143 | |
144 /** | |
145 * \class runge_kutta4 | |
146 * \brief The classical Runge-Kutta stepper of fourth order. | |
147 * | |
148 * The Runge-Kutta method of fourth order is one standard method for | |
149 * solving ordinary differential equations and is widely used, see also | |
150 * <a href="http://en.wikipedia.org/wiki/Runge%E2%80%93Kutta_methods">en.wikipedia.org/wiki/Runge-Kutta_methods</a> | |
151 * The method is explicit and fulfills the Stepper concept. Step size control | |
152 * or continuous output are not provided. | |
153 * | |
154 * This class derives from explicit_stepper_base and inherits its interface via CRTP (current recurring template pattern). | |
155 * Furthermore, it derivs from explicit_generic_rk which is a generic Runge-Kutta algorithm. For more details see | |
156 * explicit_stepper_base and explicit_generic_rk. | |
157 * | |
158 * \tparam State The state type. | |
159 * \tparam Value The value type. | |
160 * \tparam Deriv The type representing the time derivative of the state. | |
161 * \tparam Time The time representing the independent variable - the time. | |
162 * \tparam Algebra The algebra type. | |
163 * \tparam Operations The operations type. | |
164 * \tparam Resizer The resizer policy type. | |
165 */ | |
166 | |
167 /** | |
168 * \fn runge_kutta4::runge_kutta4( const algebra_type &algebra = algebra_type() ) | |
169 * \brief Constructs the runge_kutta4 class. This constructor can be used as a default | |
170 * constructor if the algebra has a default constructor. | |
171 * \param algebra A copy of algebra is made and stored inside explicit_stepper_base. | |
172 */ | |
173 | |
174 } | |
175 } | |
176 } | |
177 | |
178 | |
179 #endif // BOOST_NUMERIC_ODEINT_STEPPER_RUNGE_KUTTA4_HPP_INCLUDED |