mirror of
https://github.com/TheAlgorithms/C-Plus-Plus.git
synced 2026-11-28 23:15:33 +08:00
Documentation for 67e26cfbae
This commit is contained in:
@@ -98,38 +98,36 @@ $(document).ready(function(){initNavTree('dc/dc4/_2_users_2runner_2work_2_c-_plu
|
||||
<div class="fragment"><div class="line"><span class="comment">/**</span></div>
|
||||
<div class="line"><span class="comment"> * @{</span></div>
|
||||
<div class="line"><span class="comment"> * \file</span></div>
|
||||
<div class="line"><span class="comment"> * \brief [Runge Kutta fourth order](https://en.wikipedia.org/wiki/Runge%E2%80%93Kutta_methods) method implementation</span></div>
|
||||
<div class="line"><span class="comment"> * \brief [Runge Kutta fourth</span></div>
|
||||
<div class="line"><span class="comment"> * order](https://en.wikipedia.org/wiki/Runge%E2%80%93Kutta_methods) method</span></div>
|
||||
<div class="line"><span class="comment"> * implementation</span></div>
|
||||
<div class="line"><span class="comment"> *</span></div>
|
||||
<div class="line"><span class="comment"> * \author [Rudra Prasad Das](http://github.com/rudra697)</span></div>
|
||||
<div class="line"><span class="comment"> *</span></div>
|
||||
<div class="line"><span class="comment"> * \details</span></div>
|
||||
<div class="line"><span class="comment"> * It solves the unknown value of y </span></div>
|
||||
<div class="line"><span class="comment"> * It solves the unknown value of y</span></div>
|
||||
<div class="line"><span class="comment"> * for a given value of x</span></div>
|
||||
<div class="line"><span class="comment"> * only first order differential equations</span></div>
|
||||
<div class="line"><span class="comment"> * can be solved</span></div>
|
||||
<div class="line"><span class="comment"> * \example</span></div>
|
||||
<div class="line"><span class="comment"> * it solves \frac{\mathrm{d} y}{\mathrm{d} x}= \frac{\left ( x-y \right )}{2}</span></div>
|
||||
<div class="line"><span class="comment"> * given x for given initial </span></div>
|
||||
<div class="line"><span class="comment"> * given x for given initial</span></div>
|
||||
<div class="line"><span class="comment"> * conditions</span></div>
|
||||
<div class="line"><span class="comment"> * There can be many such equations </span></div>
|
||||
<div class="line"><span class="comment"> * There can be many such equations</span></div>
|
||||
<div class="line"><span class="comment"> */</span></div>
|
||||
<div class="line"><span class="preprocessor">#include <iostream></span> <span class="comment">/// for io operations</span></div>
|
||||
<div class="line"><span class="comment"></span><span class="preprocessor">#include <vector></span> <span class="comment">/// for using the vector container</span></div>
|
||||
<div class="line"><span class="comment"></span><span class="preprocessor">#include <cassert></span> <span class="comment">/// asserting the test functions</span></div>
|
||||
<div class="line"><span class="preprocessor">#include <cassert></span> <span class="comment">/// asserting the test functions</span></div>
|
||||
<div class="line"><span class="comment"></span><span class="preprocessor">#include <iostream></span> <span class="comment">/// for io operations</span></div>
|
||||
<div class="line"><span class="comment"></span><span class="preprocessor">#include <vector></span> <span class="comment">/// for using the vector container</span></div>
|
||||
<div class="line"><span class="comment"></span><span class="comment"></span> </div>
|
||||
<div class="line"><span class="comment">/**</span></div>
|
||||
<div class="line"><span class="comment"> * @brief The change() function is used </span></div>
|
||||
<div class="line"><span class="comment"> * to return the updated iterative value corresponding </span></div>
|
||||
<div class="line"><span class="comment"> * @brief The change() function is used</span></div>
|
||||
<div class="line"><span class="comment"> * to return the updated iterative value corresponding</span></div>
|
||||
<div class="line"><span class="comment"> * to the given function</span></div>
|
||||
<div class="line"><span class="comment"> * @param x is the value corresponding to the x coordinate</span></div>
|
||||
<div class="line"><span class="comment"> * @param y is the value corresponding to the y coordinate </span></div>
|
||||
<div class="line"><span class="comment"> * @param y is the value corresponding to the y coordinate</span></div>
|
||||
<div class="line"><span class="comment"> * @returns the computed function value at that call</span></div>
|
||||
<div class="line"><span class="comment"> */</span></div>
|
||||
<div class="line"><span class="keyword">static</span> <span class="keywordtype">double</span> <a name="a0"></a><a class="code" href="../../d1/da6/rungekutta_8cpp.html#a450497475f5607333f9aca8f88901579">change</a>(<span class="keywordtype">double</span> x, <span class="keywordtype">double</span> y) </div>
|
||||
<div class="line">{ </div>
|
||||
<div class="line"> <span class="keywordflow">return</span> ((x - y)/2.0); </div>
|
||||
<div class="line"> </div>
|
||||
<div class="line">} </div>
|
||||
<div class="line"><span class="keyword">static</span> <span class="keywordtype">double</span> <a name="a0"></a><a class="code" href="../../d1/da6/rungekutta_8cpp.html#a450497475f5607333f9aca8f88901579">change</a>(<span class="keywordtype">double</span> x, <span class="keywordtype">double</span> y) { <span class="keywordflow">return</span> ((x - y) / 2.0); }</div>
|
||||
<div class="line"><span class="comment"></span> </div>
|
||||
<div class="line"><span class="comment">/**</span></div>
|
||||
<div class="line"><span class="comment"> * @namespace numerical_methods</span></div>
|
||||
@@ -138,98 +136,98 @@ $(document).ready(function(){initNavTree('dc/dc4/_2_users_2runner_2work_2_c-_plu
|
||||
<div class="line"><span class="keyword">namespace </span><a class="code" href="../../d1/de0/namespacenumerical__methods.html">numerical_methods</a> {<span class="comment"></span></div>
|
||||
<div class="line"><span class="comment">/**</span></div>
|
||||
<div class="line"><span class="comment"> * @namespace runge_kutta</span></div>
|
||||
<div class="line"><span class="comment"> * @brief Functions for [Runge Kutta fourth order](https://en.wikipedia.org/wiki/Runge%E2%80%93Kutta_methods) method</span></div>
|
||||
<div class="line"><span class="comment"> * @brief Functions for [Runge Kutta fourth</span></div>
|
||||
<div class="line"><span class="comment"> * order](https://en.wikipedia.org/wiki/Runge%E2%80%93Kutta_methods) method</span></div>
|
||||
<div class="line"><span class="comment"> */</span></div>
|
||||
<div class="line"><span class="keyword">namespace </span><a class="code" href="../../d2/de7/namespacerunge__kutta.html">runge_kutta</a> {<span class="comment"></span></div>
|
||||
<div class="line"><span class="comment">/**</span></div>
|
||||
<div class="line"><span class="comment"> * @brief the Runge Kutta method finds the value of integration of a function in the given limits.</span></div>
|
||||
<div class="line"><span class="comment"> * the lower limit of integration as the initial value and the upper limit is the given x</span></div>
|
||||
<div class="line"><span class="comment"> * @brief the Runge Kutta method finds the value of integration of a function in</span></div>
|
||||
<div class="line"><span class="comment"> * the given limits. the lower limit of integration as the initial value and the</span></div>
|
||||
<div class="line"><span class="comment"> * upper limit is the given x</span></div>
|
||||
<div class="line"><span class="comment"> * @param init_x is the value of initial x and is updated after each call</span></div>
|
||||
<div class="line"><span class="comment"> * @param init_y is the value of initial x and is updated after each call</span></div>
|
||||
<div class="line"><span class="comment"> * @param x is current iteration at which the function needs to be evaluated</span></div>
|
||||
<div class="line"><span class="comment"> * @param h is the step value </span></div>
|
||||
<div class="line"><span class="comment"> * @returns the value of y at thr required value of x from the initial conditions</span></div>
|
||||
<div class="line"><span class="comment"> * @param h is the step value</span></div>
|
||||
<div class="line"><span class="comment"> * @returns the value of y at thr required value of x from the initial</span></div>
|
||||
<div class="line"><span class="comment"> * conditions</span></div>
|
||||
<div class="line"><span class="comment"> */</span></div>
|
||||
<div class="line"><span class="keywordtype">double</span> <a name="a1"></a><a class="code" href="../../d1/da6/rungekutta_8cpp.html#a7b9f40c7b5e9749cc550f19be3dc8856">rungeKutta</a>(<span class="keywordtype">double</span> init_x, <span class="keyword">const</span> <span class="keywordtype">double</span> &init_y, <span class="keyword">const</span> <span class="keywordtype">double</span> &x, <span class="keyword">const</span> <span class="keywordtype">double</span> &<a name="a2"></a><a class="code" href="../../d1/df3/hash__search_8cpp.html#a566eaf0ffafd50bc61e644561fd27001">h</a>) </div>
|
||||
<div class="line">{ </div>
|
||||
<div class="line"> </div>
|
||||
<div class="line"> <span class="comment">// Count number of iterations </span></div>
|
||||
<div class="line"> <span class="comment">// using step size or </span></div>
|
||||
<div class="line"> <span class="comment">// step height h </span></div>
|
||||
<div class="line"> </div>
|
||||
<div class="line"> </div>
|
||||
<div class="line"> <span class="comment">// n calucates the number of iterations</span></div>
|
||||
<div class="line"> <span class="comment">// k1, k2, k3, k4 are the Runge Kutta variables </span></div>
|
||||
<div class="line"> <span class="comment">// used for calculation of y at each iteration</span></div>
|
||||
<div class="line"> </div>
|
||||
<div class="line"> <span class="keyword">auto</span> n = <span class="keyword">static_cast<</span>uint64_t<span class="keyword">></span>((x - init_x) / <a class="code" href="../../d1/df3/hash__search_8cpp.html#a566eaf0ffafd50bc61e644561fd27001">h</a>); </div>
|
||||
<div class="line"> <span class="comment">// used a vector container for the variables</span></div>
|
||||
<div class="line"> <a name="_a3"></a><a class="codeRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector<double></a> k(4,0.0);</div>
|
||||
<div class="line"> </div>
|
||||
<div class="line"> </div>
|
||||
<div class="line"> <span class="comment">// Iterate for number of iterations </span></div>
|
||||
<div class="line"> </div>
|
||||
<div class="line"> <span class="keywordtype">double</span> y = init_y; </div>
|
||||
<div class="line"> <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i=1; i<=n; ++i) </div>
|
||||
<div class="line"> { </div>
|
||||
<div class="line"> </div>
|
||||
<div class="line"> <span class="comment">// Apply Runge Kutta Formulas </span></div>
|
||||
<div class="line"> <span class="comment">// to find next value of y </span></div>
|
||||
<div class="line"> k[0] = <a class="code" href="../../d1/df3/hash__search_8cpp.html#a566eaf0ffafd50bc61e644561fd27001">h</a>*<a class="code" href="../../d1/da6/rungekutta_8cpp.html#a450497475f5607333f9aca8f88901579">change</a>(init_x, y); </div>
|
||||
<div class="line"> k[1] = <a class="code" href="../../d1/df3/hash__search_8cpp.html#a566eaf0ffafd50bc61e644561fd27001">h</a>*<a class="code" href="../../d1/da6/rungekutta_8cpp.html#a450497475f5607333f9aca8f88901579">change</a>(init_x + 0.5*<a class="code" href="../../d1/df3/hash__search_8cpp.html#a566eaf0ffafd50bc61e644561fd27001">h</a>, y + 0.5*k[0]); </div>
|
||||
<div class="line"> k[2] = <a class="code" href="../../d1/df3/hash__search_8cpp.html#a566eaf0ffafd50bc61e644561fd27001">h</a>*<a class="code" href="../../d1/da6/rungekutta_8cpp.html#a450497475f5607333f9aca8f88901579">change</a>(init_x + 0.5*<a class="code" href="../../d1/df3/hash__search_8cpp.html#a566eaf0ffafd50bc61e644561fd27001">h</a>, y + 0.5*k[1]); </div>
|
||||
<div class="line"> k[3] = <a class="code" href="../../d1/df3/hash__search_8cpp.html#a566eaf0ffafd50bc61e644561fd27001">h</a>*<a class="code" href="../../d1/da6/rungekutta_8cpp.html#a450497475f5607333f9aca8f88901579">change</a>(init_x + <a class="code" href="../../d1/df3/hash__search_8cpp.html#a566eaf0ffafd50bc61e644561fd27001">h</a>, y + k[2]); </div>
|
||||
<div class="line"> </div>
|
||||
<div class="line"> </div>
|
||||
<div class="line"> <span class="comment">// Update next value of y </span></div>
|
||||
<div class="line"> </div>
|
||||
<div class="line"> y += (1.0/6.0)*(k[0] + 2*k[1] + 2*k[2] + k[3]);</div>
|
||||
<div class="line"> </div>
|
||||
<div class="line"> <span class="comment">// Update next value of x </span></div>
|
||||
<div class="line"> </div>
|
||||
<div class="line"> init_x += <a class="code" href="../../d1/df3/hash__search_8cpp.html#a566eaf0ffafd50bc61e644561fd27001">h</a>; </div>
|
||||
<div class="line"> } </div>
|
||||
<div class="line"><span class="keywordtype">double</span> <a name="a1"></a><a class="code" href="../../d1/da6/rungekutta_8cpp.html#a7b9f40c7b5e9749cc550f19be3dc8856">rungeKutta</a>(<span class="keywordtype">double</span> init_x, <span class="keyword">const</span> <span class="keywordtype">double</span> &init_y, <span class="keyword">const</span> <span class="keywordtype">double</span> &x,</div>
|
||||
<div class="line"> <span class="keyword">const</span> <span class="keywordtype">double</span> &<a name="a2"></a><a class="code" href="../../d1/df3/hash__search_8cpp.html#a566eaf0ffafd50bc61e644561fd27001">h</a>) {</div>
|
||||
<div class="line"> <span class="comment">// Count number of iterations</span></div>
|
||||
<div class="line"> <span class="comment">// using step size or</span></div>
|
||||
<div class="line"> <span class="comment">// step height h</span></div>
|
||||
<div class="line"> </div>
|
||||
<div class="line"> <span class="keywordflow">return</span> y; </div>
|
||||
<div class="line">} </div>
|
||||
<div class="line">} <span class="comment">// namespace runge_kutta</span></div>
|
||||
<div class="line">} <span class="comment">// namespace numerical_methods</span></div>
|
||||
<div class="line"> <span class="comment">// n calucates the number of iterations</span></div>
|
||||
<div class="line"> <span class="comment">// k1, k2, k3, k4 are the Runge Kutta variables</span></div>
|
||||
<div class="line"> <span class="comment">// used for calculation of y at each iteration</span></div>
|
||||
<div class="line"> </div>
|
||||
<div class="line"> <span class="keyword">auto</span> n = <span class="keyword">static_cast<</span>uint64_t<span class="keyword">></span>((x - init_x) / <a class="code" href="../../d1/df3/hash__search_8cpp.html#a566eaf0ffafd50bc61e644561fd27001">h</a>);</div>
|
||||
<div class="line"> <span class="comment">// used a vector container for the variables</span></div>
|
||||
<div class="line"> <a name="_a3"></a><a class="codeRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector<double></a> k(4, 0.0);</div>
|
||||
<div class="line"> </div>
|
||||
<div class="line"> <span class="comment">// Iterate for number of iterations</span></div>
|
||||
<div class="line"> </div>
|
||||
<div class="line"> <span class="keywordtype">double</span> y = init_y;</div>
|
||||
<div class="line"> <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 1; i <= n; ++i) {</div>
|
||||
<div class="line"> <span class="comment">// Apply Runge Kutta Formulas</span></div>
|
||||
<div class="line"> <span class="comment">// to find next value of y</span></div>
|
||||
<div class="line"> k[0] = <a class="code" href="../../d1/df3/hash__search_8cpp.html#a566eaf0ffafd50bc61e644561fd27001">h</a> * <a class="code" href="../../d1/da6/rungekutta_8cpp.html#a450497475f5607333f9aca8f88901579">change</a>(init_x, y);</div>
|
||||
<div class="line"> k[1] = <a class="code" href="../../d1/df3/hash__search_8cpp.html#a566eaf0ffafd50bc61e644561fd27001">h</a> * <a class="code" href="../../d1/da6/rungekutta_8cpp.html#a450497475f5607333f9aca8f88901579">change</a>(init_x + 0.5 * <a class="code" href="../../d1/df3/hash__search_8cpp.html#a566eaf0ffafd50bc61e644561fd27001">h</a>, y + 0.5 * k[0]);</div>
|
||||
<div class="line"> k[2] = <a class="code" href="../../d1/df3/hash__search_8cpp.html#a566eaf0ffafd50bc61e644561fd27001">h</a> * <a class="code" href="../../d1/da6/rungekutta_8cpp.html#a450497475f5607333f9aca8f88901579">change</a>(init_x + 0.5 * <a class="code" href="../../d1/df3/hash__search_8cpp.html#a566eaf0ffafd50bc61e644561fd27001">h</a>, y + 0.5 * k[1]);</div>
|
||||
<div class="line"> k[3] = <a class="code" href="../../d1/df3/hash__search_8cpp.html#a566eaf0ffafd50bc61e644561fd27001">h</a> * <a class="code" href="../../d1/da6/rungekutta_8cpp.html#a450497475f5607333f9aca8f88901579">change</a>(init_x + <a class="code" href="../../d1/df3/hash__search_8cpp.html#a566eaf0ffafd50bc61e644561fd27001">h</a>, y + k[2]);</div>
|
||||
<div class="line"> </div>
|
||||
<div class="line"> <span class="comment">// Update next value of y</span></div>
|
||||
<div class="line"> </div>
|
||||
<div class="line"> y += (1.0 / 6.0) * (k[0] + 2 * k[1] + 2 * k[2] + k[3]);</div>
|
||||
<div class="line"> </div>
|
||||
<div class="line"> <span class="comment">// Update next value of x</span></div>
|
||||
<div class="line"> </div>
|
||||
<div class="line"> init_x += <a class="code" href="../../d1/df3/hash__search_8cpp.html#a566eaf0ffafd50bc61e644561fd27001">h</a>;</div>
|
||||
<div class="line"> }</div>
|
||||
<div class="line"> </div>
|
||||
<div class="line"> <span class="keywordflow">return</span> y;</div>
|
||||
<div class="line">}</div>
|
||||
<div class="line">} <span class="comment">// namespace runge_kutta</span></div>
|
||||
<div class="line">} <span class="comment">// namespace numerical_methods</span></div>
|
||||
<div class="line"><span class="comment"></span> </div>
|
||||
<div class="line"><span class="comment">/**</span></div>
|
||||
<div class="line"><span class="comment"> * @brief Tests to check algorithm implementation.</span></div>
|
||||
<div class="line"><span class="comment"> * @returns void </span></div>
|
||||
<div class="line"><span class="comment"> * @returns void</span></div>
|
||||
<div class="line"><span class="comment"> */</span></div>
|
||||
<div class="line"> <span class="keyword">static</span> <span class="keywordtype">void</span> <a name="a4"></a><a class="code" href="../../dc/d5a/rat__maze_8cpp.html#aa8dca7b867074164d5f45b0f3851269d">test</a>()</div>
|
||||
<div class="line"> {</div>
|
||||
<div class="line"> <a name="_a5"></a><a class="codeRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/basic_ostream.html">std::cout</a> << <span class="stringliteral">"The Runge Kutta function will be tested on the basis of precomputed values\n"</span>;</div>
|
||||
<div class="line"><span class="keyword">static</span> <span class="keywordtype">void</span> <a name="a4"></a><a class="code" href="../../dc/d5a/rat__maze_8cpp.html#aa8dca7b867074164d5f45b0f3851269d">test</a>() {</div>
|
||||
<div class="line"> <a name="_a5"></a><a class="codeRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/basic_ostream.html">std::cout</a> << <span class="stringliteral">"The Runge Kutta function will be tested on the basis of "</span></div>
|
||||
<div class="line"> <span class="stringliteral">"precomputed values\n"</span>;</div>
|
||||
<div class="line"> </div>
|
||||
<div class="line"> <a class="codeRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/basic_ostream.html">std::cout</a> << <span class="stringliteral">"Test 1...."</span> << <span class="stringliteral">"\n"</span>;</div>
|
||||
<div class="line"> <span class="keywordtype">double</span> valfirst=<a class="code" href="../../d1/da6/rungekutta_8cpp.html#a7b9f40c7b5e9749cc550f19be3dc8856">numerical_methods::runge_kutta::rungeKutta</a>(2,3,4,0.2); <span class="comment">// Tests the function with pre calculated values</span></div>
|
||||
<div class="line"> assert(valfirst==3.10363932323749570);</div>
|
||||
<div class="line"> <a class="codeRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/basic_ostream.html">std::cout</a> << <span class="stringliteral">"Passed Test 1\n"</span>;</div>
|
||||
<div class="line"> <a class="codeRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/basic_ostream.html">std::cout</a> << <span class="stringliteral">"Test 1...."</span></div>
|
||||
<div class="line"> << <span class="stringliteral">"\n"</span>;</div>
|
||||
<div class="line"> <span class="keywordtype">double</span> valfirst = <a class="code" href="../../d1/da6/rungekutta_8cpp.html#a7b9f40c7b5e9749cc550f19be3dc8856">numerical_methods::runge_kutta::rungeKutta</a>(</div>
|
||||
<div class="line"> 2, 3, 4, 0.2); <span class="comment">// Tests the function with pre calculated values</span></div>
|
||||
<div class="line"> assert(valfirst == 3.10363932323749570);</div>
|
||||
<div class="line"> <a class="codeRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/basic_ostream.html">std::cout</a> << <span class="stringliteral">"Passed Test 1\n"</span>;</div>
|
||||
<div class="line"> </div>
|
||||
<div class="line"> <a class="codeRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/basic_ostream.html">std::cout</a> << <span class="stringliteral">"Test 2...."</span> << <span class="stringliteral">"\n"</span>;</div>
|
||||
<div class="line"> <span class="keywordtype">double</span> valsec=<a class="code" href="../../d1/da6/rungekutta_8cpp.html#a7b9f40c7b5e9749cc550f19be3dc8856">numerical_methods::runge_kutta::rungeKutta</a>(1,2,5,0.1); <span class="comment">// The value of step changed</span></div>
|
||||
<div class="line"> assert(valsec==3.40600589380261409);</div>
|
||||
<div class="line"> <a class="codeRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/basic_ostream.html">std::cout</a> << <span class="stringliteral">"Passed Test 2\n"</span>;</div>
|
||||
<div class="line"> <a class="codeRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/basic_ostream.html">std::cout</a> << <span class="stringliteral">"Test 2...."</span></div>
|
||||
<div class="line"> << <span class="stringliteral">"\n"</span>;</div>
|
||||
<div class="line"> <span class="keywordtype">double</span> valsec = <a class="code" href="../../d1/da6/rungekutta_8cpp.html#a7b9f40c7b5e9749cc550f19be3dc8856">numerical_methods::runge_kutta::rungeKutta</a>(</div>
|
||||
<div class="line"> 1, 2, 5, 0.1); <span class="comment">// The value of step changed</span></div>
|
||||
<div class="line"> assert(valsec == 3.40600589380261409);</div>
|
||||
<div class="line"> <a class="codeRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/basic_ostream.html">std::cout</a> << <span class="stringliteral">"Passed Test 2\n"</span>;</div>
|
||||
<div class="line"> </div>
|
||||
<div class="line"> <a class="codeRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/basic_ostream.html">std::cout</a> << <span class="stringliteral">"Test 3...."</span> << <span class="stringliteral">"\n"</span>;</div>
|
||||
<div class="line"> <span class="keywordtype">double</span> valthird=<a class="code" href="../../d1/da6/rungekutta_8cpp.html#a7b9f40c7b5e9749cc550f19be3dc8856">numerical_methods::runge_kutta::rungeKutta</a>(-1,3,4,0.1); <span class="comment">// Tested with negative value</span></div>
|
||||
<div class="line"> assert(valthird==2.49251005860244268);</div>
|
||||
<div class="line"> <a class="codeRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/basic_ostream.html">std::cout</a> << <span class="stringliteral">"Passed Test 3\n"</span>;</div>
|
||||
<div class="line"> }</div>
|
||||
<div class="line"> </div>
|
||||
<div class="line"> <span class="comment"></span></div>
|
||||
<div class="line"> <a class="codeRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/basic_ostream.html">std::cout</a> << <span class="stringliteral">"Test 3...."</span></div>
|
||||
<div class="line"> << <span class="stringliteral">"\n"</span>;</div>
|
||||
<div class="line"> <span class="keywordtype">double</span> valthird = <a class="code" href="../../d1/da6/rungekutta_8cpp.html#a7b9f40c7b5e9749cc550f19be3dc8856">numerical_methods::runge_kutta::rungeKutta</a>(</div>
|
||||
<div class="line"> -1, 3, 4, 0.1); <span class="comment">// Tested with negative value</span></div>
|
||||
<div class="line"> assert(valthird == 2.49251005860244268);</div>
|
||||
<div class="line"> <a class="codeRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/basic_ostream.html">std::cout</a> << <span class="stringliteral">"Passed Test 3\n"</span>;</div>
|
||||
<div class="line">}</div>
|
||||
<div class="line"><span class="comment"></span> </div>
|
||||
<div class="line"><span class="comment">/**</span></div>
|
||||
<div class="line"><span class="comment"> * @brief Main function</span></div>
|
||||
<div class="line"><span class="comment"> * @returns 0 on exit </span></div>
|
||||
<div class="line"><span class="comment"> * @returns 0 on exit</span></div>
|
||||
<div class="line"><span class="comment"> */</span></div>
|
||||
<div class="line"><span class="keywordtype">int</span> <a name="a6"></a><a class="code" href="../../d3/d40/graph__coloring_8cpp.html#gae66f6b31b5ad750f1fe042a706a4e3d4">main</a>() </div>
|
||||
<div class="line">{ </div>
|
||||
<div class="line"> </div>
|
||||
<div class="line"><span class="keywordtype">int</span> <a name="a6"></a><a class="code" href="../../d3/d40/graph__coloring_8cpp.html#gae66f6b31b5ad750f1fe042a706a4e3d4">main</a>() {</div>
|
||||
<div class="line"> <a class="code" href="../../dc/d5a/rat__maze_8cpp.html#aa8dca7b867074164d5f45b0f3851269d">test</a>(); <span class="comment">// Execute the tests</span></div>
|
||||
<div class="line"> <span class="keywordflow">return</span> 0; </div>
|
||||
<div class="line">} </div>
|
||||
<div class="line"> <span class="keywordflow">return</span> 0;</div>
|
||||
<div class="line">}</div>
|
||||
</div><!-- fragment --> </div><!-- contents -->
|
||||
</div><!-- doc-content -->
|
||||
<div class="ttc" id="arat__maze_8cpp_html_aa8dca7b867074164d5f45b0f3851269d"><div class="ttname"><a href="../../dc/d5a/rat__maze_8cpp.html#aa8dca7b867074164d5f45b0f3851269d">test</a></div><div class="ttdeci">static void test()</div><div class="ttdoc">Test implementations.</div><div class="ttdef"><b>Definition:</b> rat_maze.cpp:84</div></div>
|
||||
@@ -239,8 +237,8 @@ $(document).ready(function(){initNavTree('dc/dc4/_2_users_2runner_2work_2_c-_plu
|
||||
<div class="ttc" id="abasic_ostream_html"><div class="ttname"><a href="http://en.cppreference.com/w/cpp/io/basic_ostream.html">std::cout</a></div></div>
|
||||
<div class="ttc" id="ahash__search_8cpp_html_a566eaf0ffafd50bc61e644561fd27001"><div class="ttname"><a href="../../d1/df3/hash__search_8cpp.html#a566eaf0ffafd50bc61e644561fd27001">h</a></div><div class="ttdeci">int h(int key)</div><div class="ttdef"><b>Definition:</b> hash_search.cpp:45</div></div>
|
||||
<div class="ttc" id="anamespacerunge__kutta_html"><div class="ttname"><a href="../../d2/de7/namespacerunge__kutta.html">runge_kutta</a></div><div class="ttdoc">Functions for Runge Kutta fourth order method.</div></div>
|
||||
<div class="ttc" id="arungekutta_8cpp_html_a450497475f5607333f9aca8f88901579"><div class="ttname"><a href="../../d1/da6/rungekutta_8cpp.html#a450497475f5607333f9aca8f88901579">change</a></div><div class="ttdeci">static double change(double x, double y)</div><div class="ttdoc">asserting the test functions</div><div class="ttdef"><b>Definition:</b> rungekutta.cpp:31</div></div>
|
||||
<div class="ttc" id="arungekutta_8cpp_html_a7b9f40c7b5e9749cc550f19be3dc8856"><div class="ttname"><a href="../../d1/da6/rungekutta_8cpp.html#a7b9f40c7b5e9749cc550f19be3dc8856">numerical_methods::runge_kutta::rungeKutta</a></div><div class="ttdeci">double rungeKutta(double init_x, const double &init_y, const double &x, const double &h)</div><div class="ttdoc">the Runge Kutta method finds the value of integration of a function in the given limits....</div><div class="ttdef"><b>Definition:</b> rungekutta.cpp:56</div></div>
|
||||
<div class="ttc" id="arungekutta_8cpp_html_a450497475f5607333f9aca8f88901579"><div class="ttname"><a href="../../d1/da6/rungekutta_8cpp.html#a450497475f5607333f9aca8f88901579">change</a></div><div class="ttdeci">static double change(double x, double y)</div><div class="ttdoc">for using the vector container</div><div class="ttdef"><b>Definition:</b> rungekutta.cpp:33</div></div>
|
||||
<div class="ttc" id="arungekutta_8cpp_html_a7b9f40c7b5e9749cc550f19be3dc8856"><div class="ttname"><a href="../../d1/da6/rungekutta_8cpp.html#a7b9f40c7b5e9749cc550f19be3dc8856">numerical_methods::runge_kutta::rungeKutta</a></div><div class="ttdeci">double rungeKutta(double init_x, const double &init_y, const double &x, const double &h)</div><div class="ttdoc">the Runge Kutta method finds the value of integration of a function in the given limits....</div><div class="ttdef"><b>Definition:</b> rungekutta.cpp:57</div></div>
|
||||
<!-- start footer part -->
|
||||
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
|
||||
<ul>
|
||||
|
||||
Reference in New Issue
Block a user