mirror of
https://github.com/TheAlgorithms/C-Plus-Plus.git
synced 2026-03-22 04:42:10 +08:00
Documentation for 0d766b0f8a
This commit is contained in:
@@ -332,7 +332,7 @@ Here is the call graph for this function:</div>
|
||||
<p>the real axis</p>
|
||||
<p>Step, calculated by a, b and N</p>
|
||||
<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"> 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="../../d8/dab/sparse__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>
|
||||
@@ -346,7 +346,7 @@ Here is the call graph for this function:</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"> 177</span> <a class="code hl_variable" href="../../d8/dab/sparse__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>
|
||||
@@ -355,10 +355,10 @@ Here is the call graph for this function:</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"> 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="../../d8/dab/sparse__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"> 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="../../d8/dab/sparse__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>
|
||||
@@ -372,11 +372,11 @@ Here is the call graph for this function:</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>
|
||||
<div class="ttc" id="adata__structures_2sparse__table_8cpp_html_a10f3ffb3f6f7e1b83d556b9c8de89a5d"><div class="ttname"><a href="../../d6/d42/data__structures_2sparse__table_8cpp.html#a10f3ffb3f6f7e1b83d556b9c8de89a5d">data_structures::sparse_table::N</a></div><div class="ttdeci">constexpr uint32_t N</div><div class="ttdoc">A struct to represent sparse table for min() as their invariant function, for the given array A....</div><div class="ttdef"><b>Definition</b> sparse_table.cpp:48</div></div>
|
||||
<div class="ttc" id="aendl_html"><div class="ttname"><a href="http://en.cppreference.com/w/cpp/io/manip/endl.html">std::endl</a></div><div class="ttdeci">T endl(T... args)</div></div>
|
||||
<div class="ttc" id="agenerate__parentheses_8cpp_html_aa8dca7b867074164d5f45b0f3851269d"><div class="ttname"><a href="../../dd/d1e/generate__parentheses_8cpp.html#aa8dca7b867074164d5f45b0f3851269d">test</a></div><div class="ttdeci">static void test()</div><div class="ttdoc">Self-test implementations.</div><div class="ttdef"><b>Definition</b> generate_parentheses.cpp:82</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="ainteger_html"><div class="ttname"><a href="http://en.cppreference.com/w/cpp/types/integer.html">std::int32_t</a></div></div>
|
||||
<div class="ttc" id="asparse__table_8cpp_html_a10f3ffb3f6f7e1b83d556b9c8de89a5d"><div class="ttname"><a href="../../d8/dab/sparse__table_8cpp.html#a10f3ffb3f6f7e1b83d556b9c8de89a5d">data_structures::sparse_table::N</a></div><div class="ttdeci">constexpr uint32_t N</div><div class="ttdoc">A struct to represent sparse table for min() as their invariant function, for the given array A....</div><div class="ttdef"><b>Definition</b> sparse_table.cpp:48</div></div>
|
||||
</div><!-- fragment --><div class="dynheader">
|
||||
Here is the call graph for this function:</div>
|
||||
<div class="dyncontent">
|
||||
@@ -433,7 +433,7 @@ Here is the call graph for this function:</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"> 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="../../d8/dab/sparse__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>
|
||||
@@ -443,7 +443,7 @@ Here is the call graph for this function:</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"> 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="../../d8/dab/sparse__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>
|
||||
|
||||
Reference in New Issue
Block a user