Imported Upstream version 1.64.0
[platform/upstream/boost.git] / libs / numeric / odeint / doc / html / boost / numeric / odeint / runge_kutta4_classic.html
1 <html>
2 <head>
3 <meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
4 <title>Class template runge_kutta4_classic</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_classic_hpp.html" title="Header &lt;boost/numeric/odeint/stepper/runge_kutta4_classic.hpp&gt;">
9 <link rel="prev" href="../../../header/boost/numeric/odeint/stepper/runge_kutta4_classic_hpp.html" title="Header &lt;boost/numeric/odeint/stepper/runge_kutta4_classic.hpp&gt;">
10 <link rel="next" href="../../../header/boost/numeric/odeint/stepper/runge_kutta_cash_karp54_hpp.html" title="Header &lt;boost/numeric/odeint/stepper/runge_kutta_cash_karp54.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_classic_hpp.html"><img src="../../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../../../header/boost/numeric/odeint/stepper/runge_kutta4_classic_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_kutta_cash_karp54_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_classic"></a><div class="titlepage"></div>
27 <div class="refnamediv">
28 <h2><span class="refentrytitle">Class template runge_kutta4_classic</span></h2>
29 <p>boost::numeric::odeint::runge_kutta4_classic &#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_classic_hpp.html" title="Header &lt;boost/numeric/odeint/stepper/runge_kutta4_classic.hpp&gt;">boost/numeric/odeint/stepper/runge_kutta4_classic.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_classic.html" title="Class template runge_kutta4_classic">runge_kutta4_classic</a> <span class="special">:</span> <span class="keyword">public</span> <span class="identifier">explicit_stepper_base</span> <span class="special">{</span>
40 <span class="keyword">public</span><span class="special">:</span>
41   <span class="comment">// types</span>
42   <span class="keyword">typedef</span> <span class="identifier">explicit_stepper_base</span><span class="special">&lt;</span> <a class="link" href="runge_kutta4_classic.html" title="Class template runge_kutta4_classic">runge_kutta4_classic</a><span class="special">&lt;</span> <span class="special">...</span> <span class="special">&gt;</span><span class="special">,</span><span class="special">...</span> <span class="special">&gt;</span> <a name="boost.numeric.odeint.runge_kutta4_classic.stepper_base_type"></a><span class="identifier">stepper_base_type</span><span class="special">;</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_classic.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_classic.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_classic.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_classic.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_classic.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_classic.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_classic.resizer_type"></a><span class="identifier">resizer_type</span><span class="special">;</span>     
50
51   <span class="comment">// <a class="link" href="runge_kutta4_classic.html#boost.numeric.odeint.runge_kutta4_classicconstruct-copy-destruct">construct/copy/destruct</a></span>
52   <a class="link" href="runge_kutta4_classic.html#idp61717616-bb"><span class="identifier">runge_kutta4_classic</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_classic.html#idp61699472-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_classic.html#idp61700032-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> StateType<span class="special">&gt;</span> <span class="keyword">void</span> <a class="link" href="runge_kutta4_classic.html#idp61713840-bb"><span class="identifier">adjust_size</span></a><span class="special">(</span><span class="keyword">const</span> <span class="identifier">StateType</span> <span class="special">&amp;</span><span class="special">)</span><span class="special">;</span>
60
61   <span class="comment">// <a class="link" href="runge_kutta4_classic.html#idp61720896-bb">private member functions</a></span>
62   <span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">typename</span> StateIn<span class="special">&gt;</span> <span class="keyword">bool</span> <a class="link" href="runge_kutta4_classic.html#idp61721472-bb"><span class="identifier">resize_impl</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>
63 <span class="special">}</span><span class="special">;</span></pre></div>
64 <div class="refsect1">
65 <a name="idp98803904"></a><h2>Description</h2>
66 <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. This class implements the method directly, hence the generic Runge-Kutta algorithm is not used.</p>
67 <p>This class derives from explicit_stepper_base and inherits its interface via CRTP (current recurring template pattern). For more details see explicit_stepper_base.</p>
68 <p>
69 </p>
70 <div class="refsect2">
71 <a name="idp98806400"></a><h3>Template Parameters</h3>
72 <div class="orderedlist"><ol class="orderedlist" type="1">
73 <li class="listitem">
74 <pre class="literallayout"><span class="keyword">typename</span> State</pre>
75 <p>The state type. </p>
76 </li>
77 <li class="listitem">
78 <pre class="literallayout"><span class="keyword">typename</span> Value <span class="special">=</span> <span class="keyword">double</span></pre>
79 <p>The value type. </p>
80 </li>
81 <li class="listitem">
82 <pre class="literallayout"><span class="keyword">typename</span> Deriv <span class="special">=</span> <span class="identifier">State</span></pre>
83 <p>The type representing the time derivative of the state. </p>
84 </li>
85 <li class="listitem">
86 <pre class="literallayout"><span class="keyword">typename</span> Time <span class="special">=</span> <span class="identifier">Value</span></pre>
87 <p>The time representing the independent variable - the time. </p>
88 </li>
89 <li class="listitem">
90 <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>
91 <p>The algebra type. </p>
92 </li>
93 <li class="listitem">
94 <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>
95 <p>The operations type. </p>
96 </li>
97 <li class="listitem">
98 <pre class="literallayout"><span class="keyword">typename</span> Resizer <span class="special">=</span> <span class="identifier">initially_resizer</span></pre>
99 <p>The resizer policy type. </p>
100 </li>
101 </ol></div>
102 </div>
103 <div class="refsect2">
104 <a name="idp98836768"></a><h3>
105 <a name="boost.numeric.odeint.runge_kutta4_classicconstruct-copy-destruct"></a><code class="computeroutput">runge_kutta4_classic</code> 
106         public
107        construct/copy/destruct</h3>
108 <div class="orderedlist"><ol class="orderedlist" type="1"><li class="listitem">
109 <pre class="literallayout"><a name="idp61717616-bb"></a><span class="identifier">runge_kutta4_classic</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_classic.html" title="Class template runge_kutta4_classic">runge_kutta4_classic</a></code> class. This constructor can be used as a default constructor if the algebra has a default constructor. <p>
110 </p>
111 <div class="variablelist"><table border="0" class="variablelist compact">
112 <colgroup>
113 <col align="left" valign="top">
114 <col>
115 </colgroup>
116 <tbody><tr>
117 <td><p><span class="term">Parameters:</span></p></td>
118 <td><div class="variablelist"><table border="0" class="variablelist compact">
119 <colgroup>
120 <col align="left" valign="top">
121 <col>
122 </colgroup>
123 <tbody><tr>
124 <td><p><span class="term"><code class="computeroutput">algebra</code></span></p></td>
125 <td><p>A copy of algebra is made and stored inside explicit_stepper_base. </p></td>
126 </tr></tbody>
127 </table></div></td>
128 </tr></tbody>
129 </table></div>
130 </li></ol></div>
131 </div>
132 <div class="refsect2">
133 <a name="idp98851904"></a><h3>
134 <a name="idp61699472-bb"></a><code class="computeroutput">runge_kutta4_classic</code> public member functions</h3>
135 <div class="orderedlist"><ol class="orderedlist" type="1">
136 <li class="listitem">
137 <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> 
138          <span class="keyword">typename</span> StateOut<span class="special">&gt;</span> 
139   <span class="keyword">void</span> <a name="idp61700032-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> 
140                     <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>
141 </p>
142 <div class="variablelist"><table border="0" class="variablelist compact">
143 <colgroup>
144 <col align="left" valign="top">
145 <col>
146 </colgroup>
147 <tbody><tr>
148 <td><p><span class="term">Parameters:</span></p></td>
149 <td><div class="variablelist"><table border="0" class="variablelist compact">
150 <colgroup>
151 <col align="left" valign="top">
152 <col>
153 </colgroup>
154 <tbody>
155 <tr>
156 <td><p><span class="term"><code class="computeroutput">dt</code></span></p></td>
157 <td><p>The step size. </p></td>
158 </tr>
159 <tr>
160 <td><p><span class="term"><code class="computeroutput">dxdt</code></span></p></td>
161 <td><p>The derivative of x at t. </p></td>
162 </tr>
163 <tr>
164 <td><p><span class="term"><code class="computeroutput">in</code></span></p></td>
165 <td><p>The state of the ODE which should be solved. in is not modified in this method </p></td>
166 </tr>
167 <tr>
168 <td><p><span class="term"><code class="computeroutput">out</code></span></p></td>
169 <td><p>The result of the step is written in out. </p></td>
170 </tr>
171 <tr>
172 <td><p><span class="term"><code class="computeroutput">system</code></span></p></td>
173 <td><p>The system function to solve, hence the r.h.s. of the ODE. It must fulfill the Simple System concept. </p></td>
174 </tr>
175 <tr>
176 <td><p><span class="term"><code class="computeroutput">t</code></span></p></td>
177 <td><p>The value of the time, at which the step should be performed. </p></td>
178 </tr>
179 </tbody>
180 </table></div></td>
181 </tr></tbody>
182 </table></div>
183 </li>
184 <li class="listitem">
185 <pre class="literallayout"><span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">typename</span> StateType<span class="special">&gt;</span> <span class="keyword">void</span> <a name="idp61713840-bb"></a><span class="identifier">adjust_size</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">StateType</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>
186 </p>
187 <div class="variablelist"><table border="0" class="variablelist compact">
188 <colgroup>
189 <col align="left" valign="top">
190 <col>
191 </colgroup>
192 <tbody><tr>
193 <td><p><span class="term">Parameters:</span></p></td>
194 <td><div class="variablelist"><table border="0" class="variablelist compact">
195 <colgroup>
196 <col align="left" valign="top">
197 <col>
198 </colgroup>
199 <tbody><tr>
200 <td><p><span class="term"><code class="computeroutput">x</code></span></p></td>
201 <td><p>A state from which the size of the temporaries to be resized is deduced. </p></td>
202 </tr></tbody>
203 </table></div></td>
204 </tr></tbody>
205 </table></div>
206 </li>
207 </ol></div>
208 </div>
209 <div class="refsect2">
210 <a name="idp98902400"></a><h3>
211 <a name="idp61720896-bb"></a><code class="computeroutput">runge_kutta4_classic</code> private member functions</h3>
212 <div class="orderedlist"><ol class="orderedlist" type="1"><li class="listitem"><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">bool</span> <a name="idp61721472-bb"></a><span class="identifier">resize_impl</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></li></ol></div>
213 </div>
214 </div>
215 </div>
216 <table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
217 <td align="left"></td>
218 <td align="right"><div class="copyright-footer">Copyright &#169; 2009-2015 Karsten Ahnert and Mario Mulansky<p>
219         Distributed under the Boost Software License, Version 1.0. (See accompanying
220         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>)
221       </p>
222 </div></td>
223 </tr></table>
224 <hr>
225 <div class="spirit-nav">
226 <a accesskey="p" href="../../../header/boost/numeric/odeint/stepper/runge_kutta4_classic_hpp.html"><img src="../../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../../../header/boost/numeric/odeint/stepper/runge_kutta4_classic_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_kutta_cash_karp54_hpp.html"><img src="../../../../../../../../doc/src/images/next.png" alt="Next"></a>
227 </div>
228 </body>
229 </html>