Imported Upstream version 1.72.0
[platform/upstream/boost.git] / libs / numeric / odeint / doc / html / boost / numeric / odeint / runge_kutta4.html
1 <html>
2 <head>
3 <meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
4 <title>Class template runge_kutta4</title>
5 <link rel="stylesheet" href="../../../../../../../../doc/src/boostbook.css" type="text/css">
6 <meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
7 <link rel="home" href="../../../index.html" title="Chapter&#160;1.&#160;Boost.Numeric.Odeint">
8 <link rel="up" href="../../../header/boost/numeric/odeint/stepper/runge_kutta4_hpp.html" title="Header &lt;boost/numeric/odeint/stepper/runge_kutta4.hpp&gt;">
9 <link rel="prev" href="../../../header/boost/numeric/odeint/stepper/runge_kutta4_hpp.html" title="Header &lt;boost/numeric/odeint/stepper/runge_kutta4.hpp&gt;">
10 <link rel="next" href="../../../header/boost/numeric/odeint/stepper/runge_kutta4_classic_hpp.html" title="Header &lt;boost/numeric/odeint/stepper/runge_kutta4_classic.hpp&gt;">
11 </head>
12 <body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
13 <table cellpadding="2" width="100%"><tr>
14 <td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../logo.jpg"></td>
15 <td align="center"><a href="../../../../../../../../index.html">Home</a></td>
16 <td align="center"><a href="../../../../../../../../libs/libraries.htm">Libraries</a></td>
17 <td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
18 <td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
19 <td align="center"><a href="../../../../../../../../more/index.htm">More</a></td>
20 </tr></table>
21 <hr>
22 <div class="spirit-nav">
23 <a accesskey="p" href="../../../header/boost/numeric/odeint/stepper/runge_kutta4_hpp.html"><img src="../../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../../../header/boost/numeric/odeint/stepper/runge_kutta4_hpp.html"><img src="../../../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../../index.html"><img src="../../../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="../../../header/boost/numeric/odeint/stepper/runge_kutta4_classic_hpp.html"><img src="../../../../../../../../doc/src/images/next.png" alt="Next"></a>
24 </div>
25 <div class="refentry">
26 <a name="boost.numeric.odeint.runge_kutta4"></a><div class="titlepage"></div>
27 <div class="refnamediv">
28 <h2><span class="refentrytitle">Class template runge_kutta4</span></h2>
29 <p>boost::numeric::odeint::runge_kutta4 &#8212; The classical Runge-Kutta stepper of fourth order. </p>
30 </div>
31 <h2 xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="refsynopsisdiv-title">Synopsis</h2>
32 <div xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="refsynopsisdiv"><pre class="synopsis"><span class="comment">// In header: &lt;<a class="link" href="../../../header/boost/numeric/odeint/stepper/runge_kutta4_hpp.html" title="Header &lt;boost/numeric/odeint/stepper/runge_kutta4.hpp&gt;">boost/numeric/odeint/stepper/runge_kutta4.hpp</a>&gt;
33
34 </span><span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">typename</span> State<span class="special">,</span> <span class="keyword">typename</span> Value <span class="special">=</span> <span class="keyword">double</span><span class="special">,</span> <span class="keyword">typename</span> Deriv <span class="special">=</span> <span class="identifier">State</span><span class="special">,</span> 
35          <span class="keyword">typename</span> Time <span class="special">=</span> <span class="identifier">Value</span><span class="special">,</span> 
36          <span class="keyword">typename</span> Algebra <span class="special">=</span> <span class="keyword">typename</span> <span class="identifier">algebra_dispatcher</span><span class="special">&lt;</span> <span class="identifier">State</span> <span class="special">&gt;</span><span class="special">::</span><span class="identifier">algebra_type</span><span class="special">,</span> 
37          <span class="keyword">typename</span> Operations <span class="special">=</span> <span class="keyword">typename</span> <span class="identifier">operations_dispatcher</span><span class="special">&lt;</span> <span class="identifier">State</span> <span class="special">&gt;</span><span class="special">::</span><span class="identifier">operations_type</span><span class="special">,</span> 
38          <span class="keyword">typename</span> Resizer <span class="special">=</span> <span class="identifier">initially_resizer</span><span class="special">&gt;</span> 
39 <span class="keyword">class</span> <a class="link" href="runge_kutta4.html" title="Class template runge_kutta4">runge_kutta4</a> <span class="special">:</span> <span class="keyword">public</span> boost::numeric::odeint::explicit_generic_rk&lt; StageCount, Order, State, Value, Deriv, Time, Algebra, Operations, Resizer &gt;
40 <span class="special">{</span>
41 <span class="keyword">public</span><span class="special">:</span>
42   <span class="comment">// types</span>
43   <span class="keyword">typedef</span> <span class="identifier">stepper_base_type</span><span class="special">::</span><span class="identifier">state_type</span>      <a name="boost.numeric.odeint.runge_kutta4.state_type"></a><span class="identifier">state_type</span><span class="special">;</span>     
44   <span class="keyword">typedef</span> <span class="identifier">stepper_base_type</span><span class="special">::</span><span class="identifier">value_type</span>      <a name="boost.numeric.odeint.runge_kutta4.value_type"></a><span class="identifier">value_type</span><span class="special">;</span>     
45   <span class="keyword">typedef</span> <span class="identifier">stepper_base_type</span><span class="special">::</span><span class="identifier">deriv_type</span>      <a name="boost.numeric.odeint.runge_kutta4.deriv_type"></a><span class="identifier">deriv_type</span><span class="special">;</span>     
46   <span class="keyword">typedef</span> <span class="identifier">stepper_base_type</span><span class="special">::</span><span class="identifier">time_type</span>       <a name="boost.numeric.odeint.runge_kutta4.time_type"></a><span class="identifier">time_type</span><span class="special">;</span>      
47   <span class="keyword">typedef</span> <span class="identifier">stepper_base_type</span><span class="special">::</span><span class="identifier">algebra_type</span>    <a name="boost.numeric.odeint.runge_kutta4.algebra_type"></a><span class="identifier">algebra_type</span><span class="special">;</span>   
48   <span class="keyword">typedef</span> <span class="identifier">stepper_base_type</span><span class="special">::</span><span class="identifier">operations_type</span> <a name="boost.numeric.odeint.runge_kutta4.operations_type"></a><span class="identifier">operations_type</span><span class="special">;</span>
49   <span class="keyword">typedef</span> <span class="identifier">stepper_base_type</span><span class="special">::</span><span class="identifier">resizer_type</span>    <a name="boost.numeric.odeint.runge_kutta4.resizer_type"></a><span class="identifier">resizer_type</span><span class="special">;</span>   
50
51   <span class="comment">// <a class="link" href="runge_kutta4.html#boost.numeric.odeint.runge_kutta4construct-copy-destruct">construct/copy/destruct</a></span>
52   <a class="link" href="runge_kutta4.html#idm45853738841952-bb"><span class="identifier">runge_kutta4</span></a><span class="special">(</span><span class="keyword">const</span> <span class="identifier">algebra_type</span> <span class="special">&amp;</span> <span class="special">=</span> <span class="identifier">algebra_type</span><span class="special">(</span><span class="special">)</span><span class="special">)</span><span class="special">;</span>
53
54   <span class="comment">// <a class="link" href="runge_kutta4.html#idm45853738860096-bb">public member functions</a></span>
55   <span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">typename</span> System<span class="special">,</span> <span class="keyword">typename</span> StateIn<span class="special">,</span> <span class="keyword">typename</span> DerivIn<span class="special">,</span> 
56            <span class="keyword">typename</span> StateOut<span class="special">&gt;</span> 
57     <span class="keyword">void</span> <a class="link" href="runge_kutta4.html#idm45853738859536-bb"><span class="identifier">do_step_impl</span></a><span class="special">(</span><span class="identifier">System</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">StateIn</span> <span class="special">&amp;</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">DerivIn</span> <span class="special">&amp;</span><span class="special">,</span> <span class="identifier">time_type</span><span class="special">,</span> 
58                       <span class="identifier">StateOut</span> <span class="special">&amp;</span><span class="special">,</span> <span class="identifier">time_type</span><span class="special">)</span><span class="special">;</span>
59   <span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">typename</span> StateIn<span class="special">&gt;</span> <span class="keyword">void</span> <a class="link" href="runge_kutta4.html#idm45853738845728-bb"><span class="identifier">adjust_size</span></a><span class="special">(</span><span class="keyword">const</span> <span class="identifier">StateIn</span> <span class="special">&amp;</span><span class="special">)</span><span class="special">;</span>
60 <span class="special">}</span><span class="special">;</span></pre></div>
61 <div class="refsect1">
62 <a name="idm45221356587040"></a><h2>Description</h2>
63 <p>The Runge-Kutta method of fourth order is one standard method for solving ordinary differential equations and is widely used, see also <a href="http://en.wikipedia.org/wiki/Runge%E2%80%93Kutta_methods" target="_top">en.wikipedia.org/wiki/Runge-Kutta_methods</a> The method is explicit and fulfills the Stepper concept. Step size control or continuous output are not provided.</p>
64 <p>This class derives from explicit_stepper_base and inherits its interface via CRTP (current recurring template pattern). Furthermore, it derivs from <a class="link" href="explicit_generic_rk.html" title="Class template explicit_generic_rk">explicit_generic_rk</a> which is a generic Runge-Kutta algorithm. For more details see explicit_stepper_base and <a class="link" href="explicit_generic_rk.html" title="Class template explicit_generic_rk">explicit_generic_rk</a>.</p>
65 <p>
66 </p>
67 <div class="refsect2">
68 <a name="idm45221356582752"></a><h3>Template Parameters</h3>
69 <div class="orderedlist"><ol class="orderedlist" type="1">
70 <li class="listitem">
71 <pre class="literallayout"><span class="keyword">typename</span> State</pre>
72 <p>The state type. </p>
73 </li>
74 <li class="listitem">
75 <pre class="literallayout"><span class="keyword">typename</span> Value <span class="special">=</span> <span class="keyword">double</span></pre>
76 <p>The value type. </p>
77 </li>
78 <li class="listitem">
79 <pre class="literallayout"><span class="keyword">typename</span> Deriv <span class="special">=</span> <span class="identifier">State</span></pre>
80 <p>The type representing the time derivative of the state. </p>
81 </li>
82 <li class="listitem">
83 <pre class="literallayout"><span class="keyword">typename</span> Time <span class="special">=</span> <span class="identifier">Value</span></pre>
84 <p>The time representing the independent variable - the time. </p>
85 </li>
86 <li class="listitem">
87 <pre class="literallayout"><span class="keyword">typename</span> Algebra <span class="special">=</span> <span class="keyword">typename</span> <span class="identifier">algebra_dispatcher</span><span class="special">&lt;</span> <span class="identifier">State</span> <span class="special">&gt;</span><span class="special">::</span><span class="identifier">algebra_type</span></pre>
88 <p>The algebra type. </p>
89 </li>
90 <li class="listitem">
91 <pre class="literallayout"><span class="keyword">typename</span> Operations <span class="special">=</span> <span class="keyword">typename</span> <span class="identifier">operations_dispatcher</span><span class="special">&lt;</span> <span class="identifier">State</span> <span class="special">&gt;</span><span class="special">::</span><span class="identifier">operations_type</span></pre>
92 <p>The operations type. </p>
93 </li>
94 <li class="listitem">
95 <pre class="literallayout"><span class="keyword">typename</span> Resizer <span class="special">=</span> <span class="identifier">initially_resizer</span></pre>
96 <p>The resizer policy type. </p>
97 </li>
98 </ol></div>
99 </div>
100 <div class="refsect2">
101 <a name="idm45221356552384"></a><h3>
102 <a name="boost.numeric.odeint.runge_kutta4construct-copy-destruct"></a><code class="computeroutput">runge_kutta4</code> 
103         public
104        construct/copy/destruct</h3>
105 <div class="orderedlist"><ol class="orderedlist" type="1"><li class="listitem">
106 <pre class="literallayout"><a name="idm45853738841952-bb"></a><span class="identifier">runge_kutta4</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">algebra_type</span> <span class="special">&amp;</span> algebra <span class="special">=</span> <span class="identifier">algebra_type</span><span class="special">(</span><span class="special">)</span><span class="special">)</span><span class="special">;</span></pre>Constructs the <code class="computeroutput"><a class="link" href="runge_kutta4.html" title="Class template runge_kutta4">runge_kutta4</a></code> class. This constructor can be used as a default constructor if the algebra has a default constructor. <p>
107 </p>
108 <div class="variablelist"><table border="0" class="variablelist compact">
109 <colgroup>
110 <col align="left" valign="top">
111 <col>
112 </colgroup>
113 <tbody><tr>
114 <td><p><span class="term">Parameters:</span></p></td>
115 <td><div class="variablelist"><table border="0" class="variablelist compact">
116 <colgroup>
117 <col align="left" valign="top">
118 <col>
119 </colgroup>
120 <tbody><tr>
121 <td><p><span class="term"><code class="computeroutput">algebra</code></span></p></td>
122 <td><p>A copy of algebra is made and stored inside explicit_stepper_base. </p></td>
123 </tr></tbody>
124 </table></div></td>
125 </tr></tbody>
126 </table></div>
127 </li></ol></div>
128 </div>
129 <div class="refsect2">
130 <a name="idm45221356537344"></a><h3>
131 <a name="idm45853738860096-bb"></a><code class="computeroutput">runge_kutta4</code> public member functions</h3>
132 <div class="orderedlist"><ol class="orderedlist" type="1">
133 <li class="listitem">
134 <pre class="literallayout"><span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">typename</span> System<span class="special">,</span> <span class="keyword">typename</span> StateIn<span class="special">,</span> <span class="keyword">typename</span> DerivIn<span class="special">,</span> 
135          <span class="keyword">typename</span> StateOut<span class="special">&gt;</span> 
136   <span class="keyword">void</span> <a name="idm45853738859536-bb"></a><span class="identifier">do_step_impl</span><span class="special">(</span><span class="identifier">System</span> system<span class="special">,</span> <span class="keyword">const</span> <span class="identifier">StateIn</span> <span class="special">&amp;</span> in<span class="special">,</span> <span class="keyword">const</span> <span class="identifier">DerivIn</span> <span class="special">&amp;</span> dxdt<span class="special">,</span> 
137                     <span class="identifier">time_type</span> t<span class="special">,</span> <span class="identifier">StateOut</span> <span class="special">&amp;</span> out<span class="special">,</span> <span class="identifier">time_type</span> dt<span class="special">)</span><span class="special">;</span></pre>This method performs one step. The derivative <code class="computeroutput">dxdt</code> of <code class="computeroutput">in</code> at the time <code class="computeroutput">t</code> is passed to the method. The result is updated out of place, hence the input is in <code class="computeroutput">in</code> and the output in <code class="computeroutput">out</code>. Access to this step functionality is provided by explicit_stepper_base and <code class="computeroutput">do_step_impl</code> should not be called directly. <p>
138 </p>
139 <div class="variablelist"><table border="0" class="variablelist compact">
140 <colgroup>
141 <col align="left" valign="top">
142 <col>
143 </colgroup>
144 <tbody><tr>
145 <td><p><span class="term">Parameters:</span></p></td>
146 <td><div class="variablelist"><table border="0" class="variablelist compact">
147 <colgroup>
148 <col align="left" valign="top">
149 <col>
150 </colgroup>
151 <tbody>
152 <tr>
153 <td><p><span class="term"><code class="computeroutput">dt</code></span></p></td>
154 <td><p>The step size. </p></td>
155 </tr>
156 <tr>
157 <td><p><span class="term"><code class="computeroutput">dxdt</code></span></p></td>
158 <td><p>The derivative of x at t. </p></td>
159 </tr>
160 <tr>
161 <td><p><span class="term"><code class="computeroutput">in</code></span></p></td>
162 <td><p>The state of the ODE which should be solved. in is not modified in this method </p></td>
163 </tr>
164 <tr>
165 <td><p><span class="term"><code class="computeroutput">out</code></span></p></td>
166 <td><p>The result of the step is written in out. </p></td>
167 </tr>
168 <tr>
169 <td><p><span class="term"><code class="computeroutput">system</code></span></p></td>
170 <td><p>The system function to solve, hence the r.h.s. of the ODE. It must fulfill the Simple System concept. </p></td>
171 </tr>
172 <tr>
173 <td><p><span class="term"><code class="computeroutput">t</code></span></p></td>
174 <td><p>The value of the time, at which the step should be performed. </p></td>
175 </tr>
176 </tbody>
177 </table></div></td>
178 </tr></tbody>
179 </table></div>
180 </li>
181 <li class="listitem">
182 <pre class="literallayout"><span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">typename</span> StateIn<span class="special">&gt;</span> <span class="keyword">void</span> <a name="idm45853738845728-bb"></a><span class="identifier">adjust_size</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">StateIn</span> <span class="special">&amp;</span> x<span class="special">)</span><span class="special">;</span></pre>Adjust the size of all temporaries in the stepper manually. <p>
183 </p>
184 <div class="variablelist"><table border="0" class="variablelist compact">
185 <colgroup>
186 <col align="left" valign="top">
187 <col>
188 </colgroup>
189 <tbody><tr>
190 <td><p><span class="term">Parameters:</span></p></td>
191 <td><div class="variablelist"><table border="0" class="variablelist compact">
192 <colgroup>
193 <col align="left" valign="top">
194 <col>
195 </colgroup>
196 <tbody><tr>
197 <td><p><span class="term"><code class="computeroutput">x</code></span></p></td>
198 <td><p>A state from which the size of the temporaries to be resized is deduced. </p></td>
199 </tr></tbody>
200 </table></div></td>
201 </tr></tbody>
202 </table></div>
203 </li>
204 </ol></div>
205 </div>
206 </div>
207 </div>
208 <table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
209 <td align="left"></td>
210 <td align="right"><div class="copyright-footer">Copyright &#169; 2009-2015 Karsten Ahnert and Mario Mulansky<p>
211         Distributed under the Boost Software License, Version 1.0. (See accompanying
212         file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
213       </p>
214 </div></td>
215 </tr></table>
216 <hr>
217 <div class="spirit-nav">
218 <a accesskey="p" href="../../../header/boost/numeric/odeint/stepper/runge_kutta4_hpp.html"><img src="../../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../../../header/boost/numeric/odeint/stepper/runge_kutta4_hpp.html"><img src="../../../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../../index.html"><img src="../../../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="../../../header/boost/numeric/odeint/stepper/runge_kutta4_classic_hpp.html"><img src="../../../../../../../../doc/src/images/next.png" alt="Next"></a>
219 </div>
220 </body>
221 </html>