mirror of
https://github.com/TheAlgorithms/C-Plus-Plus.git
synced 2026-03-23 05:12:40 +08:00
Documentation for 53a6c16730
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=11"/>
|
||||
<meta name="generator" content="Doxygen 1.9.2"/>
|
||||
<meta name="generator" content="Doxygen 1.9.3"/>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1"/>
|
||||
<title>Algorithms_in_C++: numerical_methods/midpoint_integral_method.cpp File Reference</title>
|
||||
<link href="../../tabs.css" rel="stylesheet" type="text/css"/>
|
||||
@@ -30,8 +30,8 @@ MathJax.Hub.Config({
|
||||
<div id="titlearea">
|
||||
<table cellspacing="0" cellpadding="0">
|
||||
<tbody>
|
||||
<tr style="height: 56px;">
|
||||
<td id="projectalign" style="padding-left: 0.5em;">
|
||||
<tr id="projectrow">
|
||||
<td id="projectalign">
|
||||
<div id="projectname">Algorithms_in_C++<span id="projectnumber"> 1.0.0</span>
|
||||
</div>
|
||||
<div id="projectbrief">Set of algorithms implemented in C++.</div>
|
||||
@@ -41,7 +41,7 @@ MathJax.Hub.Config({
|
||||
</table>
|
||||
</div>
|
||||
<!-- end header part -->
|
||||
<!-- Generated by Doxygen 1.9.2 -->
|
||||
<!-- Generated by Doxygen 1.9.3 -->
|
||||
<script type="text/javascript">
|
||||
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt MIT */
|
||||
var searchBox = new SearchBox("searchBox", "../../search",'Search','.html');
|
||||
@@ -177,7 +177,7 @@ Functions</h2></td></tr>
|
||||
</dd>
|
||||
</dl>
|
||||
<dl class="section return"><dt>Returns</dt><dd>the value of the dependent variable yi = f(xi) = sqrt(xi) + ln(xi) </dd></dl>
|
||||
<div class="fragment"><div class="line"><a id="l00090" name="l00090"></a><span class="lineno"> 90</span>{ <span class="keywordflow">return</span> <a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/numeric/math/sqrt.html">std::sqrt</a>(x) + <a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/numeric/math/log.html">std::log</a>(x); }</div>
|
||||
<div class="fragment"><div class="line"><span class="lineno"> 90</span>{ <span class="keywordflow">return</span> <a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/numeric/math/sqrt.html">std::sqrt</a>(x) + <a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/numeric/math/log.html">std::log</a>(x); }</div>
|
||||
<div class="ttc" id="alog_html"><div class="ttname"><a href="http://en.cppreference.com/w/cpp/numeric/math/log.html">std::log</a></div><div class="ttdeci">T log(T... args)</div></div>
|
||||
<div class="ttc" id="asqrt_html"><div class="ttname"><a href="http://en.cppreference.com/w/cpp/numeric/math/sqrt.html">std::sqrt</a></div><div class="ttdeci">T sqrt(T... args)</div></div>
|
||||
</div><!-- fragment --><div class="dynheader">
|
||||
@@ -213,7 +213,7 @@ Here is the call graph for this function:</div>
|
||||
</dd>
|
||||
</dl>
|
||||
<dl class="section return"><dt>Returns</dt><dd>the value of the dependent variable yi = g(xi) = e^(-xi) * (4 - xi^2) </dd></dl>
|
||||
<div class="fragment"><div class="line"><a id="l00097" name="l00097"></a><span class="lineno"> 97</span>{ <span class="keywordflow">return</span> <a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/numeric/math/exp.html">std::exp</a>(-x) * (4 - <a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/numeric/math/pow.html">std::pow</a>(x, 2)); }</div>
|
||||
<div class="fragment"><div class="line"><span class="lineno"> 97</span>{ <span class="keywordflow">return</span> <a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/numeric/math/exp.html">std::exp</a>(-x) * (4 - <a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/numeric/math/pow.html">std::pow</a>(x, 2)); }</div>
|
||||
<div class="ttc" id="aexp_html"><div class="ttname"><a href="http://en.cppreference.com/w/cpp/numeric/math/exp.html">std::exp</a></div><div class="ttdeci">T exp(T... args)</div></div>
|
||||
<div class="ttc" id="apow_html"><div class="ttname"><a href="http://en.cppreference.com/w/cpp/numeric/math/pow.html">std::pow</a></div><div class="ttdeci">T pow(T... args)</div></div>
|
||||
</div><!-- fragment --><div class="dynheader">
|
||||
@@ -249,7 +249,7 @@ Here is the call graph for this function:</div>
|
||||
</dd>
|
||||
</dl>
|
||||
<dl class="section return"><dt>Returns</dt><dd>the value of the dependent variable yi = k(xi) = sqrt(2*xi^3 + 3) </dd></dl>
|
||||
<div class="fragment"><div class="line"><a id="l00103" name="l00103"></a><span class="lineno"> 103</span>{ <span class="keywordflow">return</span> <a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/numeric/math/sqrt.html">std::sqrt</a>(2 * <a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/numeric/math/pow.html">std::pow</a>(x, 3) + 3); }</div>
|
||||
<div class="fragment"><div class="line"><span class="lineno"> 103</span>{ <span class="keywordflow">return</span> <a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/numeric/math/sqrt.html">std::sqrt</a>(2 * <a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/numeric/math/pow.html">std::pow</a>(x, 3) + 3); }</div>
|
||||
</div><!-- fragment --><div class="dynheader">
|
||||
Here is the call graph for this function:</div>
|
||||
<div class="dyncontent">
|
||||
@@ -283,7 +283,7 @@ Here is the call graph for this function:</div>
|
||||
</dd>
|
||||
</dl>
|
||||
<dl class="section return"><dt>Returns</dt><dd>the value of the dependent variable yi = l(xi) = xi + ln(2*xi + 1) </dd></dl>
|
||||
<div class="fragment"><div class="line"><a id="l00109" name="l00109"></a><span class="lineno"> 109</span>{ <span class="keywordflow">return</span> x + <a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/numeric/math/log.html">std::log</a>(2 * x + 1); }</div>
|
||||
<div class="fragment"><div class="line"><span class="lineno"> 109</span>{ <span class="keywordflow">return</span> x + <a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/numeric/math/log.html">std::log</a>(2 * x + 1); }</div>
|
||||
</div><!-- fragment --><div class="dynheader">
|
||||
Here is the call graph for this function:</div>
|
||||
<div class="dyncontent">
|
||||
@@ -333,44 +333,44 @@ Here is the call graph for this function:</div>
|
||||
<p >Starting and ending point of the integration in</p>
|
||||
<p >the real axis</p>
|
||||
<p >Step, calculated by a, b and N</p>
|
||||
<div class="fragment"><div class="line"><a id="l00162" name="l00162"></a><span class="lineno"> 162</span> {</div>
|
||||
<div class="line"><a id="l00163" name="l00163"></a><span class="lineno"> 163</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/types/integer.html">std::int32_t</a> <a class="code hl_variable" href="../../d6/d42/data__structures_2sparse__table_8cpp.html#a10f3ffb3f6f7e1b83d556b9c8de89a5d">N</a> =</div>
|
||||
<div class="line"><a id="l00164" name="l00164"></a><span class="lineno"> 164</span> 16; <span class="comment">/// Number of intervals to divide the integration interval.</span><span class="comment"></span></div>
|
||||
<div class="line"><a id="l00165" name="l00165"></a><span class="lineno"> 165</span><span class="comment"> /// MUST BE EVEN</span></div>
|
||||
<div class="line"><a id="l00166" name="l00166"></a><span class="lineno"> 166</span><span class="comment"></span> <span class="keywordtype">double</span> a = 1, b = 3; <span class="comment">/// Starting and ending point of the integration in</span><span class="comment"></span></div>
|
||||
<div class="line"><a id="l00167" name="l00167"></a><span class="lineno"> 167</span><span class="comment"> /// the real axis</span></div>
|
||||
<div class="line"><a id="l00168" name="l00168"></a><span class="lineno"> 168</span><span class="comment"></span> <span class="keywordtype">double</span> <a class="code hl_function" href="../../d1/df3/hash__search_8cpp.html#a566eaf0ffafd50bc61e644561fd27001">h</a> = NAN; <span class="comment">/// Step, calculated by a, b and N</span></div>
|
||||
<div class="line"><a id="l00169" name="l00169"></a><span class="lineno"> 169</span> </div>
|
||||
<div class="line"><a id="l00170" name="l00170"></a><span class="lineno"> 170</span> <span class="keywordtype">bool</span> used_argv_parameters =</div>
|
||||
<div class="line"><a id="l00171" name="l00171"></a><span class="lineno"> 171</span> <span class="keyword">false</span>; <span class="comment">// If argv parameters are used then the assert must be omitted</span></div>
|
||||
<div class="line"><a id="l00172" name="l00172"></a><span class="lineno"> 172</span> <span class="comment">// for the test cases</span></div>
|
||||
<div class="line"><a id="l00173" name="l00173"></a><span class="lineno"> 173</span> </div>
|
||||
<div class="line"><a id="l00174" name="l00174"></a><span class="lineno"> 174</span> <span class="comment">// Get user input (by the command line parameters or the console after</span></div>
|
||||
<div class="line"><a id="l00175" name="l00175"></a><span class="lineno"> 175</span> <span class="comment">// displaying messages)</span></div>
|
||||
<div class="line"><a id="l00176" name="l00176"></a><span class="lineno"> 176</span> <span class="keywordflow">if</span> (argc == 4) {</div>
|
||||
<div class="line"><a id="l00177" name="l00177"></a><span class="lineno"> 177</span> <a class="code hl_variable" href="../../d6/d42/data__structures_2sparse__table_8cpp.html#a10f3ffb3f6f7e1b83d556b9c8de89a5d">N</a> = <a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/string/byte/atoi.html">std::atoi</a>(argv[1]);</div>
|
||||
<div class="line"><a id="l00178" name="l00178"></a><span class="lineno"> 178</span> a = <a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/string/byte/atof.html">std::atof</a>(argv[2]);</div>
|
||||
<div class="line"><a id="l00179" name="l00179"></a><span class="lineno"> 179</span> b = <a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/string/byte/atof.html">std::atof</a>(argv[3]);</div>
|
||||
<div class="line"><a id="l00180" name="l00180"></a><span class="lineno"> 180</span> <span class="comment">// Check if a<b else abort</span></div>
|
||||
<div class="line"><a id="l00181" name="l00181"></a><span class="lineno"> 181</span> assert(a < b && <span class="stringliteral">"a has to be less than b"</span>);</div>
|
||||
<div class="line"><a id="l00182" name="l00182"></a><span class="lineno"> 182</span> assert(N > 0 && <span class="stringliteral">"N has to be > 0"</span>);</div>
|
||||
<div class="line"><a id="l00183" name="l00183"></a><span class="lineno"> 183</span> <span class="keywordflow">if</span> (N < 4 || a != 1 || b != 3) {</div>
|
||||
<div class="line"><a id="l00184" name="l00184"></a><span class="lineno"> 184</span> used_argv_parameters = <span class="keyword">true</span>;</div>
|
||||
<div class="line"><a id="l00185" name="l00185"></a><span class="lineno"> 185</span> }</div>
|
||||
<div class="line"><a id="l00186" name="l00186"></a><span class="lineno"> 186</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/basic_ostream.html">std::cout</a> << <span class="stringliteral">"You selected N="</span> << <a class="code hl_variable" href="../../d6/d42/data__structures_2sparse__table_8cpp.html#a10f3ffb3f6f7e1b83d556b9c8de89a5d">N</a> << <span class="stringliteral">", a="</span> << a << <span class="stringliteral">", b="</span> << b</div>
|
||||
<div class="line"><a id="l00187" name="l00187"></a><span class="lineno"> 187</span> << <a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/manip/endl.html">std::endl</a>;</div>
|
||||
<div class="line"><a id="l00188" name="l00188"></a><span class="lineno"> 188</span> } <span class="keywordflow">else</span> {</div>
|
||||
<div class="line"><a id="l00189" name="l00189"></a><span class="lineno"> 189</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/basic_ostream.html">std::cout</a> << <span class="stringliteral">"Default N="</span> << <a class="code hl_variable" href="../../d6/d42/data__structures_2sparse__table_8cpp.html#a10f3ffb3f6f7e1b83d556b9c8de89a5d">N</a> << <span class="stringliteral">", a="</span> << a << <span class="stringliteral">", b="</span> << b</div>
|
||||
<div class="line"><a id="l00190" name="l00190"></a><span class="lineno"> 190</span> << <a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/manip/endl.html">std::endl</a>;</div>
|
||||
<div class="line"><a id="l00191" name="l00191"></a><span class="lineno"> 191</span> }</div>
|
||||
<div class="line"><a id="l00192" name="l00192"></a><span class="lineno"> 192</span> </div>
|
||||
<div class="line"><a id="l00193" name="l00193"></a><span class="lineno"> 193</span> <span class="comment">// Find the step</span></div>
|
||||
<div class="line"><a id="l00194" name="l00194"></a><span class="lineno"> 194</span> <a class="code hl_function" href="../../d1/df3/hash__search_8cpp.html#a566eaf0ffafd50bc61e644561fd27001">h</a> = (b - a) / N;</div>
|
||||
<div class="line"><a id="l00195" name="l00195"></a><span class="lineno"> 195</span> </div>
|
||||
<div class="line"><a id="l00196" name="l00196"></a><span class="lineno"> 196</span> <a class="code hl_function" href="../../df/d11/midpoint__integral__method_8cpp.html#a2ae48a41e43dc6ab11b962742349646e">test</a>(N, <a class="code hl_function" href="../../d1/df3/hash__search_8cpp.html#a566eaf0ffafd50bc61e644561fd27001">h</a>, a, b, used_argv_parameters); <span class="comment">// run self-test implementations</span></div>
|
||||
<div class="line"><a id="l00197" name="l00197"></a><span class="lineno"> 197</span> </div>
|
||||
<div class="line"><a id="l00198" name="l00198"></a><span class="lineno"> 198</span> <span class="keywordflow">return</span> 0;</div>
|
||||
<div class="line"><a id="l00199" name="l00199"></a><span class="lineno"> 199</span>}</div>
|
||||
<div class="fragment"><div class="line"><span class="lineno"> 162</span> {</div>
|
||||
<div class="line"><span class="lineno"> 163</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/types/integer.html">std::int32_t</a> <a class="code hl_variable" href="../../d6/d42/data__structures_2sparse__table_8cpp.html#a10f3ffb3f6f7e1b83d556b9c8de89a5d">N</a> =</div>
|
||||
<div class="line"><span class="lineno"> 164</span> 16; <span class="comment">/// Number of intervals to divide the integration interval.</span><span class="comment"></span></div>
|
||||
<div class="line"><span class="lineno"> 165</span><span class="comment"> /// MUST BE EVEN</span></div>
|
||||
<div class="line"><span class="lineno"> 166</span><span class="comment"></span> <span class="keywordtype">double</span> a = 1, b = 3; <span class="comment">/// Starting and ending point of the integration in</span><span class="comment"></span></div>
|
||||
<div class="line"><span class="lineno"> 167</span><span class="comment"> /// the real axis</span></div>
|
||||
<div class="line"><span class="lineno"> 168</span><span class="comment"></span> <span class="keywordtype">double</span> <a class="code hl_function" href="../../d1/df3/hash__search_8cpp.html#a566eaf0ffafd50bc61e644561fd27001">h</a> = NAN; <span class="comment">/// Step, calculated by a, b and N</span></div>
|
||||
<div class="line"><span class="lineno"> 169</span> </div>
|
||||
<div class="line"><span class="lineno"> 170</span> <span class="keywordtype">bool</span> used_argv_parameters =</div>
|
||||
<div class="line"><span class="lineno"> 171</span> <span class="keyword">false</span>; <span class="comment">// If argv parameters are used then the assert must be omitted</span></div>
|
||||
<div class="line"><span class="lineno"> 172</span> <span class="comment">// for the test cases</span></div>
|
||||
<div class="line"><span class="lineno"> 173</span> </div>
|
||||
<div class="line"><span class="lineno"> 174</span> <span class="comment">// Get user input (by the command line parameters or the console after</span></div>
|
||||
<div class="line"><span class="lineno"> 175</span> <span class="comment">// displaying messages)</span></div>
|
||||
<div class="line"><span class="lineno"> 176</span> <span class="keywordflow">if</span> (argc == 4) {</div>
|
||||
<div class="line"><span class="lineno"> 177</span> <a class="code hl_variable" href="../../d6/d42/data__structures_2sparse__table_8cpp.html#a10f3ffb3f6f7e1b83d556b9c8de89a5d">N</a> = <a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/string/byte/atoi.html">std::atoi</a>(argv[1]);</div>
|
||||
<div class="line"><span class="lineno"> 178</span> a = <a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/string/byte/atof.html">std::atof</a>(argv[2]);</div>
|
||||
<div class="line"><span class="lineno"> 179</span> b = <a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/string/byte/atof.html">std::atof</a>(argv[3]);</div>
|
||||
<div class="line"><span class="lineno"> 180</span> <span class="comment">// Check if a<b else abort</span></div>
|
||||
<div class="line"><span class="lineno"> 181</span> assert(a < b && <span class="stringliteral">"a has to be less than b"</span>);</div>
|
||||
<div class="line"><span class="lineno"> 182</span> assert(N > 0 && <span class="stringliteral">"N has to be > 0"</span>);</div>
|
||||
<div class="line"><span class="lineno"> 183</span> <span class="keywordflow">if</span> (N < 4 || a != 1 || b != 3) {</div>
|
||||
<div class="line"><span class="lineno"> 184</span> used_argv_parameters = <span class="keyword">true</span>;</div>
|
||||
<div class="line"><span class="lineno"> 185</span> }</div>
|
||||
<div class="line"><span class="lineno"> 186</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/basic_ostream.html">std::cout</a> << <span class="stringliteral">"You selected N="</span> << <a class="code hl_variable" href="../../d6/d42/data__structures_2sparse__table_8cpp.html#a10f3ffb3f6f7e1b83d556b9c8de89a5d">N</a> << <span class="stringliteral">", a="</span> << a << <span class="stringliteral">", b="</span> << b</div>
|
||||
<div class="line"><span class="lineno"> 187</span> << <a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/manip/endl.html">std::endl</a>;</div>
|
||||
<div class="line"><span class="lineno"> 188</span> } <span class="keywordflow">else</span> {</div>
|
||||
<div class="line"><span class="lineno"> 189</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/basic_ostream.html">std::cout</a> << <span class="stringliteral">"Default N="</span> << <a class="code hl_variable" href="../../d6/d42/data__structures_2sparse__table_8cpp.html#a10f3ffb3f6f7e1b83d556b9c8de89a5d">N</a> << <span class="stringliteral">", a="</span> << a << <span class="stringliteral">", b="</span> << b</div>
|
||||
<div class="line"><span class="lineno"> 190</span> << <a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/manip/endl.html">std::endl</a>;</div>
|
||||
<div class="line"><span class="lineno"> 191</span> }</div>
|
||||
<div class="line"><span class="lineno"> 192</span> </div>
|
||||
<div class="line"><span class="lineno"> 193</span> <span class="comment">// Find the step</span></div>
|
||||
<div class="line"><span class="lineno"> 194</span> <a class="code hl_function" href="../../d1/df3/hash__search_8cpp.html#a566eaf0ffafd50bc61e644561fd27001">h</a> = (b - a) / N;</div>
|
||||
<div class="line"><span class="lineno"> 195</span> </div>
|
||||
<div class="line"><span class="lineno"> 196</span> <a class="code hl_function" href="../../df/d11/midpoint__integral__method_8cpp.html#a2ae48a41e43dc6ab11b962742349646e">test</a>(N, <a class="code hl_function" href="../../d1/df3/hash__search_8cpp.html#a566eaf0ffafd50bc61e644561fd27001">h</a>, a, b, used_argv_parameters); <span class="comment">// run self-test implementations</span></div>
|
||||
<div class="line"><span class="lineno"> 197</span> </div>
|
||||
<div class="line"><span class="lineno"> 198</span> <span class="keywordflow">return</span> 0;</div>
|
||||
<div class="line"><span class="lineno"> 199</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="aatoi_html"><div class="ttname"><a href="http://en.cppreference.com/w/cpp/string/byte/atoi.html">std::atoi</a></div><div class="ttdeci">T atoi(T... args)</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>
|
||||
@@ -437,37 +437,37 @@ Here is the call graph for this function:</div>
|
||||
</dd>
|
||||
</dl>
|
||||
<dl class="section return"><dt>Returns</dt><dd>the result of the integration </dd></dl>
|
||||
<div class="fragment"><div class="line"><a id="l00053" name="l00053"></a><span class="lineno"> 53</span> {</div>
|
||||
<div class="line"><a id="l00054" name="l00054"></a><span class="lineno"> 54</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/map.html">std::map<int, double></a></div>
|
||||
<div class="line"><a id="l00055" name="l00055"></a><span class="lineno"> 55</span> data_table; <span class="comment">// Contains the data points, key: i, value: f(xi)</span></div>
|
||||
<div class="line"><a id="l00056" name="l00056"></a><span class="lineno"> 56</span> <span class="keywordtype">double</span> xi = a; <span class="comment">// Initialize xi to the starting point x0 = a</span></div>
|
||||
<div class="line"><a id="l00057" name="l00057"></a><span class="lineno"> 57</span> </div>
|
||||
<div class="line"><a id="l00058" name="l00058"></a><span class="lineno"> 58</span> <span class="comment">// Create the data table</span></div>
|
||||
<div class="line"><a id="l00059" name="l00059"></a><span class="lineno"> 59</span> <span class="comment">// Loop from x0 to xN-1</span></div>
|
||||
<div class="line"><a id="l00060" name="l00060"></a><span class="lineno"> 60</span> <span class="keywordtype">double</span> temp = NAN;</div>
|
||||
<div class="line"><a id="l00061" name="l00061"></a><span class="lineno"> 61</span> <span class="keywordflow">for</span> (<a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/types/integer.html">std::int32_t</a> i = 0; i < <a class="code hl_variable" href="../../d6/d42/data__structures_2sparse__table_8cpp.html#a10f3ffb3f6f7e1b83d556b9c8de89a5d">N</a>; i++) {</div>
|
||||
<div class="line"><a id="l00062" name="l00062"></a><span class="lineno"> 62</span> temp = func(xi + <a class="code hl_function" href="../../d1/df3/hash__search_8cpp.html#a566eaf0ffafd50bc61e644561fd27001">h</a> / 2); <span class="comment">// find f(xi+h/2)</span></div>
|
||||
<div class="line"><a id="l00063" name="l00063"></a><span class="lineno"> 63</span> data_table.<a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/map/insert.html">insert</a>(</div>
|
||||
<div class="line"><a id="l00064" name="l00064"></a><span class="lineno"> 64</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/utility/pair.html">std::pair<std::int32_t, double></a>(i, temp)); <span class="comment">// add i and f(xi)</span></div>
|
||||
<div class="line"><a id="l00065" name="l00065"></a><span class="lineno"> 65</span> xi += <a class="code hl_function" href="../../d1/df3/hash__search_8cpp.html#a566eaf0ffafd50bc61e644561fd27001">h</a>; <span class="comment">// Get the next point xi for the next iteration</span></div>
|
||||
<div class="line"><a id="l00066" name="l00066"></a><span class="lineno"> 66</span> }</div>
|
||||
<div class="line"><a id="l00067" name="l00067"></a><span class="lineno"> 67</span> </div>
|
||||
<div class="line"><a id="l00068" name="l00068"></a><span class="lineno"> 68</span> <span class="comment">// Evaluate the integral.</span></div>
|
||||
<div class="line"><a id="l00069" name="l00069"></a><span class="lineno"> 69</span> <span class="comment">// Remember: {f(x0+h/2) + f(x1+h/2) + ... + f(xN-1+h/2)}</span></div>
|
||||
<div class="line"><a id="l00070" name="l00070"></a><span class="lineno"> 70</span> <span class="keywordtype">double</span> evaluate_integral = 0;</div>
|
||||
<div class="line"><a id="l00071" name="l00071"></a><span class="lineno"> 71</span> <span class="keywordflow">for</span> (<a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/types/integer.html">std::int32_t</a> i = 0; i < <a class="code hl_variable" href="../../d6/d42/data__structures_2sparse__table_8cpp.html#a10f3ffb3f6f7e1b83d556b9c8de89a5d">N</a>; i++) evaluate_integral += data_table.<a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/map/at.html">at</a>(i);</div>
|
||||
<div class="line"><a id="l00072" name="l00072"></a><span class="lineno"> 72</span> </div>
|
||||
<div class="line"><a id="l00073" name="l00073"></a><span class="lineno"> 73</span> <span class="comment">// Multiply by the coefficient h</span></div>
|
||||
<div class="line"><a id="l00074" name="l00074"></a><span class="lineno"> 74</span> evaluate_integral *= <a class="code hl_function" href="../../d1/df3/hash__search_8cpp.html#a566eaf0ffafd50bc61e644561fd27001">h</a>;</div>
|
||||
<div class="line"><a id="l00075" name="l00075"></a><span class="lineno"> 75</span> </div>
|
||||
<div class="line"><a id="l00076" name="l00076"></a><span class="lineno"> 76</span> <span class="comment">// If the result calculated is nan, then the user has given wrong input</span></div>
|
||||
<div class="line"><a id="l00077" name="l00077"></a><span class="lineno"> 77</span> <span class="comment">// interval.</span></div>
|
||||
<div class="line"><a id="l00078" name="l00078"></a><span class="lineno"> 78</span> assert(!<a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/numeric/math/isnan.html">std::isnan</a>(evaluate_integral) &&</div>
|
||||
<div class="line"><a id="l00079" name="l00079"></a><span class="lineno"> 79</span> <span class="stringliteral">"The definite integral can't be evaluated. Check the validity of "</span></div>
|
||||
<div class="line"><a id="l00080" name="l00080"></a><span class="lineno"> 80</span> <span class="stringliteral">"your input.\n"</span>);</div>
|
||||
<div class="line"><a id="l00081" name="l00081"></a><span class="lineno"> 81</span> <span class="comment">// Else return</span></div>
|
||||
<div class="line"><a id="l00082" name="l00082"></a><span class="lineno"> 82</span> <span class="keywordflow">return</span> evaluate_integral;</div>
|
||||
<div class="line"><a id="l00083" name="l00083"></a><span class="lineno"> 83</span>}</div>
|
||||
<div class="fragment"><div class="line"><span class="lineno"> 53</span> {</div>
|
||||
<div class="line"><span class="lineno"> 54</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/map.html">std::map<int, double></a></div>
|
||||
<div class="line"><span class="lineno"> 55</span> data_table; <span class="comment">// Contains the data points, key: i, value: f(xi)</span></div>
|
||||
<div class="line"><span class="lineno"> 56</span> <span class="keywordtype">double</span> xi = a; <span class="comment">// Initialize xi to the starting point x0 = a</span></div>
|
||||
<div class="line"><span class="lineno"> 57</span> </div>
|
||||
<div class="line"><span class="lineno"> 58</span> <span class="comment">// Create the data table</span></div>
|
||||
<div class="line"><span class="lineno"> 59</span> <span class="comment">// Loop from x0 to xN-1</span></div>
|
||||
<div class="line"><span class="lineno"> 60</span> <span class="keywordtype">double</span> temp = NAN;</div>
|
||||
<div class="line"><span class="lineno"> 61</span> <span class="keywordflow">for</span> (<a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/types/integer.html">std::int32_t</a> i = 0; i < <a class="code hl_variable" href="../../d6/d42/data__structures_2sparse__table_8cpp.html#a10f3ffb3f6f7e1b83d556b9c8de89a5d">N</a>; i++) {</div>
|
||||
<div class="line"><span class="lineno"> 62</span> temp = func(xi + <a class="code hl_function" href="../../d1/df3/hash__search_8cpp.html#a566eaf0ffafd50bc61e644561fd27001">h</a> / 2); <span class="comment">// find f(xi+h/2)</span></div>
|
||||
<div class="line"><span class="lineno"> 63</span> data_table.<a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/map/insert.html">insert</a>(</div>
|
||||
<div class="line"><span class="lineno"> 64</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/utility/pair.html">std::pair<std::int32_t, double></a>(i, temp)); <span class="comment">// add i and f(xi)</span></div>
|
||||
<div class="line"><span class="lineno"> 65</span> xi += <a class="code hl_function" href="../../d1/df3/hash__search_8cpp.html#a566eaf0ffafd50bc61e644561fd27001">h</a>; <span class="comment">// Get the next point xi for the next iteration</span></div>
|
||||
<div class="line"><span class="lineno"> 66</span> }</div>
|
||||
<div class="line"><span class="lineno"> 67</span> </div>
|
||||
<div class="line"><span class="lineno"> 68</span> <span class="comment">// Evaluate the integral.</span></div>
|
||||
<div class="line"><span class="lineno"> 69</span> <span class="comment">// Remember: {f(x0+h/2) + f(x1+h/2) + ... + f(xN-1+h/2)}</span></div>
|
||||
<div class="line"><span class="lineno"> 70</span> <span class="keywordtype">double</span> evaluate_integral = 0;</div>
|
||||
<div class="line"><span class="lineno"> 71</span> <span class="keywordflow">for</span> (<a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/types/integer.html">std::int32_t</a> i = 0; i < <a class="code hl_variable" href="../../d6/d42/data__structures_2sparse__table_8cpp.html#a10f3ffb3f6f7e1b83d556b9c8de89a5d">N</a>; i++) evaluate_integral += data_table.<a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/map/at.html">at</a>(i);</div>
|
||||
<div class="line"><span class="lineno"> 72</span> </div>
|
||||
<div class="line"><span class="lineno"> 73</span> <span class="comment">// Multiply by the coefficient h</span></div>
|
||||
<div class="line"><span class="lineno"> 74</span> evaluate_integral *= <a class="code hl_function" href="../../d1/df3/hash__search_8cpp.html#a566eaf0ffafd50bc61e644561fd27001">h</a>;</div>
|
||||
<div class="line"><span class="lineno"> 75</span> </div>
|
||||
<div class="line"><span class="lineno"> 76</span> <span class="comment">// If the result calculated is nan, then the user has given wrong input</span></div>
|
||||
<div class="line"><span class="lineno"> 77</span> <span class="comment">// interval.</span></div>
|
||||
<div class="line"><span class="lineno"> 78</span> assert(!<a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/numeric/math/isnan.html">std::isnan</a>(evaluate_integral) &&</div>
|
||||
<div class="line"><span class="lineno"> 79</span> <span class="stringliteral">"The definite integral can't be evaluated. Check the validity of "</span></div>
|
||||
<div class="line"><span class="lineno"> 80</span> <span class="stringliteral">"your input.\n"</span>);</div>
|
||||
<div class="line"><span class="lineno"> 81</span> <span class="comment">// Else return</span></div>
|
||||
<div class="line"><span class="lineno"> 82</span> <span class="keywordflow">return</span> evaluate_integral;</div>
|
||||
<div class="line"><span class="lineno"> 83</span>}</div>
|
||||
<div class="ttc" id="aat_html"><div class="ttname"><a href="http://en.cppreference.com/w/cpp/container/map/at.html">std::map::at</a></div><div class="ttdeci">T at(T... args)</div></div>
|
||||
<div class="ttc" id="ainsert_html"><div class="ttname"><a href="http://en.cppreference.com/w/cpp/container/map/insert.html">std::map::insert</a></div><div class="ttdeci">T insert(T... args)</div></div>
|
||||
<div class="ttc" id="aisnan_html"><div class="ttname"><a href="http://en.cppreference.com/w/cpp/numeric/math/isnan.html">std::isnan</a></div><div class="ttdeci">T isnan(T... args)</div></div>
|
||||
@@ -545,37 +545,37 @@ Here is the call graph for this function:</div>
|
||||
</table>
|
||||
</dd>
|
||||
</dl>
|
||||
<div class="fragment"><div class="line"><a id="l00124" name="l00124"></a><span class="lineno"> 124</span> {</div>
|
||||
<div class="line"><a id="l00125" name="l00125"></a><span class="lineno"> 125</span> <span class="comment">// Call midpoint() for each of the test functions f, g, k, l</span></div>
|
||||
<div class="line"><a id="l00126" name="l00126"></a><span class="lineno"> 126</span> <span class="comment">// Assert with two decimal point precision</span></div>
|
||||
<div class="line"><a id="l00127" name="l00127"></a><span class="lineno"> 127</span> <span class="keywordtype">double</span> result_f = <a class="code hl_function" href="../../df/d11/midpoint__integral__method_8cpp.html#a7072493d1f0f8a91b2a71d4cc456c09c">numerical_methods::midpoint_rule::midpoint</a>(</div>
|
||||
<div class="line"><a id="l00128" name="l00128"></a><span class="lineno"> 128</span> N, <a class="code hl_function" href="../../d1/df3/hash__search_8cpp.html#a566eaf0ffafd50bc61e644561fd27001">h</a>, a, numerical_methods::midpoint_rule::f);</div>
|
||||
<div class="line"><a id="l00129" name="l00129"></a><span class="lineno"> 129</span> assert((used_argv_parameters || (result_f >= 4.09 && result_f <= 4.10)) &&</div>
|
||||
<div class="line"><a id="l00130" name="l00130"></a><span class="lineno"> 130</span> <span class="stringliteral">"The result of f(x) is wrong"</span>);</div>
|
||||
<div class="line"><a id="l00131" name="l00131"></a><span class="lineno"> 131</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/basic_ostream.html">std::cout</a> << <span class="stringliteral">"The result of integral f(x) on interval ["</span> << a << <span class="stringliteral">", "</span> << b</div>
|
||||
<div class="line"><a id="l00132" name="l00132"></a><span class="lineno"> 132</span> << <span class="stringliteral">"] is equal to: "</span> << result_f << <a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/manip/endl.html">std::endl</a>;</div>
|
||||
<div class="line"><a id="l00133" name="l00133"></a><span class="lineno"> 133</span> </div>
|
||||
<div class="line"><a id="l00134" name="l00134"></a><span class="lineno"> 134</span> <span class="keywordtype">double</span> result_g = <a class="code hl_function" href="../../df/d11/midpoint__integral__method_8cpp.html#a7072493d1f0f8a91b2a71d4cc456c09c">numerical_methods::midpoint_rule::midpoint</a>(</div>
|
||||
<div class="line"><a id="l00135" name="l00135"></a><span class="lineno"> 135</span> N, <a class="code hl_function" href="../../d1/df3/hash__search_8cpp.html#a566eaf0ffafd50bc61e644561fd27001">h</a>, a, numerical_methods::midpoint_rule::g);</div>
|
||||
<div class="line"><a id="l00136" name="l00136"></a><span class="lineno"> 136</span> assert((used_argv_parameters || (result_g >= 0.27 && result_g <= 0.28)) &&</div>
|
||||
<div class="line"><a id="l00137" name="l00137"></a><span class="lineno"> 137</span> <span class="stringliteral">"The result of g(x) is wrong"</span>);</div>
|
||||
<div class="line"><a id="l00138" name="l00138"></a><span class="lineno"> 138</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/basic_ostream.html">std::cout</a> << <span class="stringliteral">"The result of integral g(x) on interval ["</span> << a << <span class="stringliteral">", "</span> << b</div>
|
||||
<div class="line"><a id="l00139" name="l00139"></a><span class="lineno"> 139</span> << <span class="stringliteral">"] is equal to: "</span> << result_g << <a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/manip/endl.html">std::endl</a>;</div>
|
||||
<div class="line"><a id="l00140" name="l00140"></a><span class="lineno"> 140</span> </div>
|
||||
<div class="line"><a id="l00141" name="l00141"></a><span class="lineno"> 141</span> <span class="keywordtype">double</span> result_k = <a class="code hl_function" href="../../df/d11/midpoint__integral__method_8cpp.html#a7072493d1f0f8a91b2a71d4cc456c09c">numerical_methods::midpoint_rule::midpoint</a>(</div>
|
||||
<div class="line"><a id="l00142" name="l00142"></a><span class="lineno"> 142</span> N, <a class="code hl_function" href="../../d1/df3/hash__search_8cpp.html#a566eaf0ffafd50bc61e644561fd27001">h</a>, a, numerical_methods::midpoint_rule::k);</div>
|
||||
<div class="line"><a id="l00143" name="l00143"></a><span class="lineno"> 143</span> assert((used_argv_parameters || (result_k >= 9.06 && result_k <= 9.07)) &&</div>
|
||||
<div class="line"><a id="l00144" name="l00144"></a><span class="lineno"> 144</span> <span class="stringliteral">"The result of k(x) is wrong"</span>);</div>
|
||||
<div class="line"><a id="l00145" name="l00145"></a><span class="lineno"> 145</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/basic_ostream.html">std::cout</a> << <span class="stringliteral">"The result of integral k(x) on interval ["</span> << a << <span class="stringliteral">", "</span> << b</div>
|
||||
<div class="line"><a id="l00146" name="l00146"></a><span class="lineno"> 146</span> << <span class="stringliteral">"] is equal to: "</span> << result_k << <a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/manip/endl.html">std::endl</a>;</div>
|
||||
<div class="line"><a id="l00147" name="l00147"></a><span class="lineno"> 147</span> </div>
|
||||
<div class="line"><a id="l00148" name="l00148"></a><span class="lineno"> 148</span> <span class="keywordtype">double</span> result_l = <a class="code hl_function" href="../../df/d11/midpoint__integral__method_8cpp.html#a7072493d1f0f8a91b2a71d4cc456c09c">numerical_methods::midpoint_rule::midpoint</a>(</div>
|
||||
<div class="line"><a id="l00149" name="l00149"></a><span class="lineno"> 149</span> N, <a class="code hl_function" href="../../d1/df3/hash__search_8cpp.html#a566eaf0ffafd50bc61e644561fd27001">h</a>, a, numerical_methods::midpoint_rule::l);</div>
|
||||
<div class="line"><a id="l00150" name="l00150"></a><span class="lineno"> 150</span> assert((used_argv_parameters || (result_l >= 7.16 && result_l <= 7.17)) &&</div>
|
||||
<div class="line"><a id="l00151" name="l00151"></a><span class="lineno"> 151</span> <span class="stringliteral">"The result of l(x) is wrong"</span>);</div>
|
||||
<div class="line"><a id="l00152" name="l00152"></a><span class="lineno"> 152</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/basic_ostream.html">std::cout</a> << <span class="stringliteral">"The result of integral l(x) on interval ["</span> << a << <span class="stringliteral">", "</span> << b</div>
|
||||
<div class="line"><a id="l00153" name="l00153"></a><span class="lineno"> 153</span> << <span class="stringliteral">"] is equal to: "</span> << result_l << <a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/manip/endl.html">std::endl</a>;</div>
|
||||
<div class="line"><a id="l00154" name="l00154"></a><span class="lineno"> 154</span>}</div>
|
||||
<div class="fragment"><div class="line"><span class="lineno"> 124</span> {</div>
|
||||
<div class="line"><span class="lineno"> 125</span> <span class="comment">// Call midpoint() for each of the test functions f, g, k, l</span></div>
|
||||
<div class="line"><span class="lineno"> 126</span> <span class="comment">// Assert with two decimal point precision</span></div>
|
||||
<div class="line"><span class="lineno"> 127</span> <span class="keywordtype">double</span> result_f = <a class="code hl_function" href="../../df/d11/midpoint__integral__method_8cpp.html#a7072493d1f0f8a91b2a71d4cc456c09c">numerical_methods::midpoint_rule::midpoint</a>(</div>
|
||||
<div class="line"><span class="lineno"> 128</span> N, <a class="code hl_function" href="../../d1/df3/hash__search_8cpp.html#a566eaf0ffafd50bc61e644561fd27001">h</a>, a, numerical_methods::midpoint_rule::f);</div>
|
||||
<div class="line"><span class="lineno"> 129</span> assert((used_argv_parameters || (result_f >= 4.09 && result_f <= 4.10)) &&</div>
|
||||
<div class="line"><span class="lineno"> 130</span> <span class="stringliteral">"The result of f(x) is wrong"</span>);</div>
|
||||
<div class="line"><span class="lineno"> 131</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/basic_ostream.html">std::cout</a> << <span class="stringliteral">"The result of integral f(x) on interval ["</span> << a << <span class="stringliteral">", "</span> << b</div>
|
||||
<div class="line"><span class="lineno"> 132</span> << <span class="stringliteral">"] is equal to: "</span> << result_f << <a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/manip/endl.html">std::endl</a>;</div>
|
||||
<div class="line"><span class="lineno"> 133</span> </div>
|
||||
<div class="line"><span class="lineno"> 134</span> <span class="keywordtype">double</span> result_g = <a class="code hl_function" href="../../df/d11/midpoint__integral__method_8cpp.html#a7072493d1f0f8a91b2a71d4cc456c09c">numerical_methods::midpoint_rule::midpoint</a>(</div>
|
||||
<div class="line"><span class="lineno"> 135</span> N, <a class="code hl_function" href="../../d1/df3/hash__search_8cpp.html#a566eaf0ffafd50bc61e644561fd27001">h</a>, a, numerical_methods::midpoint_rule::g);</div>
|
||||
<div class="line"><span class="lineno"> 136</span> assert((used_argv_parameters || (result_g >= 0.27 && result_g <= 0.28)) &&</div>
|
||||
<div class="line"><span class="lineno"> 137</span> <span class="stringliteral">"The result of g(x) is wrong"</span>);</div>
|
||||
<div class="line"><span class="lineno"> 138</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/basic_ostream.html">std::cout</a> << <span class="stringliteral">"The result of integral g(x) on interval ["</span> << a << <span class="stringliteral">", "</span> << b</div>
|
||||
<div class="line"><span class="lineno"> 139</span> << <span class="stringliteral">"] is equal to: "</span> << result_g << <a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/manip/endl.html">std::endl</a>;</div>
|
||||
<div class="line"><span class="lineno"> 140</span> </div>
|
||||
<div class="line"><span class="lineno"> 141</span> <span class="keywordtype">double</span> result_k = <a class="code hl_function" href="../../df/d11/midpoint__integral__method_8cpp.html#a7072493d1f0f8a91b2a71d4cc456c09c">numerical_methods::midpoint_rule::midpoint</a>(</div>
|
||||
<div class="line"><span class="lineno"> 142</span> N, <a class="code hl_function" href="../../d1/df3/hash__search_8cpp.html#a566eaf0ffafd50bc61e644561fd27001">h</a>, a, numerical_methods::midpoint_rule::k);</div>
|
||||
<div class="line"><span class="lineno"> 143</span> assert((used_argv_parameters || (result_k >= 9.06 && result_k <= 9.07)) &&</div>
|
||||
<div class="line"><span class="lineno"> 144</span> <span class="stringliteral">"The result of k(x) is wrong"</span>);</div>
|
||||
<div class="line"><span class="lineno"> 145</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/basic_ostream.html">std::cout</a> << <span class="stringliteral">"The result of integral k(x) on interval ["</span> << a << <span class="stringliteral">", "</span> << b</div>
|
||||
<div class="line"><span class="lineno"> 146</span> << <span class="stringliteral">"] is equal to: "</span> << result_k << <a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/manip/endl.html">std::endl</a>;</div>
|
||||
<div class="line"><span class="lineno"> 147</span> </div>
|
||||
<div class="line"><span class="lineno"> 148</span> <span class="keywordtype">double</span> result_l = <a class="code hl_function" href="../../df/d11/midpoint__integral__method_8cpp.html#a7072493d1f0f8a91b2a71d4cc456c09c">numerical_methods::midpoint_rule::midpoint</a>(</div>
|
||||
<div class="line"><span class="lineno"> 149</span> N, <a class="code hl_function" href="../../d1/df3/hash__search_8cpp.html#a566eaf0ffafd50bc61e644561fd27001">h</a>, a, numerical_methods::midpoint_rule::l);</div>
|
||||
<div class="line"><span class="lineno"> 150</span> assert((used_argv_parameters || (result_l >= 7.16 && result_l <= 7.17)) &&</div>
|
||||
<div class="line"><span class="lineno"> 151</span> <span class="stringliteral">"The result of l(x) is wrong"</span>);</div>
|
||||
<div class="line"><span class="lineno"> 152</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/basic_ostream.html">std::cout</a> << <span class="stringliteral">"The result of integral l(x) on interval ["</span> << a << <span class="stringliteral">", "</span> << b</div>
|
||||
<div class="line"><span class="lineno"> 153</span> << <span class="stringliteral">"] is equal to: "</span> << result_l << <a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/manip/endl.html">std::endl</a>;</div>
|
||||
<div class="line"><span class="lineno"> 154</span>}</div>
|
||||
<div class="ttc" id="amidpoint__integral__method_8cpp_html_a7072493d1f0f8a91b2a71d4cc456c09c"><div class="ttname"><a href="../../df/d11/midpoint__integral__method_8cpp.html#a7072493d1f0f8a91b2a71d4cc456c09c">numerical_methods::midpoint_rule::midpoint</a></div><div class="ttdeci">double midpoint(const std::int32_t N, const double h, const double a, const std::function< double(double)> &func)</div><div class="ttdoc">Main function for implementing the Midpoint Integral Method implementation.</div><div class="ttdef"><b>Definition:</b> midpoint_integral_method.cpp:52</div></div>
|
||||
</div><!-- fragment --><div class="dynheader">
|
||||
Here is the call graph for this function:</div>
|
||||
@@ -592,7 +592,7 @@ Here is the call graph for this function:</div>
|
||||
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
|
||||
<ul>
|
||||
<li class="navelem"><a class="el" href="../../dir_9c6faab82c22511b50177aa2e38e2780.html">numerical_methods</a></li><li class="navelem"><a class="el" href="../../df/d11/midpoint__integral__method_8cpp.html">midpoint_integral_method.cpp</a></li>
|
||||
<li class="footer">Generated by <a href="https://www.doxygen.org/index.html"><img class="footer" src="../../doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.9.2 </li>
|
||||
<li class="footer">Generated by <a href="https://www.doxygen.org/index.html"><img class="footer" src="../../doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.9.3 </li>
|
||||
</ul>
|
||||
</div>
|
||||
</body>
|
||||
|
||||
Reference in New Issue
Block a user