Documentation for 8b1eab204b

This commit is contained in:
realstealthninja
2024-11-04 12:43:05 +00:00
parent 4fb6e622e9
commit a7bccf7d01
6732 changed files with 153919 additions and 365711 deletions

View File

@@ -1,3 +1,4 @@
<!-- HTML header for doxygen 1.12.0-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US">
<head>
@@ -5,10 +6,15 @@
<meta http-equiv="X-UA-Compatible" content="IE=11"/>
<meta name="generator" content="Doxygen 1.12.0"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>Algorithms_in_C++: numerical_methods/ode_forward_euler.cpp File Reference</title>
<title>TheAlgorithms/C++: numerical_methods/ode_forward_euler.cpp File Reference</title>
<link rel="icon" href="../../favicon.svg" type="image/x-icon" />
<link href="../../tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="../../jquery.js"></script>
<script type="text/javascript" src="../../dynsections.js"></script>
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/@xpack-3rd-party/doxygen-awesome-css@2.2.0-1/doxygen-awesome-darkmode-toggle.js"></script>
<script type="text/javascript">
DoxygenAwesomeDarkModeToggle.init()
</script>
<script type="text/javascript" src="../../clipboard.js"></script>
<link href="../../navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="../../navtreedata.js"></script>
@@ -18,14 +24,24 @@
<link href="../../search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="../../search/searchdata.js"></script>
<script type="text/javascript" src="../../search/search.js"></script>
<script type="text/x-mathjax-config">
MathJax.Hub.Config({
extensions: ["tex2jax.js", "TeX/AMSmath.js", "TeX/AMSsymbols.js"],
jax: ["input/TeX","output/HTML-CSS"],
});
<script type="text/javascript">
window.MathJax = {
options: {
ignoreHtmlClass: 'tex2jax_ignore',
processHtmlClass: 'tex2jax_process'
},
loader: {
load: ['[tex]/ams']
},
tex: {
macros: {},
packages: ['base','configmacros','ams']
}
};
</script>
<script type="text/javascript" async="async" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.7/MathJax.js?config=TeX-MML-AM_CHTML/MathJax.js"></script>
<script type="text/javascript" id="MathJax-script" async="async" src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-chtml.js"></script>
<link href="../../doxygen.css" rel="stylesheet" type="text/css" />
<link href="../../doxygen-awesome.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
@@ -33,10 +49,11 @@ MathJax.Hub.Config({
<table cellspacing="0" cellpadding="0">
<tbody>
<tr id="projectrow">
<td id="projectlogo"><img alt="Logo" src="../../project_logo.png"/></td>
<td id="projectalign">
<div id="projectname">Algorithms_in_C++<span id="projectnumber">&#160;1.0.0</span>
<div id="projectname">TheAlgorithms/C++<span id="projectnumber">&#160;1.0.0</span>
</div>
<div id="projectbrief">Set of algorithms implemented in C++.</div>
<div id="projectbrief">All the algorithms implemented in C++</div>
</td>
</tr>
</tbody>
@@ -122,22 +139,24 @@ Include dependency graph for ode_forward_euler.cpp:</div>
<div class="dyncontent">
<div class="center"><iframe scrolling="no" frameborder="0" src="../../dc/dc5/ode__forward__euler_8cpp__incl.svg" width="423" height="126"><p><b>This browser is not able to show SVG: try Firefox, Chrome, Safari, or Opera instead.</b></p></iframe></div>
</div>
</div><table class="memberdecls">
</div>
<p><a href="../../db/dd3/ode__forward__euler_8cpp_source.html">Go to the source code of this file.</a></p>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="func-members" name="func-members"></a>
Functions</h2></td></tr>
<tr class="memitem:abaeae8f62a018d197f0187a1c80a90fe" id="r_abaeae8f62a018d197f0187a1c80a90fe"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="#abaeae8f62a018d197f0187a1c80a90fe">problem</a> (const double &amp;x, <a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/numeric/valarray.html">std::valarray</a>&lt; double &gt; *y, <a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/numeric/valarray.html">std::valarray</a>&lt; double &gt; *dy)</td></tr>
<tr class="memitem:abaeae8f62a018d197f0187a1c80a90fe" id="r_abaeae8f62a018d197f0187a1c80a90fe"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="#abaeae8f62a018d197f0187a1c80a90fe">problem</a> (const double &amp;x, std::valarray&lt; double &gt; *y, std::valarray&lt; double &gt; *dy)</td></tr>
<tr class="memdesc:abaeae8f62a018d197f0187a1c80a90fe"><td class="mdescLeft">&#160;</td><td class="mdescRight">Problem statement for a system with first-order differential equations. Updates the system differential variables. <br /></td></tr>
<tr class="separator:abaeae8f62a018d197f0187a1c80a90fe"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:af3adf7b092a87868917ee5fb4255192b" id="r_af3adf7b092a87868917ee5fb4255192b"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="#af3adf7b092a87868917ee5fb4255192b">exact_solution</a> (const double &amp;x, <a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/numeric/valarray.html">std::valarray</a>&lt; double &gt; *y)</td></tr>
<tr class="memitem:af3adf7b092a87868917ee5fb4255192b" id="r_af3adf7b092a87868917ee5fb4255192b"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="#af3adf7b092a87868917ee5fb4255192b">exact_solution</a> (const double &amp;x, std::valarray&lt; double &gt; *y)</td></tr>
<tr class="memdesc:af3adf7b092a87868917ee5fb4255192b"><td class="mdescLeft">&#160;</td><td class="mdescRight">Exact solution of the problem. Used for solution comparison. <br /></td></tr>
<tr class="separator:af3adf7b092a87868917ee5fb4255192b"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga195d23bbdfcb80e83c9cda45c9ad5723" id="r_ga195d23bbdfcb80e83c9cda45c9ad5723"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../d6/d60/group__ode.html#ga195d23bbdfcb80e83c9cda45c9ad5723">forward_euler_step</a> (const double dx, const double x, <a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/numeric/valarray.html">std::valarray</a>&lt; double &gt; *y, <a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/numeric/valarray.html">std::valarray</a>&lt; double &gt; *dy)</td></tr>
<tr class="memitem:ga195d23bbdfcb80e83c9cda45c9ad5723" id="r_ga195d23bbdfcb80e83c9cda45c9ad5723"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../d6/d60/group__ode.html#ga195d23bbdfcb80e83c9cda45c9ad5723">forward_euler_step</a> (const double dx, const double x, std::valarray&lt; double &gt; *y, std::valarray&lt; double &gt; *dy)</td></tr>
<tr class="memdesc:ga195d23bbdfcb80e83c9cda45c9ad5723"><td class="mdescLeft">&#160;</td><td class="mdescRight">Compute next step approximation using the forward-Euler method. <br /></td></tr>
<tr class="separator:ga195d23bbdfcb80e83c9cda45c9ad5723"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gae0509f8843e2bc42de2abbd00a14b7b9" id="r_gae0509f8843e2bc42de2abbd00a14b7b9"><td class="memItemLeft" align="right" valign="top">double&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../d6/d60/group__ode.html#gae0509f8843e2bc42de2abbd00a14b7b9">forward_euler</a> (double dx, double x0, double x_max, <a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/numeric/valarray.html">std::valarray</a>&lt; double &gt; *y, bool save_to_file=false)</td></tr>
<tr class="memitem:gae0509f8843e2bc42de2abbd00a14b7b9" id="r_gae0509f8843e2bc42de2abbd00a14b7b9"><td class="memItemLeft" align="right" valign="top">double&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../d6/d60/group__ode.html#gae0509f8843e2bc42de2abbd00a14b7b9">forward_euler</a> (double dx, double x0, double x_max, std::valarray&lt; double &gt; *y, bool save_to_file=false)</td></tr>
<tr class="memdesc:gae0509f8843e2bc42de2abbd00a14b7b9"><td class="mdescLeft">&#160;</td><td class="mdescRight">Compute approximation using the forward-Euler method in the given limits. <br /></td></tr>
<tr class="separator:gae0509f8843e2bc42de2abbd00a14b7b9"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:aa13517b8e5de1b75592052db7f7e237f" id="r_aa13517b8e5de1b75592052db7f7e237f"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="#aa13517b8e5de1b75592052db7f7e237f">save_exact_solution</a> (const double &amp;X0, const double &amp;X_MAX, const double &amp;step_size, const <a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/numeric/valarray.html">std::valarray</a>&lt; double &gt; &amp;Y0)</td></tr>
<tr class="memitem:aa13517b8e5de1b75592052db7f7e237f" id="r_aa13517b8e5de1b75592052db7f7e237f"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="#aa13517b8e5de1b75592052db7f7e237f">save_exact_solution</a> (const double &amp;X0, const double &amp;X_MAX, const double &amp;step_size, const std::valarray&lt; double &gt; &amp;Y0)</td></tr>
<tr class="separator:aa13517b8e5de1b75592052db7f7e237f"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a0ddf1224851353fc92bfbff6f499fa97" id="r_a0ddf1224851353fc92bfbff6f499fa97"><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="#a0ddf1224851353fc92bfbff6f499fa97">main</a> (int argc, char *argv[])</td></tr>
<tr class="separator:a0ddf1224851353fc92bfbff6f499fa97"><td class="memSeparator" colspan="2">&#160;</td></tr>
@@ -164,6 +183,8 @@ Functions</h2></td></tr>
<div class="line">dy[0] = y[1];</div>
<div class="line">dy[1] = mu * (1.f - y[0] * y[0]) * y[1] - y[0];</div>
</div><!-- fragment --> <dl class="section see"><dt>See also</dt><dd><a class="el" href="../../d6/dd3/ode__midpoint__euler_8cpp.html" title="Solve a multivariable first order ordinary differential equation (ODEs) using midpoint Euler method">ode_midpoint_euler.cpp</a>, <a class="el" href="../../d3/d06/ode__semi__implicit__euler_8cpp.html" title="Solve a multivariable first order ordinary differential equation (ODEs) using semi implicit Euler met...">ode_semi_implicit_euler.cpp</a> </dd></dl>
<p class="definition">Definition in file <a class="el" href="../../db/dd3/ode__forward__euler_8cpp_source.html">ode_forward_euler.cpp</a>.</p>
</div><h2 class="groupheader">Function Documentation</h2>
<a id="af3adf7b092a87868917ee5fb4255192b" name="af3adf7b092a87868917ee5fb4255192b"></a>
<h2 class="memtitle"><span class="permalink"><a href="#af3adf7b092a87868917ee5fb4255192b">&#9670;&#160;</a></span>exact_solution()</h2>
@@ -179,7 +200,7 @@ Functions</h2></td></tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype"><a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/numeric/valarray.html">std::valarray</a>&lt; double &gt; *</td> <td class="paramname"><span class="paramname"><em>y</em></span>&#160;)</td>
<td class="paramtype">std::valarray&lt; double &gt; *</td> <td class="paramname"><span class="paramname"><em>y</em></span>&#160;)</td>
</tr>
</table>
</div><div class="memdoc">
@@ -192,18 +213,13 @@ Functions</h2></td></tr>
</table>
</dd>
</dl>
<div class="fragment"><div class="line"><span class="lineno"> 67</span> {</div>
<div class="line"><span class="lineno"> 68</span> y[0][0] = <a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/numeric/math/cos.html">std::cos</a>(x);</div>
<div class="line"><span class="lineno"> 69</span> y[0][1] = -<a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/numeric/math/sin.html">std::sin</a>(x);</div>
<div class="line"><span class="lineno"> 70</span>}</div>
<div class="ttc" id="acos_html"><div class="ttname"><a href="http://en.cppreference.com/w/cpp/numeric/math/cos.html">std::cos</a></div><div class="ttdeci">T cos(T... args)</div></div>
<div class="ttc" id="asin_html"><div class="ttname"><a href="http://en.cppreference.com/w/cpp/numeric/math/sin.html">std::sin</a></div><div class="ttdeci">T sin(T... args)</div></div>
</div><!-- fragment --><div class="dynheader">
Here is the call graph for this function:</div>
<div class="dyncontent">
<div class="center"><iframe scrolling="no" frameborder="0" src="../../db/dd3/ode__forward__euler_8cpp_af3adf7b092a87868917ee5fb4255192b_cgraph.svg" width="232" height="86"><p><b>This browser is not able to show SVG: try Firefox, Chrome, Safari, or Opera instead.</b></p></iframe></div>
</div>
<p class="definition">Definition at line <a class="el" href="../../db/dd3/ode__forward__euler_8cpp_source.html#l00067">67</a> of file <a class="el" href="../../db/dd3/ode__forward__euler_8cpp_source.html">ode_forward_euler.cpp</a>.</p>
<div class="fragment"><div class="line"><span class="lineno"> 67</span> {</div>
<div class="line"><span class="lineno"> 68</span> y[0][0] = std::cos(x);</div>
<div class="line"><span class="lineno"> 69</span> y[0][1] = -std::sin(x);</div>
<div class="line"><span class="lineno"> 70</span>}</div>
</div><!-- fragment -->
</div>
</div>
<a id="a0ddf1224851353fc92bfbff6f499fa97" name="a0ddf1224851353fc92bfbff6f499fa97"></a>
@@ -225,41 +241,34 @@ Here is the call graph for this function:</div>
</table>
</div><div class="memdoc">
<p>Main Function </p>
<p class="definition">Definition at line <a class="el" href="../../db/dd3/ode__forward__euler_8cpp_source.html#l00189">189</a> of file <a class="el" href="../../db/dd3/ode__forward__euler_8cpp_source.html">ode_forward_euler.cpp</a>.</p>
<div class="fragment"><div class="line"><span class="lineno"> 189</span> {</div>
<div class="line"><span class="lineno"> 190</span> <span class="keywordtype">double</span> X0 = 0.f; <span class="comment">/* initial value of x0 */</span></div>
<div class="line"><span class="lineno"> 191</span> <span class="keywordtype">double</span> X_MAX = 10.F; <span class="comment">/* upper limit of integration */</span></div>
<div class="line"><span class="lineno"> 192</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/numeric/valarray.html">std::valarray&lt;double&gt;</a> Y0{1.f, 0.f}; <span class="comment">/* initial value Y = y(x = x_0) */</span></div>
<div class="line"><span class="lineno"> 192</span> std::valarray&lt;double&gt; Y0{1.f, 0.f}; <span class="comment">/* initial value Y = y(x = x_0) */</span></div>
<div class="line"><span class="lineno"> 193</span> <span class="keywordtype">double</span> step_size = NAN;</div>
<div class="line"><span class="lineno"> 194</span> </div>
<div class="line"><span class="lineno"> 195</span> <span class="keywordflow">if</span> (argc == 1) {</div>
<div class="line"><span class="lineno"> 196</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/basic_ostream.html">std::cout</a> &lt;&lt; <span class="stringliteral">&quot;\nEnter the step size: &quot;</span>;</div>
<div class="line"><span class="lineno"> 197</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/basic_istream.html">std::cin</a> &gt;&gt; step_size;</div>
<div class="line"><span class="lineno"> 196</span> std::cout &lt;&lt; <span class="stringliteral">&quot;\nEnter the step size: &quot;</span>;</div>
<div class="line"><span class="lineno"> 197</span> std::cin &gt;&gt; step_size;</div>
<div class="line"><span class="lineno"> 198</span> } <span class="keywordflow">else</span> {</div>
<div class="line"><span class="lineno"> 199</span> <span class="comment">// use commandline argument as independent variable step size</span></div>
<div class="line"><span class="lineno"> 200</span> step_size = <a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/string/byte/atof.html">std::atof</a>(argv[1]);</div>
<div class="line"><span class="lineno"> 200</span> step_size = std::atof(argv[1]);</div>
<div class="line"><span class="lineno"> 201</span> }</div>
<div class="line"><span class="lineno"> 202</span> </div>
<div class="line"><span class="lineno"> 203</span> <span class="comment">// get approximate solution</span></div>
<div class="line"><span class="lineno"> 204</span> <span class="keywordtype">double</span> total_time = <a class="code hl_function" href="../../d6/d60/group__ode.html#gae0509f8843e2bc42de2abbd00a14b7b9">forward_euler</a>(step_size, X0, X_MAX, &amp;Y0, <span class="keyword">true</span>);</div>
<div class="line"><span class="lineno"> 205</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/basic_ostream.html">std::cout</a> &lt;&lt; <span class="stringliteral">&quot;\tTime = &quot;</span> &lt;&lt; total_time &lt;&lt; <span class="stringliteral">&quot; ms\n&quot;</span>;</div>
<div class="line"><span class="lineno"> 205</span> std::cout &lt;&lt; <span class="stringliteral">&quot;\tTime = &quot;</span> &lt;&lt; total_time &lt;&lt; <span class="stringliteral">&quot; ms\n&quot;</span>;</div>
<div class="line"><span class="lineno"> 206</span> </div>
<div class="line"><span class="lineno"> 207</span> <span class="comment">/* compute exact solution for comparion */</span></div>
<div class="line"><span class="lineno"> 208</span> <a class="code hl_function" href="#aa13517b8e5de1b75592052db7f7e237f">save_exact_solution</a>(X0, X_MAX, step_size, Y0);</div>
<div class="line"><span class="lineno"> 209</span> </div>
<div class="line"><span class="lineno"> 210</span> <span class="keywordflow">return</span> 0;</div>
<div class="line"><span class="lineno"> 211</span>}</div>
<div class="ttc" id="aatof_html"><div class="ttname"><a href="http://en.cppreference.com/w/cpp/string/byte/atof.html">std::atof</a></div><div class="ttdeci">T atof(T... args)</div></div>
<div class="ttc" id="abasic_istream_html"><div class="ttname"><a href="http://en.cppreference.com/w/cpp/io/basic_istream.html">std::cin</a></div></div>
<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="agroup__ode_html_gae0509f8843e2bc42de2abbd00a14b7b9"><div class="ttname"><a href="../../d6/d60/group__ode.html#gae0509f8843e2bc42de2abbd00a14b7b9">forward_euler</a></div><div class="ttdeci">double forward_euler(double dx, double x0, double x_max, std::valarray&lt; double &gt; *y, bool save_to_file=false)</div><div class="ttdoc">Compute approximation using the forward-Euler method in the given limits.</div><div class="ttdef"><b>Definition</b> ode_forward_euler.cpp:102</div></div>
<div class="ttc" id="aode__forward__euler_8cpp_html_aa13517b8e5de1b75592052db7f7e237f"><div class="ttname"><a href="#aa13517b8e5de1b75592052db7f7e237f">save_exact_solution</a></div><div class="ttdeci">void save_exact_solution(const double &amp;X0, const double &amp;X_MAX, const double &amp;step_size, const std::valarray&lt; double &gt; &amp;Y0)</div><div class="ttdef"><b>Definition</b> ode_forward_euler.cpp:153</div></div>
<div class="ttc" id="avalarray_html"><div class="ttname"><a href="http://en.cppreference.com/w/cpp/numeric/valarray.html">std::valarray</a></div></div>
</div><!-- fragment --><div class="dynheader">
Here is the call graph for this function:</div>
<div class="dyncontent">
<div class="center"><iframe scrolling="no" frameborder="0" src="../../db/dd3/ode__forward__euler_8cpp_a0ddf1224851353fc92bfbff6f499fa97_cgraph.svg" width="564" height="356"><p><b>This browser is not able to show SVG: try Firefox, Chrome, Safari, or Opera instead.</b></p></iframe></div>
</div>
<div class="ttc" id="agroup__ode_html_gae0509f8843e2bc42de2abbd00a14b7b9"><div class="ttname"><a href="../../d6/d60/group__ode.html#gae0509f8843e2bc42de2abbd00a14b7b9">forward_euler</a></div><div class="ttdeci">double forward_euler(double dx, double x0, double x_max, std::valarray&lt; double &gt; *y, bool save_to_file=false)</div><div class="ttdoc">Compute approximation using the forward-Euler method in the given limits.</div><div class="ttdef"><b>Definition</b> <a href="../../db/dd3/ode__forward__euler_8cpp_source.html#l00102">ode_forward_euler.cpp:102</a></div></div>
<div class="ttc" id="aode__forward__euler_8cpp_html_aa13517b8e5de1b75592052db7f7e237f"><div class="ttname"><a href="#aa13517b8e5de1b75592052db7f7e237f">save_exact_solution</a></div><div class="ttdeci">void save_exact_solution(const double &amp;X0, const double &amp;X_MAX, const double &amp;step_size, const std::valarray&lt; double &gt; &amp;Y0)</div><div class="ttdef"><b>Definition</b> <a href="../../db/dd3/ode__forward__euler_8cpp_source.html#l00153">ode_forward_euler.cpp:153</a></div></div>
</div><!-- fragment -->
</div>
</div>
<a id="abaeae8f62a018d197f0187a1c80a90fe" name="abaeae8f62a018d197f0187a1c80a90fe"></a>
@@ -276,12 +285,12 @@ Here is the call graph for this function:</div>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype"><a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/numeric/valarray.html">std::valarray</a>&lt; double &gt; *</td> <td class="paramname"><span class="paramname"><em>y</em></span>, </td>
<td class="paramtype">std::valarray&lt; double &gt; *</td> <td class="paramname"><span class="paramname"><em>y</em></span>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype"><a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/numeric/valarray.html">std::valarray</a>&lt; double &gt; *</td> <td class="paramname"><span class="paramname"><em>dy</em></span>&#160;)</td>
<td class="paramtype">std::valarray&lt; double &gt; *</td> <td class="paramname"><span class="paramname"><em>dy</em></span>&#160;)</td>
</tr>
</table>
</div><div class="memdoc">
@@ -296,6 +305,8 @@ Here is the call graph for this function:</div>
</table>
</dd>
</dl>
<p class="definition">Definition at line <a class="el" href="../../db/dd3/ode__forward__euler_8cpp_source.html#l00054">54</a> of file <a class="el" href="../../db/dd3/ode__forward__euler_8cpp_source.html">ode_forward_euler.cpp</a>.</p>
<div class="fragment"><div class="line"><span class="lineno"> 55</span> {</div>
<div class="line"><span class="lineno"> 56</span> <span class="keyword">const</span> <span class="keywordtype">double</span> omega = 1.F; <span class="comment">// some const for the problem</span></div>
<div class="line"><span class="lineno"> 57</span> (*dy)[0] = (*y)[1]; <span class="comment">// x dot // NOLINT</span></div>
@@ -328,7 +339,7 @@ Here is the call graph for this function:</div>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">const <a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/numeric/valarray.html">std::valarray</a>&lt; double &gt; &amp;</td> <td class="paramname"><span class="paramname"><em>Y0</em></span>&#160;)</td>
<td class="paramtype">const std::valarray&lt; double &gt; &amp;</td> <td class="paramname"><span class="paramname"><em>Y0</em></span>&#160;)</td>
</tr>
</table>
</div><div class="memdoc">
@@ -342,18 +353,20 @@ Here is the call graph for this function:</div>
</table>
</dd>
</dl>
<p class="definition">Definition at line <a class="el" href="../../db/dd3/ode__forward__euler_8cpp_source.html#l00153">153</a> of file <a class="el" href="../../db/dd3/ode__forward__euler_8cpp_source.html">ode_forward_euler.cpp</a>.</p>
<div class="fragment"><div class="line"><span class="lineno"> 155</span> {</div>
<div class="line"><span class="lineno"> 156</span> <span class="keywordtype">double</span> x = X0;</div>
<div class="line"><span class="lineno"> 157</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/numeric/valarray.html">std::valarray&lt;double&gt;</a> y(Y0);</div>
<div class="line"><span class="lineno"> 157</span> std::valarray&lt;double&gt; y(Y0);</div>
<div class="line"><span class="lineno"> 158</span> </div>
<div class="line"><span class="lineno"> 159</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/basic_ofstream.html">std::ofstream</a> fp(<span class="stringliteral">&quot;exact.csv&quot;</span>, std::ostream::out);</div>
<div class="line"><span class="lineno"> 159</span> std::ofstream fp(<span class="stringliteral">&quot;exact.csv&quot;</span>, std::ostream::out);</div>
<div class="line"><span class="lineno"> 160</span> <span class="keywordflow">if</span> (!fp.is_open()) {</div>
<div class="line"><span class="lineno"> 161</span> <a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/c/perror.html">std::perror</a>(<span class="stringliteral">&quot;Error! &quot;</span>);</div>
<div class="line"><span class="lineno"> 161</span> std::perror(<span class="stringliteral">&quot;Error! &quot;</span>);</div>
<div class="line"><span class="lineno"> 162</span> <span class="keywordflow">return</span>;</div>
<div class="line"><span class="lineno"> 163</span> }</div>
<div class="line"><span class="lineno"> 164</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/basic_ostream.html">std::cout</a> &lt;&lt; <span class="stringliteral">&quot;Finding exact solution\n&quot;</span>;</div>
<div class="line"><span class="lineno"> 164</span> std::cout &lt;&lt; <span class="stringliteral">&quot;Finding exact solution\n&quot;</span>;</div>
<div class="line"><span class="lineno"> 165</span> </div>
<div class="line"><span class="lineno"> 166</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/chrono/c/clock_t.html">std::clock_t</a> t1 = <a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/chrono/c/clock.html">std::clock</a>();</div>
<div class="line"><span class="lineno"> 166</span> std::clock_t t1 = std::clock();</div>
<div class="line"><span class="lineno"> 167</span> <span class="keywordflow">do</span> {</div>
<div class="line"><span class="lineno"> 168</span> fp &lt;&lt; x &lt;&lt; <span class="stringliteral">&quot;,&quot;</span>;</div>
<div class="line"><span class="lineno"> 169</span> <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i &lt; y.size() - 1; i++) {</div>
@@ -366,23 +379,14 @@ Here is the call graph for this function:</div>
<div class="line"><span class="lineno"> 176</span> x += step_size;</div>
<div class="line"><span class="lineno"> 177</span> } <span class="keywordflow">while</span> (x &lt;= X_MAX);</div>
<div class="line"><span class="lineno"> 178</span> </div>
<div class="line"><span class="lineno"> 179</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/chrono/c/clock_t.html">std::clock_t</a> t2 = <a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/chrono/c/clock.html">std::clock</a>();</div>
<div class="line"><span class="lineno"> 179</span> std::clock_t t2 = std::clock();</div>
<div class="line"><span class="lineno"> 180</span> <span class="keywordtype">double</span> total_time = <span class="keyword">static_cast&lt;</span><span class="keywordtype">double</span><span class="keyword">&gt;</span>(t2 - t1) / CLOCKS_PER_SEC;</div>
<div class="line"><span class="lineno"> 181</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/basic_ostream.html">std::cout</a> &lt;&lt; <span class="stringliteral">&quot;\tTime = &quot;</span> &lt;&lt; total_time &lt;&lt; <span class="stringliteral">&quot; ms\n&quot;</span>;</div>
<div class="line"><span class="lineno"> 181</span> std::cout &lt;&lt; <span class="stringliteral">&quot;\tTime = &quot;</span> &lt;&lt; total_time &lt;&lt; <span class="stringliteral">&quot; ms\n&quot;</span>;</div>
<div class="line"><span class="lineno"> 182</span> </div>
<div class="line"><span class="lineno"> 183</span> fp.close();</div>
<div class="line"><span class="lineno"> 184</span>}</div>
<div class="ttc" id="abasic_ofstream_html"><div class="ttname"><a href="http://en.cppreference.com/w/cpp/io/basic_ofstream.html">std::ofstream</a></div></div>
<div class="ttc" id="aclock_html"><div class="ttname"><a href="http://en.cppreference.com/w/cpp/chrono/c/clock.html">std::clock</a></div><div class="ttdeci">T clock(T... args)</div></div>
<div class="ttc" id="aclock_t_html"><div class="ttname"><a href="http://en.cppreference.com/w/cpp/chrono/c/clock_t.html">std::clock_t</a></div></div>
<div class="ttc" id="aode__forward__euler_8cpp_html_af3adf7b092a87868917ee5fb4255192b"><div class="ttname"><a href="#af3adf7b092a87868917ee5fb4255192b">exact_solution</a></div><div class="ttdeci">void exact_solution(const double &amp;x, std::valarray&lt; double &gt; *y)</div><div class="ttdoc">Exact solution of the problem. Used for solution comparison.</div><div class="ttdef"><b>Definition</b> ode_forward_euler.cpp:67</div></div>
<div class="ttc" id="aperror_html"><div class="ttname"><a href="http://en.cppreference.com/w/cpp/io/c/perror.html">std::perror</a></div><div class="ttdeci">T perror(T... args)</div></div>
</div><!-- fragment --><div class="dynheader">
Here is the call graph for this function:</div>
<div class="dyncontent">
<div class="center"><iframe scrolling="no" frameborder="0" src="../../db/dd3/ode__forward__euler_8cpp_aa13517b8e5de1b75592052db7f7e237f_cgraph.svg" width="467" height="234"><p><b>This browser is not able to show SVG: try Firefox, Chrome, Safari, or Opera instead.</b></p></iframe></div>
</div>
<div class="ttc" id="aode__forward__euler_8cpp_html_af3adf7b092a87868917ee5fb4255192b"><div class="ttname"><a href="#af3adf7b092a87868917ee5fb4255192b">exact_solution</a></div><div class="ttdeci">void exact_solution(const double &amp;x, std::valarray&lt; double &gt; *y)</div><div class="ttdoc">Exact solution of the problem. Used for solution comparison.</div><div class="ttdef"><b>Definition</b> <a href="../../db/dd3/ode__forward__euler_8cpp_source.html#l00067">ode_forward_euler.cpp:67</a></div></div>
</div><!-- fragment -->
</div>
</div>
</div><!-- contents -->