1<html> 2<head> 3<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 4<title>Class template explicit_generic_rk</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 1. Boost.Numeric.Odeint"> 8<link rel="up" href="../../../header/boost/numeric/odeint/stepper/explicit_generic_rk_hpp.html" title="Header <boost/numeric/odeint/stepper/explicit_generic_rk.hpp>"> 9<link rel="prev" href="../../../header/boost/numeric/odeint/stepper/explicit_generic_rk_hpp.html" title="Header <boost/numeric/odeint/stepper/explicit_generic_rk.hpp>"> 10<link rel="next" href="../../../header/boost/numeric/odeint/stepper/extrapolation_stepper_hpp.html" title="Header <boost/numeric/odeint/stepper/extrapolation_stepper.hpp>"> 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/explicit_generic_rk_hpp.html"><img src="../../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../../../header/boost/numeric/odeint/stepper/explicit_generic_rk_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/extrapolation_stepper_hpp.html"><img src="../../../../../../../../doc/src/images/next.png" alt="Next"></a> 24</div> 25<div class="refentry"> 26<a name="boost.numeric.odeint.explicit_generic_rk"></a><div class="titlepage"></div> 27<div class="refnamediv"> 28<h2><span class="refentrytitle">Class template explicit_generic_rk</span></h2> 29<p>boost::numeric::odeint::explicit_generic_rk — A generic implementation of explicit Runge-Kutta algorithms. This class is as a base class for all explicit Runge-Kutta steppers. </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: <<a class="link" href="../../../header/boost/numeric/odeint/stepper/explicit_generic_rk_hpp.html" title="Header <boost/numeric/odeint/stepper/explicit_generic_rk.hpp>">boost/numeric/odeint/stepper/explicit_generic_rk.hpp</a>> 33 34</span><span class="keyword">template</span><span class="special"><</span><span class="identifier">size_t</span> StageCount<span class="special">,</span> <span class="identifier">size_t</span> Order<span class="special">,</span> <span class="keyword">typename</span> State<span class="special">,</span> <span class="keyword">typename</span> Value<span class="special">,</span> 35 <span class="keyword">typename</span> Deriv<span class="special">,</span> <span class="keyword">typename</span> Time<span class="special">,</span> <span class="keyword">typename</span> Algebra<span class="special">,</span> <span class="keyword">typename</span> Operations<span class="special">,</span> 36 <span class="keyword">typename</span> Resizer<span class="special">></span> 37<span class="keyword">class</span> <a class="link" href="explicit_generic_rk.html" title="Class template explicit_generic_rk">explicit_generic_rk</a> <span class="special">:</span> <span class="keyword">public</span> <span class="identifier">explicit_stepper_base</span> <span class="special">{</span> 38<span class="keyword">public</span><span class="special">:</span> 39 <span class="comment">// types</span> 40 <span class="keyword">typedef</span> <span class="identifier">explicit_stepper_base</span><span class="special"><</span> <span class="special">...</span> <span class="special">></span> <a name="boost.numeric.odeint.explicit_generic_rk.stepper_base_type"></a><span class="identifier">stepper_base_type</span><span class="special">;</span> 41 <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.explicit_generic_rk.state_type"></a><span class="identifier">state_type</span><span class="special">;</span> 42 <span class="keyword">typedef</span> <span class="identifier">stepper_base_type</span><span class="special">::</span><span class="identifier">wrapped_state_type</span> <a name="boost.numeric.odeint.explicit_generic_rk.wrapped_state_type"></a><span class="identifier">wrapped_state_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">value_type</span> <a name="boost.numeric.odeint.explicit_generic_rk.value_type"></a><span class="identifier">value_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">deriv_type</span> <a name="boost.numeric.odeint.explicit_generic_rk.deriv_type"></a><span class="identifier">deriv_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">wrapped_deriv_type</span> <a name="boost.numeric.odeint.explicit_generic_rk.wrapped_deriv_type"></a><span class="identifier">wrapped_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.explicit_generic_rk.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.explicit_generic_rk.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.explicit_generic_rk.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.explicit_generic_rk.resizer_type"></a><span class="identifier">resizer_type</span><span class="special">;</span> 50 <span class="keyword">typedef</span> <span class="emphasis"><em><span class="identifier">unspecified</span></em></span> <a name="boost.numeric.odeint.explicit_generic_rk.rk_algorithm_type"></a><span class="identifier">rk_algorithm_type</span><span class="special">;</span> 51 <span class="keyword">typedef</span> <span class="identifier">rk_algorithm_type</span><span class="special">::</span><span class="identifier">coef_a_type</span> <a name="boost.numeric.odeint.explicit_generic_rk.coef_a_type"></a><span class="identifier">coef_a_type</span><span class="special">;</span> 52 <span class="keyword">typedef</span> <span class="identifier">rk_algorithm_type</span><span class="special">::</span><span class="identifier">coef_b_type</span> <a name="boost.numeric.odeint.explicit_generic_rk.coef_b_type"></a><span class="identifier">coef_b_type</span><span class="special">;</span> 53 <span class="keyword">typedef</span> <span class="identifier">rk_algorithm_type</span><span class="special">::</span><span class="identifier">coef_c_type</span> <a name="boost.numeric.odeint.explicit_generic_rk.coef_c_type"></a><span class="identifier">coef_c_type</span><span class="special">;</span> 54 55 <span class="comment">// <a class="link" href="explicit_generic_rk.html#boost.numeric.odeint.explicit_generic_rkconstruct-copy-destruct">construct/copy/destruct</a></span> 56 <a class="link" href="explicit_generic_rk.html#idm45875526333040-bb"><span class="identifier">explicit_generic_rk</span></a><span class="special">(</span><span class="keyword">const</span> <span class="identifier">coef_a_type</span> <span class="special">&</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">coef_b_type</span> <span class="special">&</span><span class="special">,</span> 57 <span class="keyword">const</span> <span class="identifier">coef_c_type</span> <span class="special">&</span><span class="special">,</span> 58 <span class="keyword">const</span> <span class="identifier">algebra_type</span> <span class="special">&</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> 59 60 <span class="comment">// <a class="link" href="explicit_generic_rk.html#idm45875526351184-bb">public member functions</a></span> 61 <span class="keyword">template</span><span class="special"><</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> 62 <span class="keyword">typename</span> StateOut<span class="special">></span> 63 <span class="keyword">void</span> <a class="link" href="explicit_generic_rk.html#idm45875526350624-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">&</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">DerivIn</span> <span class="special">&</span><span class="special">,</span> <span class="identifier">time_type</span><span class="special">,</span> 64 <span class="identifier">StateOut</span> <span class="special">&</span><span class="special">,</span> <span class="identifier">time_type</span><span class="special">)</span><span class="special">;</span> 65 <span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> StateIn<span class="special">></span> <span class="keyword">void</span> <a class="link" href="explicit_generic_rk.html#idm45875526336816-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">&</span><span class="special">)</span><span class="special">;</span> 66 67 <span class="comment">// <a class="link" href="explicit_generic_rk.html#idm45875526326384-bb">private member functions</a></span> 68 <span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> StateIn<span class="special">></span> <span class="keyword">bool</span> <a class="link" href="explicit_generic_rk.html#idm45875526325808-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">&</span><span class="special">)</span><span class="special">;</span> 69<span class="special">}</span><span class="special">;</span></pre></div> 70<div class="refsect1"> 71<a name="idm45600373040624"></a><h2>Description</h2> 72<p>This class implements the explicit Runge-Kutta algorithms without error estimation in a generic way. The Butcher tableau is passed to the stepper which constructs the stepper scheme with the help of a template-metaprogramming algorithm. ToDo : Add example!</p> 73<p>This class derives explicit_stepper_base which provides the stepper interface.</p> 74<p> 75</p> 76<div class="refsect2"> 77<a name="idm45600373039072"></a><h3>Template Parameters</h3> 78<div class="orderedlist"><ol class="orderedlist" type="1"> 79<li class="listitem"> 80<pre class="literallayout"><span class="identifier">size_t</span> StageCount</pre> 81<p>The number of stages of the Runge-Kutta algorithm. </p> 82</li> 83<li class="listitem"> 84<pre class="literallayout"><span class="identifier">size_t</span> Order</pre> 85<p>The order of the stepper. </p> 86</li> 87<li class="listitem"> 88<pre class="literallayout"><span class="keyword">typename</span> State</pre> 89<p>The type representing the state of the ODE. </p> 90</li> 91<li class="listitem"> 92<pre class="literallayout"><span class="keyword">typename</span> Value</pre> 93<p>The floating point type which is used in the computations. </p> 94</li> 95<li class="listitem"><pre class="literallayout"><span class="keyword">typename</span> Deriv</pre></li> 96<li class="listitem"> 97<pre class="literallayout"><span class="keyword">typename</span> Time</pre> 98<p>The type representing the independent variable - the time - of the ODE. </p> 99</li> 100<li class="listitem"> 101<pre class="literallayout"><span class="keyword">typename</span> Algebra</pre> 102<p>The algebra type. </p> 103</li> 104<li class="listitem"> 105<pre class="literallayout"><span class="keyword">typename</span> Operations</pre> 106<p>The operations type. </p> 107</li> 108<li class="listitem"> 109<pre class="literallayout"><span class="keyword">typename</span> Resizer</pre> 110<p>The resizer policy type. </p> 111</li> 112</ol></div> 113</div> 114<div class="refsect2"> 115<a name="idm45600373019696"></a><h3> 116<a name="boost.numeric.odeint.explicit_generic_rkconstruct-copy-destruct"></a><code class="computeroutput">explicit_generic_rk</code> 117 public 118 construct/copy/destruct</h3> 119<div class="orderedlist"><ol class="orderedlist" type="1"><li class="listitem"> 120<pre class="literallayout"><a name="idm45875526333040-bb"></a><span class="identifier">explicit_generic_rk</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">coef_a_type</span> <span class="special">&</span> a<span class="special">,</span> <span class="keyword">const</span> <span class="identifier">coef_b_type</span> <span class="special">&</span> b<span class="special">,</span> 121 <span class="keyword">const</span> <span class="identifier">coef_c_type</span> <span class="special">&</span> c<span class="special">,</span> 122 <span class="keyword">const</span> <span class="identifier">algebra_type</span> <span class="special">&</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="explicit_generic_rk.html" title="Class template explicit_generic_rk">explicit_generic_rk</a></code> class. See examples section for details on the coefficients. <p> 123</p> 124<div class="variablelist"><table border="0" class="variablelist compact"> 125<colgroup> 126<col align="left" valign="top"> 127<col> 128</colgroup> 129<tbody><tr> 130<td><p><span class="term">Parameters:</span></p></td> 131<td><div class="variablelist"><table border="0" class="variablelist compact"> 132<colgroup> 133<col align="left" valign="top"> 134<col> 135</colgroup> 136<tbody> 137<tr> 138<td><p><span class="term"><code class="computeroutput">a</code></span></p></td> 139<td><p>Triangular matrix of parameters b in the Butcher tableau. </p></td> 140</tr> 141<tr> 142<td><p><span class="term"><code class="computeroutput">algebra</code></span></p></td> 143<td><p>A copy of algebra is made and stored inside explicit_stepper_base. </p></td> 144</tr> 145<tr> 146<td><p><span class="term"><code class="computeroutput">b</code></span></p></td> 147<td><p>Last row of the butcher tableau. </p></td> 148</tr> 149<tr> 150<td><p><span class="term"><code class="computeroutput">c</code></span></p></td> 151<td><p>Parameters to calculate the time points in the Butcher tableau. </p></td> 152</tr> 153</tbody> 154</table></div></td> 155</tr></tbody> 156</table></div> 157</li></ol></div> 158</div> 159<div class="refsect2"> 160<a name="idm45600372992736"></a><h3> 161<a name="idm45875526351184-bb"></a><code class="computeroutput">explicit_generic_rk</code> public member functions</h3> 162<div class="orderedlist"><ol class="orderedlist" type="1"> 163<li class="listitem"> 164<pre class="literallayout"><span class="keyword">template</span><span class="special"><</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> 165 <span class="keyword">typename</span> StateOut<span class="special">></span> 166 <span class="keyword">void</span> <a name="idm45875526350624-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">&</span> in<span class="special">,</span> <span class="keyword">const</span> <span class="identifier">DerivIn</span> <span class="special">&</span> dxdt<span class="special">,</span> 167 <span class="identifier">time_type</span> t<span class="special">,</span> <span class="identifier">StateOut</span> <span class="special">&</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> 168</p> 169<div class="variablelist"><table border="0" class="variablelist compact"> 170<colgroup> 171<col align="left" valign="top"> 172<col> 173</colgroup> 174<tbody><tr> 175<td><p><span class="term">Parameters:</span></p></td> 176<td><div class="variablelist"><table border="0" class="variablelist compact"> 177<colgroup> 178<col align="left" valign="top"> 179<col> 180</colgroup> 181<tbody> 182<tr> 183<td><p><span class="term"><code class="computeroutput">dt</code></span></p></td> 184<td><p>The step size. </p></td> 185</tr> 186<tr> 187<td><p><span class="term"><code class="computeroutput">dxdt</code></span></p></td> 188<td><p>The derivative of x at t. </p></td> 189</tr> 190<tr> 191<td><p><span class="term"><code class="computeroutput">in</code></span></p></td> 192<td><p>The state of the ODE which should be solved. in is not modified in this method </p></td> 193</tr> 194<tr> 195<td><p><span class="term"><code class="computeroutput">out</code></span></p></td> 196<td><p>The result of the step is written in out. </p></td> 197</tr> 198<tr> 199<td><p><span class="term"><code class="computeroutput">system</code></span></p></td> 200<td><p>The system function to solve, hence the r.h.s. of the ODE. It must fulfill the Simple System concept. </p></td> 201</tr> 202<tr> 203<td><p><span class="term"><code class="computeroutput">t</code></span></p></td> 204<td><p>The value of the time, at which the step should be performed. </p></td> 205</tr> 206</tbody> 207</table></div></td> 208</tr></tbody> 209</table></div> 210</li> 211<li class="listitem"> 212<pre class="literallayout"><span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> StateIn<span class="special">></span> <span class="keyword">void</span> <a name="idm45875526336816-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">&</span> x<span class="special">)</span><span class="special">;</span></pre>Adjust the size of all temporaries in the stepper manually. <p> 213</p> 214<div class="variablelist"><table border="0" class="variablelist compact"> 215<colgroup> 216<col align="left" valign="top"> 217<col> 218</colgroup> 219<tbody><tr> 220<td><p><span class="term">Parameters:</span></p></td> 221<td><div class="variablelist"><table border="0" class="variablelist compact"> 222<colgroup> 223<col align="left" valign="top"> 224<col> 225</colgroup> 226<tbody><tr> 227<td><p><span class="term"><code class="computeroutput">x</code></span></p></td> 228<td><p>A state from which the size of the temporaries to be resized is deduced. </p></td> 229</tr></tbody> 230</table></div></td> 231</tr></tbody> 232</table></div> 233</li> 234</ol></div> 235</div> 236<div class="refsect2"> 237<a name="idm45600372942304"></a><h3> 238<a name="idm45875526326384-bb"></a><code class="computeroutput">explicit_generic_rk</code> private member functions</h3> 239<div class="orderedlist"><ol class="orderedlist" type="1"><li class="listitem"><pre class="literallayout"><span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> StateIn<span class="special">></span> <span class="keyword">bool</span> <a name="idm45875526325808-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">&</span> x<span class="special">)</span><span class="special">;</span></pre></li></ol></div> 240</div> 241</div> 242</div> 243<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> 244<td align="left"></td> 245<td align="right"><div class="copyright-footer">Copyright © 2009-2015 Karsten Ahnert and Mario Mulansky<p> 246 Distributed under the Boost Software License, Version 1.0. (See accompanying 247 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>) 248 </p> 249</div></td> 250</tr></table> 251<hr> 252<div class="spirit-nav"> 253<a accesskey="p" href="../../../header/boost/numeric/odeint/stepper/explicit_generic_rk_hpp.html"><img src="../../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../../../header/boost/numeric/odeint/stepper/explicit_generic_rk_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/extrapolation_stepper_hpp.html"><img src="../../../../../../../../doc/src/images/next.png" alt="Next"></a> 254</div> 255</body> 256</html> 257