Documentation for 53a6c16730

This commit is contained in:
github-actions
2022-01-16 16:05:19 +00:00
parent 778f1be9e5
commit 2cab28c905
3620 changed files with 52045 additions and 41188 deletions

View File

@@ -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/brent_method_extrema.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">&#160;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&amp;dn=expat.txt MIT */
var searchBox = new SearchBox("searchBox", "../../search",'Search','.html');
@@ -144,7 +144,7 @@ Functions</h2></td></tr>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<div class="textblock"><p >Find real extrema of a univariate real function in a given interval using <a href="https://en.wikipedia.org/wiki/Brent%27s_method" target="_blank">Brent's method</a>. </p>
<p >Refer the algorithm discoverer's publication <a href="https://maths-people.anu.edu.au/~brent/pd/rpb011i.pdf" target="_blank">online</a> and also associated book: </p><blockquote class="doxtable">
<p >R. P. Brent, Algorithms for Minimization without Derivatives, Prentice-Hall, Englewood Cliffs, New Jersey, 1973 </p>
<p >&zwj;R. P. Brent, Algorithms for Minimization without Derivatives, Prentice-Hall, Englewood Cliffs, New Jersey, 1973 </p>
</blockquote>
<dl class="section see"><dt>See also</dt><dd><a class="el" href="../../d6/d7a/golden__search__extrema_8cpp.html" title="Find extrema of a univariate real function in a given interval using golden section search algorithm.">golden_search_extrema.cpp</a></dd></dl>
<dl class="section author"><dt>Author</dt><dd><a href="https://github.com/kvedala" target="_blank">Krishna Vedala</a> </dd></dl>
@@ -212,106 +212,106 @@ Functions</h2></td></tr>
</dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>root found in the interval </dd></dl>
<div class="fragment"><div class="line"><a id="l00036" name="l00036"></a><span class="lineno"> 36</span> {</div>
<div class="line"><a id="l00037" name="l00037"></a><span class="lineno"> 37</span> uint32_t iters = 0;</div>
<div class="line"><a id="l00038" name="l00038"></a><span class="lineno"> 38</span> </div>
<div class="line"><a id="l00039" name="l00039"></a><span class="lineno"> 39</span> <span class="keywordflow">if</span> (lim_a &gt; lim_b) {</div>
<div class="line"><a id="l00040" name="l00040"></a><span class="lineno"> 40</span> <a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/algorithm/swap.html">std::swap</a>(lim_a, lim_b);</div>
<div class="line"><a id="l00041" name="l00041"></a><span class="lineno"> 41</span> } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (std::abs(lim_a - lim_b) &lt;= <a class="code hl_define" href="../../db/d01/brent__method__extrema_8cpp.html#a002b2f4894492820fe708b1b7e7c5e70">EPSILON</a>) {</div>
<div class="line"><a id="l00042" name="l00042"></a><span class="lineno"> 42</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/basic_ostream.html">std::cerr</a> &lt;&lt; <span class="stringliteral">&quot;Search range must be greater than &quot;</span> &lt;&lt; <a class="code hl_define" href="../../db/d01/brent__method__extrema_8cpp.html#a002b2f4894492820fe708b1b7e7c5e70">EPSILON</a> &lt;&lt; <span class="stringliteral">&quot;\n&quot;</span>;</div>
<div class="line"><a id="l00043" name="l00043"></a><span class="lineno"> 43</span> <span class="keywordflow">return</span> lim_a;</div>
<div class="line"><a id="l00044" name="l00044"></a><span class="lineno"> 44</span> }</div>
<div class="line"><a id="l00045" name="l00045"></a><span class="lineno"> 45</span> </div>
<div class="line"><a id="l00046" name="l00046"></a><span class="lineno"> 46</span> <span class="comment">// golden ratio value</span></div>
<div class="line"><a id="l00047" name="l00047"></a><span class="lineno"> 47</span> <span class="keyword">const</span> <span class="keywordtype">double</span> M_GOLDEN_RATIO = (3.f - <a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/numeric/math/sqrt.html">std::sqrt</a>(5.f)) / 2.f;</div>
<div class="line"><a id="l00048" name="l00048"></a><span class="lineno"> 48</span> </div>
<div class="line"><a id="l00049" name="l00049"></a><span class="lineno"> 49</span> <span class="keywordtype">double</span> v = lim_a + M_GOLDEN_RATIO * (lim_b - lim_a);</div>
<div class="line"><a id="l00050" name="l00050"></a><span class="lineno"> 50</span> <span class="keywordtype">double</span> u, w = v, x = v;</div>
<div class="line"><a id="l00051" name="l00051"></a><span class="lineno"> 51</span> <span class="keywordtype">double</span> fu, fv = <a class="code hl_function" href="../../d4/d18/composite__simpson__rule_8cpp.html#a4251b4df4748a0b9c43a48f61bdd2397">f</a>(v);</div>
<div class="line"><a id="l00052" name="l00052"></a><span class="lineno"> 52</span> <span class="keywordtype">double</span> fw = fv, fx = fv;</div>
<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> <span class="keywordtype">double</span> mid_point = (lim_a + lim_b) / 2.f;</div>
<div class="line"><a id="l00055" name="l00055"></a><span class="lineno"> 55</span> <span class="keywordtype">double</span> p = 0, q = 0, r = 0;</div>
<div class="line"><a id="l00056" name="l00056"></a><span class="lineno"> 56</span> </div>
<div class="line"><a id="l00057" name="l00057"></a><span class="lineno"> 57</span> <span class="keywordtype">double</span> d, e = 0;</div>
<div class="line"><a id="l00058" name="l00058"></a><span class="lineno"> 58</span> <span class="keywordtype">double</span> tolerance, tolerance2;</div>
<div class="line"><a id="l00059" name="l00059"></a><span class="lineno"> 59</span> </div>
<div class="line"><a id="l00060" name="l00060"></a><span class="lineno"> 60</span> <span class="keywordflow">do</span> {</div>
<div class="line"><a id="l00061" name="l00061"></a><span class="lineno"> 61</span> mid_point = (lim_a + lim_b) / 2.f;</div>
<div class="line"><a id="l00062" name="l00062"></a><span class="lineno"> 62</span> tolerance = <a class="code hl_define" href="../../db/d01/brent__method__extrema_8cpp.html#a002b2f4894492820fe708b1b7e7c5e70">EPSILON</a> * std::abs(x);</div>
<div class="line"><a id="l00063" name="l00063"></a><span class="lineno"> 63</span> tolerance2 = 2 * tolerance;</div>
<div class="line"><a id="l00064" name="l00064"></a><span class="lineno"> 64</span> </div>
<div class="line"><a id="l00065" name="l00065"></a><span class="lineno"> 65</span> <span class="keywordflow">if</span> (std::abs(e) &gt; tolerance2) {</div>
<div class="line"><a id="l00066" name="l00066"></a><span class="lineno"> 66</span> <span class="comment">// fit parabola</span></div>
<div class="line"><a id="l00067" name="l00067"></a><span class="lineno"> 67</span> r = (x - w) * (fx - fv);</div>
<div class="line"><a id="l00068" name="l00068"></a><span class="lineno"> 68</span> q = (x - v) * (fx - fw);</div>
<div class="line"><a id="l00069" name="l00069"></a><span class="lineno"> 69</span> p = (x - v) * q - (x - w) * r;</div>
<div class="line"><a id="l00070" name="l00070"></a><span class="lineno"> 70</span> q = 2.f * (q - r);</div>
<div class="line"><a id="l00071" name="l00071"></a><span class="lineno"> 71</span> <span class="keywordflow">if</span> (q &gt; 0)</div>
<div class="line"><a id="l00072" name="l00072"></a><span class="lineno"> 72</span> p = -p;</div>
<div class="line"><a id="l00073" name="l00073"></a><span class="lineno"> 73</span> <span class="keywordflow">else</span></div>
<div class="line"><a id="l00074" name="l00074"></a><span class="lineno"> 74</span> q = -q;</div>
<div class="line"><a id="l00075" name="l00075"></a><span class="lineno"> 75</span> r = e;</div>
<div class="line"><a id="l00076" name="l00076"></a><span class="lineno"> 76</span> e = d;</div>
<div class="line"><a id="l00077" name="l00077"></a><span class="lineno"> 77</span> }</div>
<div class="line"><a id="l00078" name="l00078"></a><span class="lineno"> 78</span> </div>
<div class="line"><a id="l00079" name="l00079"></a><span class="lineno"> 79</span> <span class="keywordflow">if</span> (std::abs(p) &lt; std::abs(0.5 * q * r) &amp;&amp; p &lt; q * (lim_b - x)) {</div>
<div class="line"><a id="l00080" name="l00080"></a><span class="lineno"> 80</span> <span class="comment">// parabolic interpolation step</span></div>
<div class="line"><a id="l00081" name="l00081"></a><span class="lineno"> 81</span> d = p / q;</div>
<div class="line"><a id="l00082" name="l00082"></a><span class="lineno"> 82</span> u = x + d;</div>
<div class="line"><a id="l00083" name="l00083"></a><span class="lineno"> 83</span> <span class="keywordflow">if</span> (u - lim_a &lt; tolerance2 || lim_b - u &lt; tolerance2)</div>
<div class="line"><a id="l00084" name="l00084"></a><span class="lineno"> 84</span> d = x &lt; mid_point ? tolerance : -tolerance;</div>
<div class="line"><a id="l00085" name="l00085"></a><span class="lineno"> 85</span> } <span class="keywordflow">else</span> {</div>
<div class="line"><a id="l00086" name="l00086"></a><span class="lineno"> 86</span> <span class="comment">// golden section interpolation step</span></div>
<div class="line"><a id="l00087" name="l00087"></a><span class="lineno"> 87</span> e = (x &lt; mid_point ? lim_b : lim_a) - x;</div>
<div class="line"><a id="l00088" name="l00088"></a><span class="lineno"> 88</span> d = M_GOLDEN_RATIO * e;</div>
<div class="line"><a id="l00089" name="l00089"></a><span class="lineno"> 89</span> }</div>
<div class="line"><a id="l00090" name="l00090"></a><span class="lineno"> 90</span> </div>
<div class="line"><a id="l00091" name="l00091"></a><span class="lineno"> 91</span> <span class="comment">// evaluate not too close to x</span></div>
<div class="line"><a id="l00092" name="l00092"></a><span class="lineno"> 92</span> <span class="keywordflow">if</span> (std::abs(d) &gt;= tolerance)</div>
<div class="line"><a id="l00093" name="l00093"></a><span class="lineno"> 93</span> u = d;</div>
<div class="line"><a id="l00094" name="l00094"></a><span class="lineno"> 94</span> <span class="keywordflow">else</span> <span class="keywordflow">if</span> (d &gt; 0)</div>
<div class="line"><a id="l00095" name="l00095"></a><span class="lineno"> 95</span> u = tolerance;</div>
<div class="line"><a id="l00096" name="l00096"></a><span class="lineno"> 96</span> <span class="keywordflow">else</span></div>
<div class="line"><a id="l00097" name="l00097"></a><span class="lineno"> 97</span> u = -tolerance;</div>
<div class="line"><a id="l00098" name="l00098"></a><span class="lineno"> 98</span> u += x;</div>
<div class="line"><a id="l00099" name="l00099"></a><span class="lineno"> 99</span> fu = <a class="code hl_function" href="../../d4/d18/composite__simpson__rule_8cpp.html#a4251b4df4748a0b9c43a48f61bdd2397">f</a>(u);</div>
<div class="line"><a id="l00100" name="l00100"></a><span class="lineno"> 100</span> </div>
<div class="line"><a id="l00101" name="l00101"></a><span class="lineno"> 101</span> <span class="comment">// update variables</span></div>
<div class="line"><a id="l00102" name="l00102"></a><span class="lineno"> 102</span> <span class="keywordflow">if</span> (fu &lt;= fx) {</div>
<div class="line"><a id="l00103" name="l00103"></a><span class="lineno"> 103</span> <span class="keywordflow">if</span> (u &lt; x)</div>
<div class="line"><a id="l00104" name="l00104"></a><span class="lineno"> 104</span> lim_b = x;</div>
<div class="line"><a id="l00105" name="l00105"></a><span class="lineno"> 105</span> <span class="keywordflow">else</span></div>
<div class="line"><a id="l00106" name="l00106"></a><span class="lineno"> 106</span> lim_a = x;</div>
<div class="line"><a id="l00107" name="l00107"></a><span class="lineno"> 107</span> v = w;</div>
<div class="line"><a id="l00108" name="l00108"></a><span class="lineno"> 108</span> fv = fw;</div>
<div class="line"><a id="l00109" name="l00109"></a><span class="lineno"> 109</span> w = x;</div>
<div class="line"><a id="l00110" name="l00110"></a><span class="lineno"> 110</span> fw = fx;</div>
<div class="line"><a id="l00111" name="l00111"></a><span class="lineno"> 111</span> x = u;</div>
<div class="line"><a id="l00112" name="l00112"></a><span class="lineno"> 112</span> fx = fu;</div>
<div class="line"><a id="l00113" name="l00113"></a><span class="lineno"> 113</span> } <span class="keywordflow">else</span> {</div>
<div class="line"><a id="l00114" name="l00114"></a><span class="lineno"> 114</span> <span class="keywordflow">if</span> (u &lt; x)</div>
<div class="line"><a id="l00115" name="l00115"></a><span class="lineno"> 115</span> lim_a = u;</div>
<div class="line"><a id="l00116" name="l00116"></a><span class="lineno"> 116</span> <span class="keywordflow">else</span></div>
<div class="line"><a id="l00117" name="l00117"></a><span class="lineno"> 117</span> lim_b = u;</div>
<div class="line"><a id="l00118" name="l00118"></a><span class="lineno"> 118</span> <span class="keywordflow">if</span> (fu &lt;= fw || x == w) {</div>
<div class="line"><a id="l00119" name="l00119"></a><span class="lineno"> 119</span> v = w;</div>
<div class="line"><a id="l00120" name="l00120"></a><span class="lineno"> 120</span> fv = fw;</div>
<div class="line"><a id="l00121" name="l00121"></a><span class="lineno"> 121</span> w = u;</div>
<div class="line"><a id="l00122" name="l00122"></a><span class="lineno"> 122</span> fw = fu;</div>
<div class="line"><a id="l00123" name="l00123"></a><span class="lineno"> 123</span> } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (fu &lt;= fv || v == x || v == w) {</div>
<div class="line"><a id="l00124" name="l00124"></a><span class="lineno"> 124</span> v = u;</div>
<div class="line"><a id="l00125" name="l00125"></a><span class="lineno"> 125</span> fv = fu;</div>
<div class="line"><a id="l00126" name="l00126"></a><span class="lineno"> 126</span> }</div>
<div class="line"><a id="l00127" name="l00127"></a><span class="lineno"> 127</span> }</div>
<div class="line"><a id="l00128" name="l00128"></a><span class="lineno"> 128</span> </div>
<div class="line"><a id="l00129" name="l00129"></a><span class="lineno"> 129</span> iters++;</div>
<div class="line"><a id="l00130" name="l00130"></a><span class="lineno"> 130</span> } <span class="keywordflow">while</span> (std::abs(x - mid_point) &gt; (tolerance - (lim_b - lim_a) / 2.f));</div>
<div class="line"><a id="l00131" name="l00131"></a><span class="lineno"> 131</span> </div>
<div class="line"><a id="l00132" name="l00132"></a><span class="lineno"> 132</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; (iters: &quot;</span> &lt;&lt; iters &lt;&lt; <span class="stringliteral">&quot;) &quot;</span>;</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="keywordflow">return</span> x;</div>
<div class="line"><a id="l00135" name="l00135"></a><span class="lineno"> 135</span>}</div>
<div class="fragment"><div class="line"><span class="lineno"> 36</span> {</div>
<div class="line"><span class="lineno"> 37</span> uint32_t iters = 0;</div>
<div class="line"><span class="lineno"> 38</span> </div>
<div class="line"><span class="lineno"> 39</span> <span class="keywordflow">if</span> (lim_a &gt; lim_b) {</div>
<div class="line"><span class="lineno"> 40</span> <a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/algorithm/swap.html">std::swap</a>(lim_a, lim_b);</div>
<div class="line"><span class="lineno"> 41</span> } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (std::abs(lim_a - lim_b) &lt;= <a class="code hl_define" href="../../db/d01/brent__method__extrema_8cpp.html#a002b2f4894492820fe708b1b7e7c5e70">EPSILON</a>) {</div>
<div class="line"><span class="lineno"> 42</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/basic_ostream.html">std::cerr</a> &lt;&lt; <span class="stringliteral">&quot;Search range must be greater than &quot;</span> &lt;&lt; <a class="code hl_define" href="../../db/d01/brent__method__extrema_8cpp.html#a002b2f4894492820fe708b1b7e7c5e70">EPSILON</a> &lt;&lt; <span class="stringliteral">&quot;\n&quot;</span>;</div>
<div class="line"><span class="lineno"> 43</span> <span class="keywordflow">return</span> lim_a;</div>
<div class="line"><span class="lineno"> 44</span> }</div>
<div class="line"><span class="lineno"> 45</span> </div>
<div class="line"><span class="lineno"> 46</span> <span class="comment">// golden ratio value</span></div>
<div class="line"><span class="lineno"> 47</span> <span class="keyword">const</span> <span class="keywordtype">double</span> M_GOLDEN_RATIO = (3.f - <a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/numeric/math/sqrt.html">std::sqrt</a>(5.f)) / 2.f;</div>
<div class="line"><span class="lineno"> 48</span> </div>
<div class="line"><span class="lineno"> 49</span> <span class="keywordtype">double</span> v = lim_a + M_GOLDEN_RATIO * (lim_b - lim_a);</div>
<div class="line"><span class="lineno"> 50</span> <span class="keywordtype">double</span> u, w = v, x = v;</div>
<div class="line"><span class="lineno"> 51</span> <span class="keywordtype">double</span> fu, fv = <a class="code hl_function" href="../../d4/d18/composite__simpson__rule_8cpp.html#a4251b4df4748a0b9c43a48f61bdd2397">f</a>(v);</div>
<div class="line"><span class="lineno"> 52</span> <span class="keywordtype">double</span> fw = fv, fx = fv;</div>
<div class="line"><span class="lineno"> 53</span> </div>
<div class="line"><span class="lineno"> 54</span> <span class="keywordtype">double</span> mid_point = (lim_a + lim_b) / 2.f;</div>
<div class="line"><span class="lineno"> 55</span> <span class="keywordtype">double</span> p = 0, q = 0, r = 0;</div>
<div class="line"><span class="lineno"> 56</span> </div>
<div class="line"><span class="lineno"> 57</span> <span class="keywordtype">double</span> d, e = 0;</div>
<div class="line"><span class="lineno"> 58</span> <span class="keywordtype">double</span> tolerance, tolerance2;</div>
<div class="line"><span class="lineno"> 59</span> </div>
<div class="line"><span class="lineno"> 60</span> <span class="keywordflow">do</span> {</div>
<div class="line"><span class="lineno"> 61</span> mid_point = (lim_a + lim_b) / 2.f;</div>
<div class="line"><span class="lineno"> 62</span> tolerance = <a class="code hl_define" href="../../db/d01/brent__method__extrema_8cpp.html#a002b2f4894492820fe708b1b7e7c5e70">EPSILON</a> * std::abs(x);</div>
<div class="line"><span class="lineno"> 63</span> tolerance2 = 2 * tolerance;</div>
<div class="line"><span class="lineno"> 64</span> </div>
<div class="line"><span class="lineno"> 65</span> <span class="keywordflow">if</span> (std::abs(e) &gt; tolerance2) {</div>
<div class="line"><span class="lineno"> 66</span> <span class="comment">// fit parabola</span></div>
<div class="line"><span class="lineno"> 67</span> r = (x - w) * (fx - fv);</div>
<div class="line"><span class="lineno"> 68</span> q = (x - v) * (fx - fw);</div>
<div class="line"><span class="lineno"> 69</span> p = (x - v) * q - (x - w) * r;</div>
<div class="line"><span class="lineno"> 70</span> q = 2.f * (q - r);</div>
<div class="line"><span class="lineno"> 71</span> <span class="keywordflow">if</span> (q &gt; 0)</div>
<div class="line"><span class="lineno"> 72</span> p = -p;</div>
<div class="line"><span class="lineno"> 73</span> <span class="keywordflow">else</span></div>
<div class="line"><span class="lineno"> 74</span> q = -q;</div>
<div class="line"><span class="lineno"> 75</span> r = e;</div>
<div class="line"><span class="lineno"> 76</span> e = d;</div>
<div class="line"><span class="lineno"> 77</span> }</div>
<div class="line"><span class="lineno"> 78</span> </div>
<div class="line"><span class="lineno"> 79</span> <span class="keywordflow">if</span> (std::abs(p) &lt; std::abs(0.5 * q * r) &amp;&amp; p &lt; q * (lim_b - x)) {</div>
<div class="line"><span class="lineno"> 80</span> <span class="comment">// parabolic interpolation step</span></div>
<div class="line"><span class="lineno"> 81</span> d = p / q;</div>
<div class="line"><span class="lineno"> 82</span> u = x + d;</div>
<div class="line"><span class="lineno"> 83</span> <span class="keywordflow">if</span> (u - lim_a &lt; tolerance2 || lim_b - u &lt; tolerance2)</div>
<div class="line"><span class="lineno"> 84</span> d = x &lt; mid_point ? tolerance : -tolerance;</div>
<div class="line"><span class="lineno"> 85</span> } <span class="keywordflow">else</span> {</div>
<div class="line"><span class="lineno"> 86</span> <span class="comment">// golden section interpolation step</span></div>
<div class="line"><span class="lineno"> 87</span> e = (x &lt; mid_point ? lim_b : lim_a) - x;</div>
<div class="line"><span class="lineno"> 88</span> d = M_GOLDEN_RATIO * e;</div>
<div class="line"><span class="lineno"> 89</span> }</div>
<div class="line"><span class="lineno"> 90</span> </div>
<div class="line"><span class="lineno"> 91</span> <span class="comment">// evaluate not too close to x</span></div>
<div class="line"><span class="lineno"> 92</span> <span class="keywordflow">if</span> (std::abs(d) &gt;= tolerance)</div>
<div class="line"><span class="lineno"> 93</span> u = d;</div>
<div class="line"><span class="lineno"> 94</span> <span class="keywordflow">else</span> <span class="keywordflow">if</span> (d &gt; 0)</div>
<div class="line"><span class="lineno"> 95</span> u = tolerance;</div>
<div class="line"><span class="lineno"> 96</span> <span class="keywordflow">else</span></div>
<div class="line"><span class="lineno"> 97</span> u = -tolerance;</div>
<div class="line"><span class="lineno"> 98</span> u += x;</div>
<div class="line"><span class="lineno"> 99</span> fu = <a class="code hl_function" href="../../d4/d18/composite__simpson__rule_8cpp.html#a4251b4df4748a0b9c43a48f61bdd2397">f</a>(u);</div>
<div class="line"><span class="lineno"> 100</span> </div>
<div class="line"><span class="lineno"> 101</span> <span class="comment">// update variables</span></div>
<div class="line"><span class="lineno"> 102</span> <span class="keywordflow">if</span> (fu &lt;= fx) {</div>
<div class="line"><span class="lineno"> 103</span> <span class="keywordflow">if</span> (u &lt; x)</div>
<div class="line"><span class="lineno"> 104</span> lim_b = x;</div>
<div class="line"><span class="lineno"> 105</span> <span class="keywordflow">else</span></div>
<div class="line"><span class="lineno"> 106</span> lim_a = x;</div>
<div class="line"><span class="lineno"> 107</span> v = w;</div>
<div class="line"><span class="lineno"> 108</span> fv = fw;</div>
<div class="line"><span class="lineno"> 109</span> w = x;</div>
<div class="line"><span class="lineno"> 110</span> fw = fx;</div>
<div class="line"><span class="lineno"> 111</span> x = u;</div>
<div class="line"><span class="lineno"> 112</span> fx = fu;</div>
<div class="line"><span class="lineno"> 113</span> } <span class="keywordflow">else</span> {</div>
<div class="line"><span class="lineno"> 114</span> <span class="keywordflow">if</span> (u &lt; x)</div>
<div class="line"><span class="lineno"> 115</span> lim_a = u;</div>
<div class="line"><span class="lineno"> 116</span> <span class="keywordflow">else</span></div>
<div class="line"><span class="lineno"> 117</span> lim_b = u;</div>
<div class="line"><span class="lineno"> 118</span> <span class="keywordflow">if</span> (fu &lt;= fw || x == w) {</div>
<div class="line"><span class="lineno"> 119</span> v = w;</div>
<div class="line"><span class="lineno"> 120</span> fv = fw;</div>
<div class="line"><span class="lineno"> 121</span> w = u;</div>
<div class="line"><span class="lineno"> 122</span> fw = fu;</div>
<div class="line"><span class="lineno"> 123</span> } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (fu &lt;= fv || v == x || v == w) {</div>
<div class="line"><span class="lineno"> 124</span> v = u;</div>
<div class="line"><span class="lineno"> 125</span> fv = fu;</div>
<div class="line"><span class="lineno"> 126</span> }</div>
<div class="line"><span class="lineno"> 127</span> }</div>
<div class="line"><span class="lineno"> 128</span> </div>
<div class="line"><span class="lineno"> 129</span> iters++;</div>
<div class="line"><span class="lineno"> 130</span> } <span class="keywordflow">while</span> (std::abs(x - mid_point) &gt; (tolerance - (lim_b - lim_a) / 2.f));</div>
<div class="line"><span class="lineno"> 131</span> </div>
<div class="line"><span class="lineno"> 132</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; (iters: &quot;</span> &lt;&lt; iters &lt;&lt; <span class="stringliteral">&quot;) &quot;</span>;</div>
<div class="line"><span class="lineno"> 133</span> </div>
<div class="line"><span class="lineno"> 134</span> <span class="keywordflow">return</span> x;</div>
<div class="line"><span class="lineno"> 135</span>}</div>
<div class="ttc" id="abasic_ostream_html"><div class="ttname"><a href="http://en.cppreference.com/w/cpp/io/basic_ostream.html">std::cerr</a></div></div>
<div class="ttc" id="abrent__method__extrema_8cpp_html_a002b2f4894492820fe708b1b7e7c5e70"><div class="ttname"><a href="../../db/d01/brent__method__extrema_8cpp.html#a002b2f4894492820fe708b1b7e7c5e70">EPSILON</a></div><div class="ttdeci">#define EPSILON</div><div class="ttdoc">system accuracy limit</div><div class="ttdef"><b>Definition:</b> brent_method_extrema.cpp:23</div></div>
<div class="ttc" id="acomposite__simpson__rule_8cpp_html_a4251b4df4748a0b9c43a48f61bdd2397"><div class="ttname"><a href="../../d4/d18/composite__simpson__rule_8cpp.html#a4251b4df4748a0b9c43a48f61bdd2397">numerical_methods::simpson_method::f</a></div><div class="ttdeci">double f(double x)</div><div class="ttdoc">A function f(x) that will be used to test the method.</div><div class="ttdef"><b>Definition:</b> composite_simpson_rule.cpp:113</div></div>
@@ -341,18 +341,18 @@ Here is the call graph for this function:</div>
</table>
</div><div class="memdoc">
<p >Main function </p>
<div class="fragment"><div class="line"><a id="l00204" name="l00204"></a><span class="lineno"> 204</span> {</div>
<div class="line"><a id="l00205" name="l00205"></a><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>.precision(18);</div>
<div class="line"><a id="l00206" name="l00206"></a><span class="lineno"> 206</span> </div>
<div class="line"><a id="l00207" name="l00207"></a><span class="lineno"> 207</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;Computations performed with machine epsilon: &quot;</span> &lt;&lt; <a class="code hl_define" href="../../db/d01/brent__method__extrema_8cpp.html#a002b2f4894492820fe708b1b7e7c5e70">EPSILON</a></div>
<div class="line"><a id="l00208" name="l00208"></a><span class="lineno"> 208</span> &lt;&lt; <span class="stringliteral">&quot;\n&quot;</span>;</div>
<div class="line"><a id="l00209" name="l00209"></a><span class="lineno"> 209</span> </div>
<div class="line"><a id="l00210" name="l00210"></a><span class="lineno"> 210</span> <a class="code hl_function" href="../../db/d01/brent__method__extrema_8cpp.html#a1440a7779ac56f47a3f355ce4a8c7da0">test1</a>();</div>
<div class="line"><a id="l00211" name="l00211"></a><span class="lineno"> 211</span> <a class="code hl_function" href="../../db/d01/brent__method__extrema_8cpp.html#a0283886819c7c140a023582b7269e2d0">test2</a>();</div>
<div class="line"><a id="l00212" name="l00212"></a><span class="lineno"> 212</span> <a class="code hl_function" href="../../db/d01/brent__method__extrema_8cpp.html#a6d0455dd5c30adda100e95f0423c786e">test3</a>();</div>
<div class="line"><a id="l00213" name="l00213"></a><span class="lineno"> 213</span> </div>
<div class="line"><a id="l00214" name="l00214"></a><span class="lineno"> 214</span> <span class="keywordflow">return</span> 0;</div>
<div class="line"><a id="l00215" name="l00215"></a><span class="lineno"> 215</span>}</div>
<div class="fragment"><div class="line"><span class="lineno"> 204</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>.precision(18);</div>
<div class="line"><span class="lineno"> 206</span> </div>
<div class="line"><span class="lineno"> 207</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;Computations performed with machine epsilon: &quot;</span> &lt;&lt; <a class="code hl_define" href="../../db/d01/brent__method__extrema_8cpp.html#a002b2f4894492820fe708b1b7e7c5e70">EPSILON</a></div>
<div class="line"><span class="lineno"> 208</span> &lt;&lt; <span class="stringliteral">&quot;\n&quot;</span>;</div>
<div class="line"><span class="lineno"> 209</span> </div>
<div class="line"><span class="lineno"> 210</span> <a class="code hl_function" href="../../db/d01/brent__method__extrema_8cpp.html#a1440a7779ac56f47a3f355ce4a8c7da0">test1</a>();</div>
<div class="line"><span class="lineno"> 211</span> <a class="code hl_function" href="../../db/d01/brent__method__extrema_8cpp.html#a0283886819c7c140a023582b7269e2d0">test2</a>();</div>
<div class="line"><span class="lineno"> 212</span> <a class="code hl_function" href="../../db/d01/brent__method__extrema_8cpp.html#a6d0455dd5c30adda100e95f0423c786e">test3</a>();</div>
<div class="line"><span class="lineno"> 213</span> </div>
<div class="line"><span class="lineno"> 214</span> <span class="keywordflow">return</span> 0;</div>
<div class="line"><span class="lineno"> 215</span>}</div>
<div class="ttc" id="abrent__method__extrema_8cpp_html_a0283886819c7c140a023582b7269e2d0"><div class="ttname"><a href="../../db/d01/brent__method__extrema_8cpp.html#a0283886819c7c140a023582b7269e2d0">test2</a></div><div class="ttdeci">void test2()</div><div class="ttdoc">Test function to find root for the function in the interval Expected result: .</div><div class="ttdef"><b>Definition:</b> brent_method_extrema.cpp:165</div></div>
<div class="ttc" id="abrent__method__extrema_8cpp_html_a1440a7779ac56f47a3f355ce4a8c7da0"><div class="ttname"><a href="../../db/d01/brent__method__extrema_8cpp.html#a1440a7779ac56f47a3f355ce4a8c7da0">test1</a></div><div class="ttdeci">void test1()</div><div class="ttdoc">Test function to find root for the function in the interval Expected result = 2.</div><div class="ttdef"><b>Definition:</b> brent_method_extrema.cpp:143</div></div>
<div class="ttc" id="abrent__method__extrema_8cpp_html_a6d0455dd5c30adda100e95f0423c786e"><div class="ttname"><a href="../../db/d01/brent__method__extrema_8cpp.html#a6d0455dd5c30adda100e95f0423c786e">test3</a></div><div class="ttdeci">void test3()</div><div class="ttdoc">Test function to find maxima for the function in the interval Expected result: .</div><div class="ttdef"><b>Definition:</b> brent_method_extrema.cpp:188</div></div>
@@ -382,21 +382,21 @@ Here is the call graph for this function:</div>
<p>Test function to find root for the function \(f(x)= (x-2)^2\) in the interval \([1,5]\) <br />
Expected result = 2. </p>
<div class="fragment"><div class="line"><a id="l00143" name="l00143"></a><span class="lineno"> 143</span> {</div>
<div class="line"><a id="l00144" name="l00144"></a><span class="lineno"> 144</span> <span class="comment">// define the function to minimize as a lambda function</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/utility/functional/function.html">std::function</a>&lt;double(<span class="keywordtype">double</span>)&gt; f1 = [](<span class="keywordtype">double</span> x) {</div>
<div class="line"><a id="l00146" name="l00146"></a><span class="lineno"> 146</span> <span class="keywordflow">return</span> (x - 2) * (x - 2);</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> </div>
<div class="line"><a id="l00149" name="l00149"></a><span class="lineno"> 149</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;Test 1.... &quot;</span>;</div>
<div class="line"><a id="l00150" name="l00150"></a><span class="lineno"> 150</span> </div>
<div class="line"><a id="l00151" name="l00151"></a><span class="lineno"> 151</span> <span class="keywordtype">double</span> minima = <a class="code hl_function" href="../../db/d01/brent__method__extrema_8cpp.html#a1aa76a6d5fd4d333f9072beff1dc486b">get_minima</a>(f1, -1, 5);</div>
<div class="line"><a id="l00152" name="l00152"></a><span class="lineno"> 152</span> </div>
<div class="line"><a id="l00153" name="l00153"></a><span class="lineno"> 153</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/basic_ostream.html">std::cout</a> &lt;&lt; minima &lt;&lt; <span class="stringliteral">&quot;...&quot;</span>;</div>
<div class="line"><a id="l00154" name="l00154"></a><span class="lineno"> 154</span> </div>
<div class="line"><a id="l00155" name="l00155"></a><span class="lineno"> 155</span> assert(std::abs(minima - 2) &lt; <a class="code hl_define" href="../../db/d01/brent__method__extrema_8cpp.html#a002b2f4894492820fe708b1b7e7c5e70">EPSILON</a>);</div>
<div class="line"><a id="l00156" name="l00156"></a><span class="lineno"> 156</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;passed\n&quot;</span>;</div>
<div class="line"><a id="l00157" name="l00157"></a><span class="lineno"> 157</span>}</div>
<div class="fragment"><div class="line"><span class="lineno"> 143</span> {</div>
<div class="line"><span class="lineno"> 144</span> <span class="comment">// define the function to minimize as a lambda function</span></div>
<div class="line"><span class="lineno"> 145</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/utility/functional/function.html">std::function</a>&lt;double(<span class="keywordtype">double</span>)&gt; f1 = [](<span class="keywordtype">double</span> x) {</div>
<div class="line"><span class="lineno"> 146</span> <span class="keywordflow">return</span> (x - 2) * (x - 2);</div>
<div class="line"><span class="lineno"> 147</span> };</div>
<div class="line"><span class="lineno"> 148</span> </div>
<div class="line"><span class="lineno"> 149</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;Test 1.... &quot;</span>;</div>
<div class="line"><span class="lineno"> 150</span> </div>
<div class="line"><span class="lineno"> 151</span> <span class="keywordtype">double</span> minima = <a class="code hl_function" href="../../db/d01/brent__method__extrema_8cpp.html#a1aa76a6d5fd4d333f9072beff1dc486b">get_minima</a>(f1, -1, 5);</div>
<div class="line"><span class="lineno"> 152</span> </div>
<div class="line"><span class="lineno"> 153</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/basic_ostream.html">std::cout</a> &lt;&lt; minima &lt;&lt; <span class="stringliteral">&quot;...&quot;</span>;</div>
<div class="line"><span class="lineno"> 154</span> </div>
<div class="line"><span class="lineno"> 155</span> assert(std::abs(minima - 2) &lt; <a class="code hl_define" href="../../db/d01/brent__method__extrema_8cpp.html#a002b2f4894492820fe708b1b7e7c5e70">EPSILON</a>);</div>
<div class="line"><span class="lineno"> 156</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;passed\n&quot;</span>;</div>
<div class="line"><span class="lineno"> 157</span>}</div>
<div class="ttc" id="abrent__method__extrema_8cpp_html_a1aa76a6d5fd4d333f9072beff1dc486b"><div class="ttname"><a href="../../db/d01/brent__method__extrema_8cpp.html#a1aa76a6d5fd4d333f9072beff1dc486b">get_minima</a></div><div class="ttdeci">double get_minima(const std::function&lt; double(double)&gt; &amp;f, double lim_a, double lim_b)</div><div class="ttdoc">Get the real root of a function in the given interval.</div><div class="ttdef"><b>Definition:</b> brent_method_extrema.cpp:35</div></div>
<div class="ttc" id="afunction_html"><div class="ttname"><a href="http://en.cppreference.com/w/cpp/utility/functional/function.html">std::function</a></div></div>
</div><!-- fragment --><div class="dynheader">
@@ -425,22 +425,22 @@ Here is the call graph for this function:</div>
<p>Test function to find root for the function \(f(x)= x^{\frac{1}{x}}\) in the interval \([-2,10]\) <br />
Expected result: \(e\approx 2.71828182845904509\). </p>
<div class="fragment"><div class="line"><a id="l00165" name="l00165"></a><span class="lineno"> 165</span> {</div>
<div class="line"><a id="l00166" name="l00166"></a><span class="lineno"> 166</span> <span class="comment">// define the function to maximize as a lambda function</span></div>
<div class="line"><a id="l00167" name="l00167"></a><span class="lineno"> 167</span> <span class="comment">// since we are maximixing, we negated the function return value</span></div>
<div class="line"><a id="l00168" name="l00168"></a><span class="lineno"> 168</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/utility/functional/function.html">std::function</a>&lt;double(<span class="keywordtype">double</span>)&gt; func = [](<span class="keywordtype">double</span> x) {</div>
<div class="line"><a id="l00169" name="l00169"></a><span class="lineno"> 169</span> <span class="keywordflow">return</span> -<a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/numeric/math/pow.html">std::pow</a>(x, 1.f / x);</div>
<div class="line"><a id="l00170" name="l00170"></a><span class="lineno"> 170</span> };</div>
<div class="line"><a id="l00171" name="l00171"></a><span class="lineno"> 171</span> </div>
<div class="line"><a id="l00172" name="l00172"></a><span class="lineno"> 172</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;Test 2.... &quot;</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="keywordtype">double</span> minima = <a class="code hl_function" href="../../db/d01/brent__method__extrema_8cpp.html#a1aa76a6d5fd4d333f9072beff1dc486b">get_minima</a>(func, -2, 5);</div>
<div class="line"><a id="l00175" name="l00175"></a><span class="lineno"> 175</span> </div>
<div class="line"><a id="l00176" name="l00176"></a><span class="lineno"> 176</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/basic_ostream.html">std::cout</a> &lt;&lt; minima &lt;&lt; <span class="stringliteral">&quot; (&quot;</span> &lt;&lt; M_E &lt;&lt; <span class="stringliteral">&quot;)...&quot;</span>;</div>
<div class="line"><a id="l00177" name="l00177"></a><span class="lineno"> 177</span> </div>
<div class="line"><a id="l00178" name="l00178"></a><span class="lineno"> 178</span> assert(std::abs(minima - M_E) &lt; <a class="code hl_define" href="../../db/d01/brent__method__extrema_8cpp.html#a002b2f4894492820fe708b1b7e7c5e70">EPSILON</a>);</div>
<div class="line"><a id="l00179" name="l00179"></a><span class="lineno"> 179</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;passed\n&quot;</span>;</div>
<div class="line"><a id="l00180" name="l00180"></a><span class="lineno"> 180</span>}</div>
<div class="fragment"><div class="line"><span class="lineno"> 165</span> {</div>
<div class="line"><span class="lineno"> 166</span> <span class="comment">// define the function to maximize as a lambda function</span></div>
<div class="line"><span class="lineno"> 167</span> <span class="comment">// since we are maximixing, we negated the function return value</span></div>
<div class="line"><span class="lineno"> 168</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/utility/functional/function.html">std::function</a>&lt;double(<span class="keywordtype">double</span>)&gt; func = [](<span class="keywordtype">double</span> x) {</div>
<div class="line"><span class="lineno"> 169</span> <span class="keywordflow">return</span> -<a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/numeric/math/pow.html">std::pow</a>(x, 1.f / x);</div>
<div class="line"><span class="lineno"> 170</span> };</div>
<div class="line"><span class="lineno"> 171</span> </div>
<div class="line"><span class="lineno"> 172</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;Test 2.... &quot;</span>;</div>
<div class="line"><span class="lineno"> 173</span> </div>
<div class="line"><span class="lineno"> 174</span> <span class="keywordtype">double</span> minima = <a class="code hl_function" href="../../db/d01/brent__method__extrema_8cpp.html#a1aa76a6d5fd4d333f9072beff1dc486b">get_minima</a>(func, -2, 5);</div>
<div class="line"><span class="lineno"> 175</span> </div>
<div class="line"><span class="lineno"> 176</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/basic_ostream.html">std::cout</a> &lt;&lt; minima &lt;&lt; <span class="stringliteral">&quot; (&quot;</span> &lt;&lt; M_E &lt;&lt; <span class="stringliteral">&quot;)...&quot;</span>;</div>
<div class="line"><span class="lineno"> 177</span> </div>
<div class="line"><span class="lineno"> 178</span> assert(std::abs(minima - M_E) &lt; <a class="code hl_define" href="../../db/d01/brent__method__extrema_8cpp.html#a002b2f4894492820fe708b1b7e7c5e70">EPSILON</a>);</div>
<div class="line"><span class="lineno"> 179</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;passed\n&quot;</span>;</div>
<div class="line"><span class="lineno"> 180</span>}</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">
Here is the call graph for this function:</div>
@@ -468,20 +468,20 @@ Here is the call graph for this function:</div>
<p>Test function to find <em>maxima</em> for the function \(f(x)= \cos x\) in the interval \([0,12]\) <br />
Expected result: \(\pi\approx 3.14159265358979312\). </p>
<div class="fragment"><div class="line"><a id="l00188" name="l00188"></a><span class="lineno"> 188</span> {</div>
<div class="line"><a id="l00189" name="l00189"></a><span class="lineno"> 189</span> <span class="comment">// define the function to maximize as a lambda function</span></div>
<div class="line"><a id="l00190" name="l00190"></a><span class="lineno"> 190</span> <span class="comment">// since we are maximixing, we negated the function return value</span></div>
<div class="line"><a id="l00191" name="l00191"></a><span class="lineno"> 191</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/utility/functional/function.html">std::function</a>&lt;double(<span class="keywordtype">double</span>)&gt; func = [](<span class="keywordtype">double</span> x) { <span class="keywordflow">return</span> <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"><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> <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;Test 3.... &quot;</span>;</div>
<div class="line"><a id="l00194" name="l00194"></a><span class="lineno"> 194</span> </div>
<div class="line"><a id="l00195" name="l00195"></a><span class="lineno"> 195</span> <span class="keywordtype">double</span> minima = <a class="code hl_function" href="../../db/d01/brent__method__extrema_8cpp.html#a1aa76a6d5fd4d333f9072beff1dc486b">get_minima</a>(func, -4, 12);</div>
<div class="line"><a id="l00196" name="l00196"></a><span class="lineno"> 196</span> </div>
<div class="line"><a id="l00197" name="l00197"></a><span class="lineno"> 197</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/basic_ostream.html">std::cout</a> &lt;&lt; minima &lt;&lt; <span class="stringliteral">&quot; (&quot;</span> &lt;&lt; M_PI &lt;&lt; <span class="stringliteral">&quot;)...&quot;</span>;</div>
<div class="line"><a id="l00198" name="l00198"></a><span class="lineno"> 198</span> </div>
<div class="line"><a id="l00199" name="l00199"></a><span class="lineno"> 199</span> assert(std::abs(minima - M_PI) &lt; <a class="code hl_define" href="../../db/d01/brent__method__extrema_8cpp.html#a002b2f4894492820fe708b1b7e7c5e70">EPSILON</a>);</div>
<div class="line"><a id="l00200" name="l00200"></a><span class="lineno"> 200</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;passed\n&quot;</span>;</div>
<div class="line"><a id="l00201" name="l00201"></a><span class="lineno"> 201</span>}</div>
<div class="fragment"><div class="line"><span class="lineno"> 188</span> {</div>
<div class="line"><span class="lineno"> 189</span> <span class="comment">// define the function to maximize as a lambda function</span></div>
<div class="line"><span class="lineno"> 190</span> <span class="comment">// since we are maximixing, we negated the function return value</span></div>
<div class="line"><span class="lineno"> 191</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/utility/functional/function.html">std::function</a>&lt;double(<span class="keywordtype">double</span>)&gt; func = [](<span class="keywordtype">double</span> x) { <span class="keywordflow">return</span> <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"> 192</span> </div>
<div class="line"><span class="lineno"> 193</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;Test 3.... &quot;</span>;</div>
<div class="line"><span class="lineno"> 194</span> </div>
<div class="line"><span class="lineno"> 195</span> <span class="keywordtype">double</span> minima = <a class="code hl_function" href="../../db/d01/brent__method__extrema_8cpp.html#a1aa76a6d5fd4d333f9072beff1dc486b">get_minima</a>(func, -4, 12);</div>
<div class="line"><span class="lineno"> 196</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_ostream.html">std::cout</a> &lt;&lt; minima &lt;&lt; <span class="stringliteral">&quot; (&quot;</span> &lt;&lt; M_PI &lt;&lt; <span class="stringliteral">&quot;)...&quot;</span>;</div>
<div class="line"><span class="lineno"> 198</span> </div>
<div class="line"><span class="lineno"> 199</span> assert(std::abs(minima - M_PI) &lt; <a class="code hl_define" href="../../db/d01/brent__method__extrema_8cpp.html#a002b2f4894492820fe708b1b7e7c5e70">EPSILON</a>);</div>
<div class="line"><span class="lineno"> 200</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;passed\n&quot;</span>;</div>
<div class="line"><span class="lineno"> 201</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><!-- fragment --><div class="dynheader">
Here is the call graph for this function:</div>
@@ -498,7 +498,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="../../db/d01/brent__method__extrema_8cpp.html">brent_method_extrema.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>

View File

@@ -1,7 +1,7 @@
<map id="test2" name="test2">
<area shape="rect" id="node1" title="Test function to find root for the function &#160;in the interval &#160;&#160;&#160;Expected result: ." alt="" coords="5,56,56,83"/>
<area shape="rect" id="node2" href="$db/d01/brent__method__extrema_8cpp.html#a1aa76a6d5fd4d333f9072beff1dc486b" title="Get the real root of a function in the given interval." alt="" coords="104,31,193,57"/>
<area shape="rect" id="node5" href="/Users/runner/work/C-Plus-Plus/C-Plus-Plus/doc/cppreference-doxygen-web.tag.xml$cpp/numeric/math/pow.html#" title=" " alt="" coords="113,81,185,108"/>
<area shape="rect" id="node3" href="/Users/runner/work/C-Plus-Plus/C-Plus-Plus/doc/cppreference-doxygen-web.tag.xml$cpp/numeric/math/sqrt.html#" title=" " alt="" coords="245,5,316,32"/>
<area shape="rect" id="node4" href="/Users/runner/work/C-Plus-Plus/C-Plus-Plus/doc/cppreference-doxygen-web.tag.xml$cpp/algorithm/swap.html#" title=" " alt="" coords="241,56,320,83"/>
<area shape="rect" id="node5" href="/Users/runner/work/C-Plus-Plus/C-Plus-Plus/doc/cppreference-doxygen-web.tag.xml$cpp/numeric/math/pow#" title=" " alt="" coords="113,81,185,108"/>
<area shape="rect" id="node3" href="/Users/runner/work/C-Plus-Plus/C-Plus-Plus/doc/cppreference-doxygen-web.tag.xml$cpp/numeric/math/sqrt#" title=" " alt="" coords="245,5,316,32"/>
<area shape="rect" id="node4" href="/Users/runner/work/C-Plus-Plus/C-Plus-Plus/doc/cppreference-doxygen-web.tag.xml$cpp/algorithm/swap#" title=" " alt="" coords="241,56,320,83"/>
</map>

View File

@@ -1 +1 @@
07a2610fa56c3c1116c699d944f4c856
c940e256b946ad9d928b3685151d31e7

View File

@@ -36,7 +36,7 @@
<!-- Node5 -->
<g id="node5" class="node">
<title>Node5</title>
<g id="a_node5"><a target="_blank" xlink:href="http://en.cppreference.com/w/cpp/numeric/math/pow.html#" xlink:title=" ">
<g id="a_node5"><a target="_blank" xlink:href="http://en.cppreference.com/w/cpp/numeric/math/pow#" xlink:title=" ">
<polygon fill="white" stroke="black" points="80.5,-0.5 80.5,-19.5 134.5,-19.5 134.5,-0.5 80.5,-0.5"/>
<text text-anchor="middle" x="107.5" y="-7.5" font-family="Helvetica,sans-Serif" font-size="10.00">std::pow</text>
</a>
@@ -51,7 +51,7 @@
<!-- Node3 -->
<g id="node3" class="node">
<title>Node3</title>
<g id="a_node3"><a target="_blank" xlink:href="http://en.cppreference.com/w/cpp/numeric/math/sqrt.html#" xlink:title=" ">
<g id="a_node3"><a target="_blank" xlink:href="http://en.cppreference.com/w/cpp/numeric/math/sqrt#" xlink:title=" ">
<polygon fill="white" stroke="black" points="180,-57.5 180,-76.5 233,-76.5 233,-57.5 180,-57.5"/>
<text text-anchor="middle" x="206.5" y="-64.5" font-family="Helvetica,sans-Serif" font-size="10.00">std::sqrt</text>
</a>
@@ -66,7 +66,7 @@
<!-- Node4 -->
<g id="node4" class="node">
<title>Node4</title>
<g id="a_node4"><a target="_blank" xlink:href="http://en.cppreference.com/w/cpp/algorithm/swap.html#" xlink:title=" ">
<g id="a_node4"><a target="_blank" xlink:href="http://en.cppreference.com/w/cpp/algorithm/swap#" xlink:title=" ">
<polygon fill="white" stroke="black" points="177,-19.5 177,-38.5 236,-38.5 236,-19.5 177,-19.5"/>
<text text-anchor="middle" x="206.5" y="-26.5" font-family="Helvetica,sans-Serif" font-size="10.00">std::swap</text>
</a>

Before

Width:  |  Height:  |  Size: 3.9 KiB

After

Width:  |  Height:  |  Size: 3.9 KiB

View File

@@ -1,6 +1,6 @@
<map id="test1" name="test1">
<area shape="rect" id="node1" title="Test function to find root for the function &#160;in the interval &#160;&#160;&#160;Expected result = 2." alt="" coords="5,31,56,57"/>
<area shape="rect" id="node2" href="$db/d01/brent__method__extrema_8cpp.html#a1aa76a6d5fd4d333f9072beff1dc486b" title="Get the real root of a function in the given interval." alt="" coords="104,31,193,57"/>
<area shape="rect" id="node3" href="/Users/runner/work/C-Plus-Plus/C-Plus-Plus/doc/cppreference-doxygen-web.tag.xml$cpp/numeric/math/sqrt.html#" title=" " alt="" coords="245,5,316,32"/>
<area shape="rect" id="node4" href="/Users/runner/work/C-Plus-Plus/C-Plus-Plus/doc/cppreference-doxygen-web.tag.xml$cpp/algorithm/swap.html#" title=" " alt="" coords="241,56,320,83"/>
<area shape="rect" id="node3" href="/Users/runner/work/C-Plus-Plus/C-Plus-Plus/doc/cppreference-doxygen-web.tag.xml$cpp/numeric/math/sqrt#" title=" " alt="" coords="245,5,316,32"/>
<area shape="rect" id="node4" href="/Users/runner/work/C-Plus-Plus/C-Plus-Plus/doc/cppreference-doxygen-web.tag.xml$cpp/algorithm/swap#" title=" " alt="" coords="241,56,320,83"/>
</map>

View File

@@ -1 +1 @@
af2c8af6e7e431c1063353c2dcefe6c3
07c92125cf78bb2293fc2055a1995fe7

View File

@@ -36,7 +36,7 @@
<!-- Node3 -->
<g id="node3" class="node">
<title>Node3</title>
<g id="a_node3"><a target="_blank" xlink:href="http://en.cppreference.com/w/cpp/numeric/math/sqrt.html#" xlink:title=" ">
<g id="a_node3"><a target="_blank" xlink:href="http://en.cppreference.com/w/cpp/numeric/math/sqrt#" xlink:title=" ">
<polygon fill="white" stroke="black" points="180,-38.5 180,-57.5 233,-57.5 233,-38.5 180,-38.5"/>
<text text-anchor="middle" x="206.5" y="-45.5" font-family="Helvetica,sans-Serif" font-size="10.00">std::sqrt</text>
</a>
@@ -51,7 +51,7 @@
<!-- Node4 -->
<g id="node4" class="node">
<title>Node4</title>
<g id="a_node4"><a target="_blank" xlink:href="http://en.cppreference.com/w/cpp/algorithm/swap.html#" xlink:title=" ">
<g id="a_node4"><a target="_blank" xlink:href="http://en.cppreference.com/w/cpp/algorithm/swap#" xlink:title=" ">
<polygon fill="white" stroke="black" points="177,-0.5 177,-19.5 236,-19.5 236,-0.5 177,-0.5"/>
<text text-anchor="middle" x="206.5" y="-7.5" font-family="Helvetica,sans-Serif" font-size="10.00">std::swap</text>
</a>

Before

Width:  |  Height:  |  Size: 3.2 KiB

After

Width:  |  Height:  |  Size: 3.2 KiB

View File

@@ -1,5 +1,5 @@
<map id="get_minima" name="get_minima">
<area shape="rect" id="node1" title="Get the real root of a function in the given interval." alt="" coords="5,31,95,57"/>
<area shape="rect" id="node2" href="/Users/runner/work/C-Plus-Plus/C-Plus-Plus/doc/cppreference-doxygen-web.tag.xml$cpp/numeric/math/sqrt.html#" title=" " alt="" coords="147,5,217,32"/>
<area shape="rect" id="node3" href="/Users/runner/work/C-Plus-Plus/C-Plus-Plus/doc/cppreference-doxygen-web.tag.xml$cpp/algorithm/swap.html#" title=" " alt="" coords="143,56,221,83"/>
<area shape="rect" id="node2" href="/Users/runner/work/C-Plus-Plus/C-Plus-Plus/doc/cppreference-doxygen-web.tag.xml$cpp/numeric/math/sqrt#" title=" " alt="" coords="147,5,217,32"/>
<area shape="rect" id="node3" href="/Users/runner/work/C-Plus-Plus/C-Plus-Plus/doc/cppreference-doxygen-web.tag.xml$cpp/algorithm/swap#" title=" " alt="" coords="143,56,221,83"/>
</map>

View File

@@ -1 +1 @@
e5bf1cb2eeb1c7d552594e1071b48d11
7d411109f061442d2e9c0cc1fb33e5f8

View File

@@ -21,7 +21,7 @@
<!-- Node2 -->
<g id="node2" class="node">
<title>Node2</title>
<g id="a_node2"><a target="_blank" xlink:href="http://en.cppreference.com/w/cpp/numeric/math/sqrt.html#" xlink:title=" ">
<g id="a_node2"><a target="_blank" xlink:href="http://en.cppreference.com/w/cpp/numeric/math/sqrt#" xlink:title=" ">
<polygon fill="white" stroke="black" points="106,-38.5 106,-57.5 159,-57.5 159,-38.5 106,-38.5"/>
<text text-anchor="middle" x="132.5" y="-45.5" font-family="Helvetica,sans-Serif" font-size="10.00">std::sqrt</text>
</a>
@@ -36,7 +36,7 @@
<!-- Node3 -->
<g id="node3" class="node">
<title>Node3</title>
<g id="a_node3"><a target="_blank" xlink:href="http://en.cppreference.com/w/cpp/algorithm/swap.html#" xlink:title=" ">
<g id="a_node3"><a target="_blank" xlink:href="http://en.cppreference.com/w/cpp/algorithm/swap#" xlink:title=" ">
<polygon fill="white" stroke="black" points="103,-0.5 103,-19.5 162,-19.5 162,-0.5 103,-0.5"/>
<text text-anchor="middle" x="132.5" y="-7.5" font-family="Helvetica,sans-Serif" font-size="10.00">std::swap</text>
</a>

Before

Width:  |  Height:  |  Size: 2.4 KiB

After

Width:  |  Height:  |  Size: 2.4 KiB

View File

@@ -1,7 +1,7 @@
<map id="test3" name="test3">
<area shape="rect" id="node1" title="Test function to find maxima for the function &#160;in the interval &#160;&#160;&#160;Expected result: ." alt="" coords="5,31,56,57"/>
<area shape="rect" id="node2" href="/Users/runner/work/C-Plus-Plus/C-Plus-Plus/doc/cppreference-doxygen-web.tag.xml$cpp/numeric/math/cos.html#" title=" " alt="" coords="114,5,183,32"/>
<area shape="rect" id="node2" href="/Users/runner/work/C-Plus-Plus/C-Plus-Plus/doc/cppreference-doxygen-web.tag.xml$cpp/numeric/math/cos#" title=" " alt="" coords="114,5,183,32"/>
<area shape="rect" id="node3" href="$db/d01/brent__method__extrema_8cpp.html#a1aa76a6d5fd4d333f9072beff1dc486b" title="Get the real root of a function in the given interval." alt="" coords="104,56,193,83"/>
<area shape="rect" id="node4" href="/Users/runner/work/C-Plus-Plus/C-Plus-Plus/doc/cppreference-doxygen-web.tag.xml$cpp/numeric/math/sqrt.html#" title=" " alt="" coords="245,31,316,57"/>
<area shape="rect" id="node5" href="/Users/runner/work/C-Plus-Plus/C-Plus-Plus/doc/cppreference-doxygen-web.tag.xml$cpp/algorithm/swap.html#" title=" " alt="" coords="241,81,320,108"/>
<area shape="rect" id="node4" href="/Users/runner/work/C-Plus-Plus/C-Plus-Plus/doc/cppreference-doxygen-web.tag.xml$cpp/numeric/math/sqrt#" title=" " alt="" coords="245,31,316,57"/>
<area shape="rect" id="node5" href="/Users/runner/work/C-Plus-Plus/C-Plus-Plus/doc/cppreference-doxygen-web.tag.xml$cpp/algorithm/swap#" title=" " alt="" coords="241,81,320,108"/>
</map>

View File

@@ -1 +1 @@
6786877db7f419e38717fa3378b2c413
dc5d40866f069a744f3d7729c722d4a4

View File

@@ -21,7 +21,7 @@
<!-- Node2 -->
<g id="node2" class="node">
<title>Node2</title>
<g id="a_node2"><a target="_blank" xlink:href="http://en.cppreference.com/w/cpp/numeric/math/cos.html#" xlink:title=" ">
<g id="a_node2"><a target="_blank" xlink:href="http://en.cppreference.com/w/cpp/numeric/math/cos#" xlink:title=" ">
<polygon fill="white" stroke="black" points="81.5,-57.5 81.5,-76.5 133.5,-76.5 133.5,-57.5 81.5,-57.5"/>
<text text-anchor="middle" x="107.5" y="-64.5" font-family="Helvetica,sans-Serif" font-size="10.00">std::cos</text>
</a>
@@ -51,7 +51,7 @@
<!-- Node4 -->
<g id="node4" class="node">
<title>Node4</title>
<g id="a_node4"><a target="_blank" xlink:href="http://en.cppreference.com/w/cpp/numeric/math/sqrt.html#" xlink:title=" ">
<g id="a_node4"><a target="_blank" xlink:href="http://en.cppreference.com/w/cpp/numeric/math/sqrt#" xlink:title=" ">
<polygon fill="white" stroke="black" points="180,-38.5 180,-57.5 233,-57.5 233,-38.5 180,-38.5"/>
<text text-anchor="middle" x="206.5" y="-45.5" font-family="Helvetica,sans-Serif" font-size="10.00">std::sqrt</text>
</a>
@@ -66,7 +66,7 @@
<!-- Node5 -->
<g id="node5" class="node">
<title>Node5</title>
<g id="a_node5"><a target="_blank" xlink:href="http://en.cppreference.com/w/cpp/algorithm/swap.html#" xlink:title=" ">
<g id="a_node5"><a target="_blank" xlink:href="http://en.cppreference.com/w/cpp/algorithm/swap#" xlink:title=" ">
<polygon fill="white" stroke="black" points="177,-0.5 177,-19.5 236,-19.5 236,-0.5 177,-0.5"/>
<text text-anchor="middle" x="206.5" y="-7.5" font-family="Helvetica,sans-Serif" font-size="10.00">std::swap</text>
</a>

Before

Width:  |  Height:  |  Size: 3.9 KiB

After

Width:  |  Height:  |  Size: 3.9 KiB

View File

@@ -4,8 +4,8 @@
<area shape="rect" id="node6" href="$db/d01/brent__method__extrema_8cpp.html#a0283886819c7c140a023582b7269e2d0" title="Test function to find root for the function &#160;in the interval &#160;&#160;&#160;Expected result: ." alt="" coords="104,5,155,32"/>
<area shape="rect" id="node8" href="$db/d01/brent__method__extrema_8cpp.html#a6d0455dd5c30adda100e95f0423c786e" title="Test function to find maxima for the function &#160;in the interval &#160;&#160;&#160;Expected result: ." alt="" coords="104,107,155,133"/>
<area shape="rect" id="node3" href="$db/d01/brent__method__extrema_8cpp.html#a1aa76a6d5fd4d333f9072beff1dc486b" title="Get the real root of a function in the given interval." alt="" coords="203,56,292,83"/>
<area shape="rect" id="node4" href="/Users/runner/work/C-Plus-Plus/C-Plus-Plus/doc/cppreference-doxygen-web.tag.xml$cpp/numeric/math/sqrt.html#" title=" " alt="" coords="344,31,415,57"/>
<area shape="rect" id="node5" href="/Users/runner/work/C-Plus-Plus/C-Plus-Plus/doc/cppreference-doxygen-web.tag.xml$cpp/algorithm/swap.html#" title=" " alt="" coords="340,81,419,108"/>
<area shape="rect" id="node7" href="/Users/runner/work/C-Plus-Plus/C-Plus-Plus/doc/cppreference-doxygen-web.tag.xml$cpp/numeric/math/pow.html#" title=" " alt="" coords="211,5,283,32"/>
<area shape="rect" id="node9" href="/Users/runner/work/C-Plus-Plus/C-Plus-Plus/doc/cppreference-doxygen-web.tag.xml$cpp/numeric/math/cos.html#" title=" " alt="" coords="213,107,282,133"/>
<area shape="rect" id="node4" href="/Users/runner/work/C-Plus-Plus/C-Plus-Plus/doc/cppreference-doxygen-web.tag.xml$cpp/numeric/math/sqrt#" title=" " alt="" coords="344,31,415,57"/>
<area shape="rect" id="node5" href="/Users/runner/work/C-Plus-Plus/C-Plus-Plus/doc/cppreference-doxygen-web.tag.xml$cpp/algorithm/swap#" title=" " alt="" coords="340,81,419,108"/>
<area shape="rect" id="node7" href="/Users/runner/work/C-Plus-Plus/C-Plus-Plus/doc/cppreference-doxygen-web.tag.xml$cpp/numeric/math/pow#" title=" " alt="" coords="211,5,283,32"/>
<area shape="rect" id="node9" href="/Users/runner/work/C-Plus-Plus/C-Plus-Plus/doc/cppreference-doxygen-web.tag.xml$cpp/numeric/math/cos#" title=" " alt="" coords="213,107,282,133"/>
</map>

View File

@@ -1 +1 @@
70ccdac96f3f81e33fa112f00ed25073
8b0e283cbc495c606078e0093e51e7cb

View File

@@ -81,7 +81,7 @@
<!-- Node4 -->
<g id="node4" class="node">
<title>Node4</title>
<g id="a_node4"><a target="_blank" xlink:href="http://en.cppreference.com/w/cpp/numeric/math/sqrt.html#" xlink:title=" ">
<g id="a_node4"><a target="_blank" xlink:href="http://en.cppreference.com/w/cpp/numeric/math/sqrt#" xlink:title=" ">
<polygon fill="white" stroke="black" points="254,-57.5 254,-76.5 307,-76.5 307,-57.5 254,-57.5"/>
<text text-anchor="middle" x="280.5" y="-64.5" font-family="Helvetica,sans-Serif" font-size="10.00">std::sqrt</text>
</a>
@@ -96,7 +96,7 @@
<!-- Node5 -->
<g id="node5" class="node">
<title>Node5</title>
<g id="a_node5"><a target="_blank" xlink:href="http://en.cppreference.com/w/cpp/algorithm/swap.html#" xlink:title=" ">
<g id="a_node5"><a target="_blank" xlink:href="http://en.cppreference.com/w/cpp/algorithm/swap#" xlink:title=" ">
<polygon fill="white" stroke="black" points="251,-19.5 251,-38.5 310,-38.5 310,-19.5 251,-19.5"/>
<text text-anchor="middle" x="280.5" y="-26.5" font-family="Helvetica,sans-Serif" font-size="10.00">std::swap</text>
</a>
@@ -117,7 +117,7 @@
<!-- Node7 -->
<g id="node7" class="node">
<title>Node7</title>
<g id="a_node7"><a target="_blank" xlink:href="http://en.cppreference.com/w/cpp/numeric/math/pow.html#" xlink:title=" ">
<g id="a_node7"><a target="_blank" xlink:href="http://en.cppreference.com/w/cpp/numeric/math/pow#" xlink:title=" ">
<polygon fill="white" stroke="black" points="154.5,-76.5 154.5,-95.5 208.5,-95.5 208.5,-76.5 154.5,-76.5"/>
<text text-anchor="middle" x="181.5" y="-83.5" font-family="Helvetica,sans-Serif" font-size="10.00">std::pow</text>
</a>
@@ -138,7 +138,7 @@
<!-- Node9 -->
<g id="node9" class="node">
<title>Node9</title>
<g id="a_node9"><a target="_blank" xlink:href="http://en.cppreference.com/w/cpp/numeric/math/cos.html#" xlink:title=" ">
<g id="a_node9"><a target="_blank" xlink:href="http://en.cppreference.com/w/cpp/numeric/math/cos#" xlink:title=" ">
<polygon fill="white" stroke="black" points="155.5,-0.5 155.5,-19.5 207.5,-19.5 207.5,-0.5 155.5,-0.5"/>
<text text-anchor="middle" x="181.5" y="-7.5" font-family="Helvetica,sans-Serif" font-size="10.00">std::cos</text>
</a>

Before

Width:  |  Height:  |  Size: 7.6 KiB

After

Width:  |  Height:  |  Size: 7.5 KiB

View File

@@ -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++: ST</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">&#160;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&amp;dn=expat.txt MIT */
var searchBox = new SearchBox("searchBox", "../../search",'Search','.html');
@@ -93,6 +93,7 @@ $(document).ready(function(){initNavTree('db/d03/_s_t-example.html','../../'); i
<div class="headertitle"><div class="title">ST</div></div>
</div><!--header-->
<div class="contents">
<p >Builds the sparse table for computing min/max/gcd/lcm/...etc for any contiguous sub-segment of the array.This is an example of computing the index of the minimum value.</p>
<p >Builds the sparse table for computing min/max/gcd/lcm/...etc for any contiguous sub-segment of the array.This is an example of computing the index of the minimum value. </p><dl class="section return"><dt>Returns</dt><dd>void @complexity: O(n.log(n))&lt; precomputing <code>log2(i+1)</code></dd></dl>
<dl class="section note"><dt>Note</dt><dd>notice how we deal with the range of length <code>pow(2,i)</code>, and we can reuse the computation that we did for the range of length <code>pow(2,i-1)</code>.</dd></dl>
<p>So, ST[j][i] = min( ST[j-1][i], ST[j-1][i + pow(2,j-1)]). [2][3] = min(ST[1][3], ST[1][5])</p>
@@ -101,7 +102,7 @@ $(document).ready(function(){initNavTree('db/d03/_s_t-example.html','../../'); i
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
<ul>
<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>

View File

@@ -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++: wildcard_matching Namespace 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">&#160;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&amp;dn=expat.txt MIT */
var searchBox = new SearchBox("searchBox", "../../search",'Search','.html');
@@ -104,7 +104,7 @@ $(document).ready(function(){initNavTree('db/d03/namespacewildcard__matching.htm
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
<ul>
<li class="navelem"><a class="el" href="../../db/d03/namespacewildcard__matching.html">wildcard_matching</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>

View File

@@ -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++: others/spiral_print.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">&#160;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&amp;dn=expat.txt MIT */
var searchBox = new SearchBox("searchBox", "../../search",'Search','.html');
@@ -157,17 +157,17 @@ Functions</h2></td></tr>
</table>
</dd>
</dl>
<div class="fragment"><div class="line"><a id="l00012" name="l00012"></a><span class="lineno"> 12</span> {</div>
<div class="line"><a id="l00013" name="l00013"></a><span class="lineno"> 13</span> <span class="keywordtype">int</span> value = 1;</div>
<div class="line"><a id="l00014" name="l00014"></a><span class="lineno"> 14</span> <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i &lt; r; i++) {</div>
<div class="line"><a id="l00015" name="l00015"></a><span class="lineno"> 15</span> <span class="keywordflow">for</span> (<span class="keywordtype">int</span> j = 0; j &lt; c; j++) {</div>
<div class="line"><a id="l00016" name="l00016"></a><span class="lineno"> 16</span> a[i][j] = value;</div>
<div class="line"><a id="l00017" name="l00017"></a><span class="lineno"> 17</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/basic_ostream.html">std::cout</a> &lt;&lt; a[i][j] &lt;&lt; <span class="stringliteral">&quot; &quot;</span>;</div>
<div class="line"><a id="l00018" name="l00018"></a><span class="lineno"> 18</span> value++;</div>
<div class="line"><a id="l00019" name="l00019"></a><span class="lineno"> 19</span> }</div>
<div class="line"><a id="l00020" name="l00020"></a><span class="lineno"> 20</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/basic_ostream.html">std::cout</a> &lt;&lt; <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="l00021" name="l00021"></a><span class="lineno"> 21</span> }</div>
<div class="line"><a id="l00022" name="l00022"></a><span class="lineno"> 22</span>}</div>
<div class="fragment"><div class="line"><span class="lineno"> 12</span> {</div>
<div class="line"><span class="lineno"> 13</span> <span class="keywordtype">int</span> value = 1;</div>
<div class="line"><span class="lineno"> 14</span> <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i &lt; r; i++) {</div>
<div class="line"><span class="lineno"> 15</span> <span class="keywordflow">for</span> (<span class="keywordtype">int</span> j = 0; j &lt; c; j++) {</div>
<div class="line"><span class="lineno"> 16</span> a[i][j] = value;</div>
<div class="line"><span class="lineno"> 17</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/basic_ostream.html">std::cout</a> &lt;&lt; a[i][j] &lt;&lt; <span class="stringliteral">&quot; &quot;</span>;</div>
<div class="line"><span class="lineno"> 18</span> value++;</div>
<div class="line"><span class="lineno"> 19</span> }</div>
<div class="line"><span class="lineno"> 20</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/basic_ostream.html">std::cout</a> &lt;&lt; <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"> 21</span> }</div>
<div class="line"><span class="lineno"> 22</span>}</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="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><!-- fragment --><div class="dynheader">
@@ -195,19 +195,19 @@ Here is the call graph for this function:</div>
</table>
</div><div class="memdoc">
<p >main function </p>
<div class="fragment"><div class="line"><a id="l00069" name="l00069"></a><span class="lineno"> 69</span> {</div>
<div class="line"><a id="l00070" name="l00070"></a><span class="lineno"> 70</span> <span class="keywordtype">int</span> r, c;</div>
<div class="line"><a id="l00071" name="l00071"></a><span class="lineno"> 71</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/basic_istream.html">std::cin</a> &gt;&gt; r &gt;&gt; c;</div>
<div class="line"><a id="l00072" name="l00072"></a><span class="lineno"> 72</span> <span class="keywordtype">int</span> **a = <span class="keyword">new</span> <span class="keywordtype">int</span> *[r];</div>
<div class="line"><a id="l00073" name="l00073"></a><span class="lineno"> 73</span> <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i &lt; r; i++) a[i] = <span class="keyword">new</span> <span class="keywordtype">int</span>[c];</div>
<div class="line"><a id="l00074" name="l00074"></a><span class="lineno"> 74</span> </div>
<div class="line"><a id="l00075" name="l00075"></a><span class="lineno"> 75</span> <a class="code hl_function" href="../../db/d07/spiral__print_8cpp.html#acfff36db81326fb990a643ab198ee8a5">genArray</a>(a, r, c);</div>
<div class="line"><a id="l00076" name="l00076"></a><span class="lineno"> 76</span> <a class="code hl_function" href="../../db/d07/spiral__print_8cpp.html#a850d3f55e1a8d227176cdcc67352c197">spiralPrint</a>(a, r, c);</div>
<div class="line"><a id="l00077" name="l00077"></a><span class="lineno"> 77</span> </div>
<div class="line"><a id="l00078" name="l00078"></a><span class="lineno"> 78</span> <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i &lt; r; i++) <span class="keyword">delete</span>[] a[i];</div>
<div class="line"><a id="l00079" name="l00079"></a><span class="lineno"> 79</span> <span class="keyword">delete</span>[] a;</div>
<div class="line"><a id="l00080" name="l00080"></a><span class="lineno"> 80</span> <span class="keywordflow">return</span> 0;</div>
<div class="line"><a id="l00081" name="l00081"></a><span class="lineno"> 81</span>}</div>
<div class="fragment"><div class="line"><span class="lineno"> 69</span> {</div>
<div class="line"><span class="lineno"> 70</span> <span class="keywordtype">int</span> r, c;</div>
<div class="line"><span class="lineno"> 71</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/basic_istream.html">std::cin</a> &gt;&gt; r &gt;&gt; c;</div>
<div class="line"><span class="lineno"> 72</span> <span class="keywordtype">int</span> **a = <span class="keyword">new</span> <span class="keywordtype">int</span> *[r];</div>
<div class="line"><span class="lineno"> 73</span> <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i &lt; r; i++) a[i] = <span class="keyword">new</span> <span class="keywordtype">int</span>[c];</div>
<div class="line"><span class="lineno"> 74</span> </div>
<div class="line"><span class="lineno"> 75</span> <a class="code hl_function" href="../../db/d07/spiral__print_8cpp.html#acfff36db81326fb990a643ab198ee8a5">genArray</a>(a, r, c);</div>
<div class="line"><span class="lineno"> 76</span> <a class="code hl_function" href="../../db/d07/spiral__print_8cpp.html#a850d3f55e1a8d227176cdcc67352c197">spiralPrint</a>(a, r, c);</div>
<div class="line"><span class="lineno"> 77</span> </div>
<div class="line"><span class="lineno"> 78</span> <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i &lt; r; i++) <span class="keyword">delete</span>[] a[i];</div>
<div class="line"><span class="lineno"> 79</span> <span class="keyword">delete</span>[] a;</div>
<div class="line"><span class="lineno"> 80</span> <span class="keywordflow">return</span> 0;</div>
<div class="line"><span class="lineno"> 81</span>}</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="aspiral__print_8cpp_html_a850d3f55e1a8d227176cdcc67352c197"><div class="ttname"><a href="../../db/d07/spiral__print_8cpp.html#a850d3f55e1a8d227176cdcc67352c197">spiralPrint</a></div><div class="ttdeci">void spiralPrint(int **a, int r, int c)</div><div class="ttdef"><b>Definition:</b> spiral_print.cpp:29</div></div>
<div class="ttc" id="aspiral__print_8cpp_html_acfff36db81326fb990a643ab198ee8a5"><div class="ttname"><a href="../../db/d07/spiral__print_8cpp.html#acfff36db81326fb990a643ab198ee8a5">genArray</a></div><div class="ttdeci">void genArray(int **a, int r, int c)</div><div class="ttdef"><b>Definition:</b> spiral_print.cpp:12</div></div>
@@ -263,44 +263,44 @@ Here is the call graph for this function:</div>
<p >Print the end col</p>
<p >Print the end row</p>
<p >Print the start Col</p>
<div class="fragment"><div class="line"><a id="l00029" name="l00029"></a><span class="lineno"> 29</span> {</div>
<div class="line"><a id="l00030" name="l00030"></a><span class="lineno"> 30</span> <span class="keywordtype">int</span> startRow = 0, endRow = r - 1;</div>
<div class="line"><a id="l00031" name="l00031"></a><span class="lineno"> 31</span> <span class="keywordtype">int</span> startCol = 0, endCol = c - 1;</div>
<div class="line"><a id="l00032" name="l00032"></a><span class="lineno"> 32</span> <span class="keywordtype">int</span> cnt = 0;</div>
<div class="line"><a id="l00033" name="l00033"></a><span class="lineno"> 33</span> </div>
<div class="line"><a id="l00034" name="l00034"></a><span class="lineno"> 34</span> <span class="keywordflow">while</span> (startRow &lt;= endRow &amp;&amp; startCol &lt;= endCol) {<span class="comment"></span></div>
<div class="line"><a id="l00035" name="l00035"></a><span class="lineno"> 35</span><span class="comment"> /// Print start row</span></div>
<div class="line"><a id="l00036" name="l00036"></a><span class="lineno"> 36</span><span class="comment"></span> <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = startCol; i &lt;= endCol; i++, cnt++) {</div>
<div class="line"><a id="l00037" name="l00037"></a><span class="lineno"> 37</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/basic_ostream.html">std::cout</a> &lt;&lt; a[startRow][i] &lt;&lt; <span class="stringliteral">&quot; &quot;</span>;</div>
<div class="line"><a id="l00038" name="l00038"></a><span class="lineno"> 38</span> }</div>
<div class="line"><a id="l00039" name="l00039"></a><span class="lineno"> 39</span> startRow++;</div>
<div class="line"><a id="l00040" name="l00040"></a><span class="lineno"> 40</span><span class="comment"></span> </div>
<div class="line"><a id="l00041" name="l00041"></a><span class="lineno"> 41</span><span class="comment"> /// Print the end col</span></div>
<div class="line"><a id="l00042" name="l00042"></a><span class="lineno"> 42</span><span class="comment"></span> <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = startRow; i &lt;= endRow; i++, cnt++) {</div>
<div class="line"><a id="l00043" name="l00043"></a><span class="lineno"> 43</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/basic_ostream.html">std::cout</a> &lt;&lt; a[i][endCol] &lt;&lt; <span class="stringliteral">&quot; &quot;</span>;</div>
<div class="line"><a id="l00044" name="l00044"></a><span class="lineno"> 44</span> }</div>
<div class="line"><a id="l00045" name="l00045"></a><span class="lineno"> 45</span> endCol--;</div>
<div class="line"><a id="l00046" name="l00046"></a><span class="lineno"> 46</span><span class="comment"></span> </div>
<div class="line"><a id="l00047" name="l00047"></a><span class="lineno"> 47</span><span class="comment"> /// Print the end row</span></div>
<div class="line"><a id="l00048" name="l00048"></a><span class="lineno"> 48</span><span class="comment"></span> <span class="keywordflow">if</span> (cnt == r * c) {</div>
<div class="line"><a id="l00049" name="l00049"></a><span class="lineno"> 49</span> <span class="keywordflow">break</span>;</div>
<div class="line"><a id="l00050" name="l00050"></a><span class="lineno"> 50</span> }</div>
<div class="line"><a id="l00051" name="l00051"></a><span class="lineno"> 51</span> </div>
<div class="line"><a id="l00052" name="l00052"></a><span class="lineno"> 52</span> <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = endCol; i &gt;= startCol; i--, cnt++) {</div>
<div class="line"><a id="l00053" name="l00053"></a><span class="lineno"> 53</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/basic_ostream.html">std::cout</a> &lt;&lt; a[endRow][i] &lt;&lt; <span class="stringliteral">&quot; &quot;</span>;</div>
<div class="line"><a id="l00054" name="l00054"></a><span class="lineno"> 54</span> }</div>
<div class="line"><a id="l00055" name="l00055"></a><span class="lineno"> 55</span> endRow--;</div>
<div class="line"><a id="l00056" name="l00056"></a><span class="lineno"> 56</span><span class="comment"></span> </div>
<div class="line"><a id="l00057" name="l00057"></a><span class="lineno"> 57</span><span class="comment"> /// Print the start Col</span></div>
<div class="line"><a id="l00058" name="l00058"></a><span class="lineno"> 58</span><span class="comment"></span> <span class="keywordflow">if</span> (cnt == r * c) {</div>
<div class="line"><a id="l00059" name="l00059"></a><span class="lineno"> 59</span> <span class="keywordflow">break</span>;</div>
<div class="line"><a id="l00060" name="l00060"></a><span class="lineno"> 60</span> }</div>
<div class="line"><a id="l00061" name="l00061"></a><span class="lineno"> 61</span> <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = endRow; i &gt;= startRow; i--, cnt++) {</div>
<div class="line"><a id="l00062" name="l00062"></a><span class="lineno"> 62</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/basic_ostream.html">std::cout</a> &lt;&lt; a[i][startCol] &lt;&lt; <span class="stringliteral">&quot; &quot;</span>;</div>
<div class="line"><a id="l00063" name="l00063"></a><span class="lineno"> 63</span> }</div>
<div class="line"><a id="l00064" name="l00064"></a><span class="lineno"> 64</span> startCol++;</div>
<div class="line"><a id="l00065" name="l00065"></a><span class="lineno"> 65</span> }</div>
<div class="line"><a id="l00066" name="l00066"></a><span class="lineno"> 66</span>}</div>
<div class="fragment"><div class="line"><span class="lineno"> 29</span> {</div>
<div class="line"><span class="lineno"> 30</span> <span class="keywordtype">int</span> startRow = 0, endRow = r - 1;</div>
<div class="line"><span class="lineno"> 31</span> <span class="keywordtype">int</span> startCol = 0, endCol = c - 1;</div>
<div class="line"><span class="lineno"> 32</span> <span class="keywordtype">int</span> cnt = 0;</div>
<div class="line"><span class="lineno"> 33</span> </div>
<div class="line"><span class="lineno"> 34</span> <span class="keywordflow">while</span> (startRow &lt;= endRow &amp;&amp; startCol &lt;= endCol) {<span class="comment"></span></div>
<div class="line"><span class="lineno"> 35</span><span class="comment"> /// Print start row</span></div>
<div class="line"><span class="lineno"> 36</span><span class="comment"></span> <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = startCol; i &lt;= endCol; i++, cnt++) {</div>
<div class="line"><span class="lineno"> 37</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/basic_ostream.html">std::cout</a> &lt;&lt; a[startRow][i] &lt;&lt; <span class="stringliteral">&quot; &quot;</span>;</div>
<div class="line"><span class="lineno"> 38</span> }</div>
<div class="line"><span class="lineno"> 39</span> startRow++;</div>
<div class="line"><span class="lineno"> 40</span><span class="comment"></span> </div>
<div class="line"><span class="lineno"> 41</span><span class="comment"> /// Print the end col</span></div>
<div class="line"><span class="lineno"> 42</span><span class="comment"></span> <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = startRow; i &lt;= endRow; i++, cnt++) {</div>
<div class="line"><span class="lineno"> 43</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/basic_ostream.html">std::cout</a> &lt;&lt; a[i][endCol] &lt;&lt; <span class="stringliteral">&quot; &quot;</span>;</div>
<div class="line"><span class="lineno"> 44</span> }</div>
<div class="line"><span class="lineno"> 45</span> endCol--;</div>
<div class="line"><span class="lineno"> 46</span><span class="comment"></span> </div>
<div class="line"><span class="lineno"> 47</span><span class="comment"> /// Print the end row</span></div>
<div class="line"><span class="lineno"> 48</span><span class="comment"></span> <span class="keywordflow">if</span> (cnt == r * c) {</div>
<div class="line"><span class="lineno"> 49</span> <span class="keywordflow">break</span>;</div>
<div class="line"><span class="lineno"> 50</span> }</div>
<div class="line"><span class="lineno"> 51</span> </div>
<div class="line"><span class="lineno"> 52</span> <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = endCol; i &gt;= startCol; i--, cnt++) {</div>
<div class="line"><span class="lineno"> 53</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/basic_ostream.html">std::cout</a> &lt;&lt; a[endRow][i] &lt;&lt; <span class="stringliteral">&quot; &quot;</span>;</div>
<div class="line"><span class="lineno"> 54</span> }</div>
<div class="line"><span class="lineno"> 55</span> endRow--;</div>
<div class="line"><span class="lineno"> 56</span><span class="comment"></span> </div>
<div class="line"><span class="lineno"> 57</span><span class="comment"> /// Print the start Col</span></div>
<div class="line"><span class="lineno"> 58</span><span class="comment"></span> <span class="keywordflow">if</span> (cnt == r * c) {</div>
<div class="line"><span class="lineno"> 59</span> <span class="keywordflow">break</span>;</div>
<div class="line"><span class="lineno"> 60</span> }</div>
<div class="line"><span class="lineno"> 61</span> <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = endRow; i &gt;= startRow; i--, cnt++) {</div>
<div class="line"><span class="lineno"> 62</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/basic_ostream.html">std::cout</a> &lt;&lt; a[i][startCol] &lt;&lt; <span class="stringliteral">&quot; &quot;</span>;</div>
<div class="line"><span class="lineno"> 63</span> }</div>
<div class="line"><span class="lineno"> 64</span> startCol++;</div>
<div class="line"><span class="lineno"> 65</span> }</div>
<div class="line"><span class="lineno"> 66</span>}</div>
</div><!-- fragment -->
</div>
</div>
@@ -310,7 +310,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_9510827d0b234b3cc54b29892f217477.html">others</a></li><li class="navelem"><a class="el" href="../../db/d07/spiral__print_8cpp.html">spiral_print.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>

View File

@@ -1,4 +1,4 @@
<map id="genArray" name="genArray">
<area shape="rect" id="node1" title=" " alt="" coords="5,5,80,32"/>
<area shape="rect" id="node2" href="/Users/runner/work/C-Plus-Plus/C-Plus-Plus/doc/cppreference-doxygen-web.tag.xml$cpp/io/manip/endl.html#" title=" " alt="" coords="128,5,200,32"/>
<area shape="rect" id="node2" href="/Users/runner/work/C-Plus-Plus/C-Plus-Plus/doc/cppreference-doxygen-web.tag.xml$cpp/io/manip/endl#" title=" " alt="" coords="128,5,200,32"/>
</map>

View File

@@ -1 +1 @@
4c4a1e52f8abb35ec422ef0fc7292ae6
f40f4615f020de42cb2cb366dfb04046

View File

@@ -21,7 +21,7 @@
<!-- Node2 -->
<g id="node2" class="node">
<title>Node2</title>
<g id="a_node2"><a target="_blank" xlink:href="http://en.cppreference.com/w/cpp/io/manip/endl.html#" xlink:title=" ">
<g id="a_node2"><a target="_blank" xlink:href="http://en.cppreference.com/w/cpp/io/manip/endl#" xlink:title=" ">
<polygon fill="white" stroke="black" points="92,-0.5 92,-19.5 146,-19.5 146,-0.5 92,-0.5"/>
<text text-anchor="middle" x="119" y="-7.5" font-family="Helvetica,sans-Serif" font-size="10.00">std::endl</text>
</a>

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 1.6 KiB

View File

@@ -2,5 +2,5 @@
<area shape="rect" id="node1" title=" " alt="" coords="5,31,56,57"/>
<area shape="rect" id="node2" href="$db/d07/spiral__print_8cpp.html#acfff36db81326fb990a643ab198ee8a5" title=" " alt="" coords="107,5,181,32"/>
<area shape="rect" id="node4" href="$db/d07/spiral__print_8cpp.html#a850d3f55e1a8d227176cdcc67352c197" title=" " alt="" coords="104,56,184,83"/>
<area shape="rect" id="node3" href="/Users/runner/work/C-Plus-Plus/C-Plus-Plus/doc/cppreference-doxygen-web.tag.xml$cpp/io/manip/endl.html#" title=" " alt="" coords="232,5,304,32"/>
<area shape="rect" id="node3" href="/Users/runner/work/C-Plus-Plus/C-Plus-Plus/doc/cppreference-doxygen-web.tag.xml$cpp/io/manip/endl#" title=" " alt="" coords="232,5,304,32"/>
</map>

View File

@@ -1 +1 @@
36ec04789746ca0a3235734c24c3c502
e9193fde5fdb4b02b2506941142380ed

View File

@@ -51,7 +51,7 @@
<!-- Node3 -->
<g id="node3" class="node">
<title>Node3</title>
<g id="a_node3"><a target="_blank" xlink:href="http://en.cppreference.com/w/cpp/io/manip/endl.html#" xlink:title=" ">
<g id="a_node3"><a target="_blank" xlink:href="http://en.cppreference.com/w/cpp/io/manip/endl#" xlink:title=" ">
<polygon fill="white" stroke="black" points="170,-38.5 170,-57.5 224,-57.5 224,-38.5 170,-38.5"/>
<text text-anchor="middle" x="197" y="-45.5" font-family="Helvetica,sans-Serif" font-size="10.00">std::endl</text>
</a>

Before

Width:  |  Height:  |  Size: 3.0 KiB

After

Width:  |  Height:  |  Size: 3.0 KiB

View File

@@ -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++: math/prime_factorization.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">&#160;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&amp;dn=expat.txt MIT */
var searchBox = new SearchBox("searchBox", "../../search",'Search','.html');
@@ -147,23 +147,23 @@ Variables</h2></td></tr>
</table>
</div><div class="memdoc">
<p >Main program </p>
<div class="fragment"><div class="line"><a id="l00062" name="l00062"></a><span class="lineno"> 62</span> {</div>
<div class="line"><a id="l00063" name="l00063"></a><span class="lineno"> 63</span> <span class="keywordtype">int</span> num;</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/io/basic_ostream.html">std::cout</a> &lt;&lt; <span class="stringliteral">&quot;\t\tComputes the prime factorization\n\n&quot;</span>;</div>
<div class="line"><a id="l00065" name="l00065"></a><span class="lineno"> 65</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;Type in a number: &quot;</span>;</div>
<div class="line"><a id="l00066" name="l00066"></a><span class="lineno"> 66</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/basic_istream.html">std::cin</a> &gt;&gt; num;</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> <a class="code hl_function" href="../../db/d0d/prime__factorization_8cpp.html#affe577b9bce8f604f5e2f861c63c7099">SieveOfEratosthenes</a>(num);</div>
<div class="line"><a id="l00069" name="l00069"></a><span class="lineno"> 69</span> </div>
<div class="line"><a id="l00070" name="l00070"></a><span class="lineno"> 70</span> <a class="code hl_function" href="../../db/d0d/prime__factorization_8cpp.html#a0ece0145fb29a5cf48378c23dde2da46">prime_factorization</a>(num);</div>
<div class="line"><a id="l00071" name="l00071"></a><span class="lineno"> 71</span> </div>
<div class="line"><a id="l00072" name="l00072"></a><span class="lineno"> 72</span> <span class="comment">// Prime factors with their powers in the given number in new line</span></div>
<div class="line"><a id="l00073" name="l00073"></a><span class="lineno"> 73</span> <span class="keywordflow">for</span> (<span class="keyword">auto</span> it : <a class="code hl_variable" href="../../db/d0d/prime__factorization_8cpp.html#acfb0df439a4beae5a34ef131ce737c1b">factors</a>) {</div>
<div class="line"><a id="l00074" name="l00074"></a><span class="lineno"> 74</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/basic_ostream.html">std::cout</a> &lt;&lt; it.first &lt;&lt; <span class="stringliteral">&quot; &quot;</span> &lt;&lt; it.second &lt;&lt; <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="l00075" name="l00075"></a><span class="lineno"> 75</span> }</div>
<div class="line"><a id="l00076" name="l00076"></a><span class="lineno"> 76</span> </div>
<div class="line"><a id="l00077" name="l00077"></a><span class="lineno"> 77</span> <span class="keywordflow">return</span> 0;</div>
<div class="line"><a id="l00078" name="l00078"></a><span class="lineno"> 78</span>}</div>
<div class="fragment"><div class="line"><span class="lineno"> 62</span> {</div>
<div class="line"><span class="lineno"> 63</span> <span class="keywordtype">int</span> num;</div>
<div class="line"><span class="lineno"> 64</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;\t\tComputes the prime factorization\n\n&quot;</span>;</div>
<div class="line"><span class="lineno"> 65</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;Type in a number: &quot;</span>;</div>
<div class="line"><span class="lineno"> 66</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/basic_istream.html">std::cin</a> &gt;&gt; num;</div>
<div class="line"><span class="lineno"> 67</span> </div>
<div class="line"><span class="lineno"> 68</span> <a class="code hl_function" href="../../db/d0d/prime__factorization_8cpp.html#affe577b9bce8f604f5e2f861c63c7099">SieveOfEratosthenes</a>(num);</div>
<div class="line"><span class="lineno"> 69</span> </div>
<div class="line"><span class="lineno"> 70</span> <a class="code hl_function" href="../../db/d0d/prime__factorization_8cpp.html#a0ece0145fb29a5cf48378c23dde2da46">prime_factorization</a>(num);</div>
<div class="line"><span class="lineno"> 71</span> </div>
<div class="line"><span class="lineno"> 72</span> <span class="comment">// Prime factors with their powers in the given number in new line</span></div>
<div class="line"><span class="lineno"> 73</span> <span class="keywordflow">for</span> (<span class="keyword">auto</span> it : <a class="code hl_variable" href="../../db/d0d/prime__factorization_8cpp.html#acfb0df439a4beae5a34ef131ce737c1b">factors</a>) {</div>
<div class="line"><span class="lineno"> 74</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/basic_ostream.html">std::cout</a> &lt;&lt; it.first &lt;&lt; <span class="stringliteral">&quot; &quot;</span> &lt;&lt; it.second &lt;&lt; <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"> 75</span> }</div>
<div class="line"><span class="lineno"> 76</span> </div>
<div class="line"><span class="lineno"> 77</span> <span class="keywordflow">return</span> 0;</div>
<div class="line"><span class="lineno"> 78</span>}</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="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>
@@ -173,7 +173,7 @@ Variables</h2></td></tr>
</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/d0d/prime__factorization_8cpp_ae66f6b31b5ad750f1fe042a706a4e3d4_cgraph.svg" width="412" height="139"><p><b>This browser is not able to show SVG: try Firefox, Chrome, Safari, or Opera instead.</b></p></iframe>
<div class="center"><iframe scrolling="no" frameborder="0" src="../../db/d0d/prime__factorization_8cpp_ae66f6b31b5ad750f1fe042a706a4e3d4_cgraph.svg" width="459" height="139"><p><b>This browser is not able to show SVG: try Firefox, Chrome, Safari, or Opera instead.</b></p></iframe>
</div>
</div>
@@ -195,26 +195,26 @@ Here is the call graph for this function:</div>
</table>
</div><div class="memdoc">
<p >Prime factorization of a number </p>
<div class="fragment"><div class="line"><a id="l00040" name="l00040"></a><span class="lineno"> 40</span> {</div>
<div class="line"><a id="l00041" name="l00041"></a><span class="lineno"> 41</span> <span class="keywordtype">int</span> number = num;</div>
<div class="line"><a id="l00042" name="l00042"></a><span class="lineno"> 42</span> </div>
<div class="line"><a id="l00043" name="l00043"></a><span class="lineno"> 43</span> <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; <a class="code hl_variable" href="../../db/d0d/prime__factorization_8cpp.html#af097796783684712b8326e5b82bfd4fe">prime_numbers</a>[i] &lt;= num; i++) {</div>
<div class="line"><a id="l00044" name="l00044"></a><span class="lineno"> 44</span> <span class="keywordtype">int</span> count = 0;</div>
<div class="line"><a id="l00045" name="l00045"></a><span class="lineno"> 45</span> </div>
<div class="line"><a id="l00046" name="l00046"></a><span class="lineno"> 46</span> <span class="comment">// termination condition</span></div>
<div class="line"><a id="l00047" name="l00047"></a><span class="lineno"> 47</span> <span class="keywordflow">if</span> (number == 1) {</div>
<div class="line"><a id="l00048" name="l00048"></a><span class="lineno"> 48</span> <span class="keywordflow">break</span>;</div>
<div class="line"><a id="l00049" name="l00049"></a><span class="lineno"> 49</span> }</div>
<div class="line"><a id="l00050" name="l00050"></a><span class="lineno"> 50</span> </div>
<div class="line"><a id="l00051" name="l00051"></a><span class="lineno"> 51</span> <span class="keywordflow">while</span> (number % <a class="code hl_variable" href="../../db/d0d/prime__factorization_8cpp.html#af097796783684712b8326e5b82bfd4fe">prime_numbers</a>[i] == 0) {</div>
<div class="line"><a id="l00052" name="l00052"></a><span class="lineno"> 52</span> count++;</div>
<div class="line"><a id="l00053" name="l00053"></a><span class="lineno"> 53</span> number = number / <a class="code hl_variable" href="../../db/d0d/prime__factorization_8cpp.html#af097796783684712b8326e5b82bfd4fe">prime_numbers</a>[i];</div>
<div class="line"><a id="l00054" name="l00054"></a><span class="lineno"> 54</span> }</div>
<div class="line"><a id="l00055" name="l00055"></a><span class="lineno"> 55</span> </div>
<div class="line"><a id="l00056" name="l00056"></a><span class="lineno"> 56</span> <span class="keywordflow">if</span> (count)</div>
<div class="line"><a id="l00057" name="l00057"></a><span class="lineno"> 57</span> <a class="code hl_variable" href="../../db/d0d/prime__factorization_8cpp.html#acfb0df439a4beae5a34ef131ce737c1b">factors</a>.push_back(<a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/utility/pair/make_pair.html">std::make_pair</a>(<a class="code hl_variable" href="../../db/d0d/prime__factorization_8cpp.html#af097796783684712b8326e5b82bfd4fe">prime_numbers</a>[i], count));</div>
<div class="line"><a id="l00058" name="l00058"></a><span class="lineno"> 58</span> }</div>
<div class="line"><a id="l00059" name="l00059"></a><span class="lineno"> 59</span>}</div>
<div class="fragment"><div class="line"><span class="lineno"> 40</span> {</div>
<div class="line"><span class="lineno"> 41</span> <span class="keywordtype">int</span> number = num;</div>
<div class="line"><span class="lineno"> 42</span> </div>
<div class="line"><span class="lineno"> 43</span> <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; <a class="code hl_variable" href="../../db/d0d/prime__factorization_8cpp.html#af097796783684712b8326e5b82bfd4fe">prime_numbers</a>[i] &lt;= num; i++) {</div>
<div class="line"><span class="lineno"> 44</span> <span class="keywordtype">int</span> count = 0;</div>
<div class="line"><span class="lineno"> 45</span> </div>
<div class="line"><span class="lineno"> 46</span> <span class="comment">// termination condition</span></div>
<div class="line"><span class="lineno"> 47</span> <span class="keywordflow">if</span> (number == 1) {</div>
<div class="line"><span class="lineno"> 48</span> <span class="keywordflow">break</span>;</div>
<div class="line"><span class="lineno"> 49</span> }</div>
<div class="line"><span class="lineno"> 50</span> </div>
<div class="line"><span class="lineno"> 51</span> <span class="keywordflow">while</span> (number % <a class="code hl_variable" href="../../db/d0d/prime__factorization_8cpp.html#af097796783684712b8326e5b82bfd4fe">prime_numbers</a>[i] == 0) {</div>
<div class="line"><span class="lineno"> 52</span> count++;</div>
<div class="line"><span class="lineno"> 53</span> number = number / <a class="code hl_variable" href="../../db/d0d/prime__factorization_8cpp.html#af097796783684712b8326e5b82bfd4fe">prime_numbers</a>[i];</div>
<div class="line"><span class="lineno"> 54</span> }</div>
<div class="line"><span class="lineno"> 55</span> </div>
<div class="line"><span class="lineno"> 56</span> <span class="keywordflow">if</span> (count)</div>
<div class="line"><span class="lineno"> 57</span> <a class="code hl_variable" href="../../db/d0d/prime__factorization_8cpp.html#acfb0df439a4beae5a34ef131ce737c1b">factors</a>.push_back(<a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/utility/pair/make_pair.html">std::make_pair</a>(<a class="code hl_variable" href="../../db/d0d/prime__factorization_8cpp.html#af097796783684712b8326e5b82bfd4fe">prime_numbers</a>[i], count));</div>
<div class="line"><span class="lineno"> 58</span> }</div>
<div class="line"><span class="lineno"> 59</span>}</div>
<div class="ttc" id="amake_pair_html"><div class="ttname"><a href="http://en.cppreference.com/w/cpp/utility/pair/make_pair.html">std::make_pair</a></div><div class="ttdeci">T make_pair(T... args)</div></div>
<div class="ttc" id="aprime__factorization_8cpp_html_af097796783684712b8326e5b82bfd4fe"><div class="ttname"><a href="../../db/d0d/prime__factorization_8cpp.html#af097796783684712b8326e5b82bfd4fe">prime_numbers</a></div><div class="ttdeci">std::vector&lt; int &gt; prime_numbers</div><div class="ttdef"><b>Definition:</b> prime_factorization.cpp:16</div></div>
</div><!-- fragment --><div class="dynheader">
@@ -242,25 +242,32 @@ Here is the call graph for this function:</div>
</table>
</div><div class="memdoc">
<p >Calculating prime number upto a given range </p>
<div class="fragment"><div class="line"><a id="l00023" name="l00023"></a><span class="lineno"> 23</span> {</div>
<div class="line"><a id="l00024" name="l00024"></a><span class="lineno"> 24</span> <span class="comment">// initializes the array isprime</span></div>
<div class="line"><a id="l00025" name="l00025"></a><span class="lineno"> 25</span> <a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/string/byte/memset.html">memset</a>(<a class="code hl_variable" href="../../db/d0d/prime__factorization_8cpp.html#a7fe38b570a51e448430d6a0f072c2f23">isprime</a>, <span class="keyword">true</span>, <span class="keyword">sizeof</span> <a class="code hl_variable" href="../../db/d0d/prime__factorization_8cpp.html#a7fe38b570a51e448430d6a0f072c2f23">isprime</a>);</div>
<div class="line"><a id="l00026" name="l00026"></a><span class="lineno"> 26</span> </div>
<div class="line"><a id="l00027" name="l00027"></a><span class="lineno"> 27</span> <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 2; i &lt;= <a class="code hl_variable" href="../../d6/d42/data__structures_2sparse__table_8cpp.html#a10f3ffb3f6f7e1b83d556b9c8de89a5d">N</a>; i++) {</div>
<div class="line"><a id="l00028" name="l00028"></a><span class="lineno"> 28</span> <span class="keywordflow">if</span> (<a class="code hl_variable" href="../../db/d0d/prime__factorization_8cpp.html#a7fe38b570a51e448430d6a0f072c2f23">isprime</a>[i]) {</div>
<div class="line"><a id="l00029" name="l00029"></a><span class="lineno"> 29</span> <span class="keywordflow">for</span> (<span class="keywordtype">int</span> j = 2 * i; j &lt;= <a class="code hl_variable" href="../../d6/d42/data__structures_2sparse__table_8cpp.html#a10f3ffb3f6f7e1b83d556b9c8de89a5d">N</a>; j += i) <a class="code hl_variable" href="../../db/d0d/prime__factorization_8cpp.html#a7fe38b570a51e448430d6a0f072c2f23">isprime</a>[j] = <span class="keyword">false</span>;</div>
<div class="line"><a id="l00030" name="l00030"></a><span class="lineno"> 30</span> }</div>
<div class="line"><a id="l00031" name="l00031"></a><span class="lineno"> 31</span> }</div>
<div class="line"><a id="l00032" name="l00032"></a><span class="lineno"> 32</span> </div>
<div class="line"><a id="l00033" name="l00033"></a><span class="lineno"> 33</span> <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 2; i &lt;= <a class="code hl_variable" href="../../d6/d42/data__structures_2sparse__table_8cpp.html#a10f3ffb3f6f7e1b83d556b9c8de89a5d">N</a>; i++) {</div>
<div class="line"><a id="l00034" name="l00034"></a><span class="lineno"> 34</span> <span class="keywordflow">if</span> (<a class="code hl_variable" href="../../db/d0d/prime__factorization_8cpp.html#a7fe38b570a51e448430d6a0f072c2f23">isprime</a>[i])</div>
<div class="line"><a id="l00035" name="l00035"></a><span class="lineno"> 35</span> <a class="code hl_variable" href="../../db/d0d/prime__factorization_8cpp.html#af097796783684712b8326e5b82bfd4fe">prime_numbers</a>.push_back(i);</div>
<div class="line"><a id="l00036" name="l00036"></a><span class="lineno"> 36</span> }</div>
<div class="line"><a id="l00037" name="l00037"></a><span class="lineno"> 37</span>}</div>
<div class="fragment"><div class="line"><span class="lineno"> 23</span> {</div>
<div class="line"><span class="lineno"> 24</span> <span class="comment">// initializes the array isprime</span></div>
<div class="line"><span class="lineno"> 25</span> <a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/string/byte/memset.html">memset</a>(<a class="code hl_variable" href="../../db/d0d/prime__factorization_8cpp.html#a7fe38b570a51e448430d6a0f072c2f23">isprime</a>, <span class="keyword">true</span>, <span class="keyword">sizeof</span> <a class="code hl_variable" href="../../db/d0d/prime__factorization_8cpp.html#a7fe38b570a51e448430d6a0f072c2f23">isprime</a>);</div>
<div class="line"><span class="lineno"> 26</span> </div>
<div class="line"><span class="lineno"> 27</span> <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 2; i &lt;= <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"> 28</span> <span class="keywordflow">if</span> (<a class="code hl_variable" href="../../db/d0d/prime__factorization_8cpp.html#a7fe38b570a51e448430d6a0f072c2f23">isprime</a>[i]) {</div>
<div class="line"><span class="lineno"> 29</span> <span class="keywordflow">for</span> (<span class="keywordtype">int</span> j = 2 * i; j &lt;= <a class="code hl_variable" href="../../d6/d42/data__structures_2sparse__table_8cpp.html#a10f3ffb3f6f7e1b83d556b9c8de89a5d">N</a>; j += i) <a class="code hl_variable" href="../../db/d0d/prime__factorization_8cpp.html#a7fe38b570a51e448430d6a0f072c2f23">isprime</a>[j] = <span class="keyword">false</span>;</div>
<div class="line"><span class="lineno"> 30</span> }</div>
<div class="line"><span class="lineno"> 31</span> }</div>
<div class="line"><span class="lineno"> 32</span> </div>
<div class="line"><span class="lineno"> 33</span> <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 2; i &lt;= <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"> 34</span> <span class="keywordflow">if</span> (<a class="code hl_variable" href="../../db/d0d/prime__factorization_8cpp.html#a7fe38b570a51e448430d6a0f072c2f23">isprime</a>[i])</div>
<div class="line"><span class="lineno"> 35</span> <a class="code hl_variable" href="../../db/d0d/prime__factorization_8cpp.html#af097796783684712b8326e5b82bfd4fe">prime_numbers</a>.<a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector/push_back.html">push_back</a>(i);</div>
<div class="line"><span class="lineno"> 36</span> }</div>
<div class="line"><span class="lineno"> 37</span>}</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:47</div></div>
<div class="ttc" id="amemset_html"><div class="ttname"><a href="http://en.cppreference.com/w/cpp/string/byte/memset.html">std::memset</a></div><div class="ttdeci">T memset(T... args)</div></div>
<div class="ttc" id="aprime__factorization_8cpp_html_a7fe38b570a51e448430d6a0f072c2f23"><div class="ttname"><a href="../../db/d0d/prime__factorization_8cpp.html#a7fe38b570a51e448430d6a0f072c2f23">isprime</a></div><div class="ttdeci">bool isprime[1000006]</div><div class="ttdef"><b>Definition:</b> prime_factorization.cpp:13</div></div>
</div><!-- fragment -->
<div class="ttc" id="apush_back_html"><div class="ttname"><a href="http://en.cppreference.com/w/cpp/container/vector/push_back.html">std::vector::push_back</a></div><div class="ttdeci">T push_back(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/d0d/prime__factorization_8cpp_affe577b9bce8f604f5e2f861c63c7099_cgraph.svg" width="360" height="38"><p><b>This browser is not able to show SVG: try Firefox, Chrome, Safari, or Opera instead.</b></p></iframe>
</div>
</div>
</div>
</div>
<h2 class="groupheader">Variable Documentation</h2>
@@ -315,7 +322,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_296d53ceaeaa7e099814a6def439fe8a.html">math</a></li><li class="navelem"><a class="el" href="../../db/d0d/prime__factorization_8cpp.html">prime_factorization.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>

View File

@@ -1,4 +1,4 @@
<map id="prime_factorization" name="prime_factorization">
<area shape="rect" id="node1" title=" " alt="" coords="5,5,137,32"/>
<area shape="rect" id="node2" href="/Users/runner/work/C-Plus-Plus/C-Plus-Plus/doc/cppreference-doxygen-web.tag.xml$cpp/utility/pair/make_pair.html#" title=" " alt="" coords="185,5,293,32"/>
<area shape="rect" id="node2" href="/Users/runner/work/C-Plus-Plus/C-Plus-Plus/doc/cppreference-doxygen-web.tag.xml$cpp/utility/pair/make_pair#" title=" " alt="" coords="185,5,293,32"/>
</map>

View File

@@ -1 +1 @@
1dc242ba4425c3b9eed6b05a6bd2d250
266b84e1e227d801de90ed64bd31459f

View File

@@ -21,7 +21,7 @@
<!-- Node2 -->
<g id="node2" class="node">
<title>Node2</title>
<g id="a_node2"><a target="_blank" xlink:href="http://en.cppreference.com/w/cpp/utility/pair/make_pair.html#" xlink:title=" ">
<g id="a_node2"><a target="_blank" xlink:href="http://en.cppreference.com/w/cpp/utility/pair/make_pair#" xlink:title=" ">
<polygon fill="white" stroke="black" points="135,-0.5 135,-19.5 216,-19.5 216,-0.5 135,-0.5"/>
<text text-anchor="middle" x="175.5" y="-7.5" font-family="Helvetica,sans-Serif" font-size="10.00">std::make_pair</text>
</a>

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 1.6 KiB

View File

@@ -1,7 +1,8 @@
<map id="main" name="main">
<area shape="rect" id="node1" title=" " alt="" coords="5,56,56,83"/>
<area shape="rect" id="node2" href="/Users/runner/work/C-Plus-Plus/C-Plus-Plus/doc/cppreference-doxygen-web.tag.xml$cpp/io/manip/endl.html#" title=" " alt="" coords="141,5,213,32"/>
<area shape="rect" id="node2" href="/Users/runner/work/C-Plus-Plus/C-Plus-Plus/doc/cppreference-doxygen-web.tag.xml$cpp/io/manip/endl#" title=" " alt="" coords="141,5,213,32"/>
<area shape="rect" id="node3" href="$db/d0d/prime__factorization_8cpp.html#a0ece0145fb29a5cf48378c23dde2da46" title=" " alt="" coords="111,56,243,83"/>
<area shape="rect" id="node5" href="$db/d0d/prime__factorization_8cpp.html#affe577b9bce8f604f5e2f861c63c7099" title=" " alt="" coords="104,107,251,133"/>
<area shape="rect" id="node4" href="/Users/runner/work/C-Plus-Plus/C-Plus-Plus/doc/cppreference-doxygen-web.tag.xml$cpp/utility/pair/make_pair.html#" title=" " alt="" coords="299,56,407,83"/>
<area shape="rect" id="node4" href="/Users/runner/work/C-Plus-Plus/C-Plus-Plus/doc/cppreference-doxygen-web.tag.xml$cpp/utility/pair/make_pair#" title=" " alt="" coords="322,56,430,83"/>
<area shape="rect" id="node6" href="/Users/runner/work/C-Plus-Plus/C-Plus-Plus/doc/cppreference-doxygen-web.tag.xml$cpp/container/vector/push_back#" title=" " alt="" coords="299,107,453,133"/>
</map>

View File

@@ -1 +1 @@
fb4a1335f4a079fc891c9879634dad1d
21b168ef8b6d2afcea8b62ff4be77516

View File

@@ -4,11 +4,11 @@
<!-- Generated by graphviz version 2.50.0 (20211204.2007)
-->
<!-- Title: main Pages: 1 -->
<svg width="309pt" height="104pt"
viewBox="0.00 0.00 309.00 104.00" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<svg width="344pt" height="104pt"
viewBox="0.00 0.00 344.00 104.00" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<g id="graph0" class="graph" transform="scale(1 1) rotate(0) translate(4 100)">
<title>main</title>
<polygon fill="white" stroke="transparent" points="-4,4 -4,-100 305,-100 305,4 -4,4"/>
<polygon fill="white" stroke="transparent" points="-4,4 -4,-100 340,-100 340,4 -4,4"/>
<!-- Node1 -->
<g id="node1" class="node">
<title>Node1</title>
@@ -21,7 +21,7 @@
<!-- Node2 -->
<g id="node2" class="node">
<title>Node2</title>
<g id="a_node2"><a target="_blank" xlink:href="http://en.cppreference.com/w/cpp/io/manip/endl.html#" xlink:title=" ">
<g id="a_node2"><a target="_blank" xlink:href="http://en.cppreference.com/w/cpp/io/manip/endl#" xlink:title=" ">
<polygon fill="white" stroke="black" points="102,-76.5 102,-95.5 156,-95.5 156,-76.5 102,-76.5"/>
<text text-anchor="middle" x="129" y="-83.5" font-family="Helvetica,sans-Serif" font-size="10.00">std::endl</text>
</a>
@@ -66,17 +66,32 @@
<!-- Node4 -->
<g id="node4" class="node">
<title>Node4</title>
<g id="a_node4"><a target="_blank" xlink:href="http://en.cppreference.com/w/cpp/utility/pair/make_pair.html#" xlink:title=" ">
<polygon fill="white" stroke="black" points="220,-38.5 220,-57.5 301,-57.5 301,-38.5 220,-38.5"/>
<text text-anchor="middle" x="260.5" y="-45.5" font-family="Helvetica,sans-Serif" font-size="10.00">std::make_pair</text>
<g id="a_node4"><a target="_blank" xlink:href="http://en.cppreference.com/w/cpp/utility/pair/make_pair#" xlink:title=" ">
<polygon fill="white" stroke="black" points="237.5,-38.5 237.5,-57.5 318.5,-57.5 318.5,-38.5 237.5,-38.5"/>
<text text-anchor="middle" x="278" y="-45.5" font-family="Helvetica,sans-Serif" font-size="10.00">std::make_pair</text>
</a>
</g>
</g>
<!-- Node3&#45;&gt;Node4 -->
<g id="edge3" class="edge">
<title>Node3&#45;&gt;Node4</title>
<path fill="none" stroke="midnightblue" d="M178.59,-48C188.82,-48 199.62,-48 209.88,-48"/>
<polygon fill="midnightblue" stroke="midnightblue" points="209.93,-51.5 219.93,-48 209.93,-44.5 209.93,-51.5"/>
<path fill="none" stroke="midnightblue" d="M178.54,-48C194.18,-48 211.53,-48 227.26,-48"/>
<polygon fill="midnightblue" stroke="midnightblue" points="227.33,-51.5 237.33,-48 227.33,-44.5 227.33,-51.5"/>
</g>
<!-- Node6 -->
<g id="node6" class="node">
<title>Node6</title>
<g id="a_node6"><a target="_blank" xlink:href="http://en.cppreference.com/w/cpp/container/vector/push_back#" xlink:title=" ">
<polygon fill="white" stroke="black" points="220,-0.5 220,-19.5 336,-19.5 336,-0.5 220,-0.5"/>
<text text-anchor="middle" x="278" y="-7.5" font-family="Helvetica,sans-Serif" font-size="10.00">std::vector::push_back</text>
</a>
</g>
</g>
<!-- Node5&#45;&gt;Node6 -->
<g id="edge5" class="edge">
<title>Node5&#45;&gt;Node6</title>
<path fill="none" stroke="midnightblue" d="M184.32,-10C192.58,-10 201.18,-10 209.67,-10"/>
<polygon fill="midnightblue" stroke="midnightblue" points="209.95,-13.5 219.95,-10 209.95,-6.5 209.95,-13.5"/>
</g>
</g>
</svg>

Before

Width:  |  Height:  |  Size: 3.8 KiB

After

Width:  |  Height:  |  Size: 4.5 KiB

View File

@@ -0,0 +1,4 @@
<map id="SieveOfEratosthenes" name="SieveOfEratosthenes">
<area shape="rect" id="node1" title=" " alt="" coords="5,5,152,32"/>
<area shape="rect" id="node2" href="/Users/runner/work/C-Plus-Plus/C-Plus-Plus/doc/cppreference-doxygen-web.tag.xml$cpp/container/vector/push_back#" title=" " alt="" coords="200,5,355,32"/>
</map>

View File

@@ -0,0 +1 @@
2505b1407ad0d18e846641ec03832fbc

View File

@@ -0,0 +1,37 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<!-- Generated by graphviz version 2.50.0 (20211204.2007)
-->
<!-- Title: SieveOfEratosthenes Pages: 1 -->
<svg width="270pt" height="28pt"
viewBox="0.00 0.00 270.00 28.00" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<g id="graph0" class="graph" transform="scale(1 1) rotate(0) translate(4 24)">
<title>SieveOfEratosthenes</title>
<polygon fill="white" stroke="transparent" points="-4,4 -4,-24 266,-24 266,4 -4,4"/>
<!-- Node1 -->
<g id="node1" class="node">
<title>Node1</title>
<g id="a_node1"><a xlink:title=" ">
<polygon fill="#bfbfbf" stroke="black" points="0,-0.5 0,-19.5 110,-19.5 110,-0.5 0,-0.5"/>
<text text-anchor="middle" x="55" y="-7.5" font-family="Helvetica,sans-Serif" font-size="10.00">SieveOfEratosthenes</text>
</a>
</g>
</g>
<!-- Node2 -->
<g id="node2" class="node">
<title>Node2</title>
<g id="a_node2"><a target="_blank" xlink:href="http://en.cppreference.com/w/cpp/container/vector/push_back#" xlink:title=" ">
<polygon fill="white" stroke="black" points="146,-0.5 146,-19.5 262,-19.5 262,-0.5 146,-0.5"/>
<text text-anchor="middle" x="204" y="-7.5" font-family="Helvetica,sans-Serif" font-size="10.00">std::vector::push_back</text>
</a>
</g>
</g>
<!-- Node1&#45;&gt;Node2 -->
<g id="edge1" class="edge">
<title>Node1&#45;&gt;Node2</title>
<path fill="none" stroke="midnightblue" d="M110.32,-10C118.58,-10 127.18,-10 135.67,-10"/>
<polygon fill="midnightblue" stroke="midnightblue" points="135.95,-13.5 145.95,-10 135.95,-6.5 135.95,-13.5"/>
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 1.6 KiB

View File

@@ -0,0 +1,5 @@
<map id="data_structures::queue_using_array::Queue_Array" name="data_structures::queue_using_array::Queue_Array">
<area shape="rect" id="node1" title="Queue_Array class containing the main data and also index of head and tail of the array." alt="" coords="5,199,185,240"/>
<area shape="rect" id="node2" href="/Users/runner/work/C-Plus-Plus/C-Plus-Plus/doc/cppreference-doxygen-web.tag.xml$cpp/container/array" title=" " alt="" coords="29,95,161,136"/>
<area shape="rect" id="node3" href="/Users/runner/work/C-Plus-Plus/C-Plus-Plus/doc/cppreference-doxygen-web.tag.xml$cpp/types/integer" title=" " alt="" coords="52,5,139,32"/>
</map>

View File

@@ -0,0 +1 @@
51f579edf748b8afcdc55ab169f1f91c

View File

@@ -0,0 +1,56 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<!-- Generated by graphviz version 2.50.0 (20211204.2007)
-->
<!-- Title: data_structures::queue_using_array::Queue_Array Pages: 1 -->
<svg width="143pt" height="184pt"
viewBox="0.00 0.00 143.00 184.00" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<g id="graph0" class="graph" transform="scale(1 1) rotate(0) translate(4 180)">
<title>data_structures::queue_using_array::Queue_Array</title>
<polygon fill="white" stroke="transparent" points="-4,4 -4,-180 139,-180 139,4 -4,4"/>
<!-- Node1 -->
<g id="node1" class="node">
<title>Node1</title>
<g id="a_node1"><a xlink:title="Queue_Array class containing the main data and also index of head and tail of the array.">
<polygon fill="#bfbfbf" stroke="black" points="0,-0.5 0,-30.5 135,-30.5 135,-0.5 0,-0.5"/>
<text text-anchor="start" x="8" y="-18.5" font-family="Helvetica,sans-Serif" font-size="10.00">data_structures::queue</text>
<text text-anchor="middle" x="67.5" y="-7.5" font-family="Helvetica,sans-Serif" font-size="10.00">_using_array::Queue_Array</text>
</a>
</g>
</g>
<!-- Node2 -->
<g id="node2" class="node">
<title>Node2</title>
<g id="a_node2"><a target="_blank" xlink:href="http://en.cppreference.com/w/cpp/container/array" xlink:title=" ">
<polygon fill="white" stroke="black" points="18,-78.5 18,-108.5 117,-108.5 117,-78.5 18,-78.5"/>
<text text-anchor="start" x="26" y="-96.5" font-family="Helvetica,sans-Serif" font-size="10.00">std::array&lt; int16_t,</text>
<text text-anchor="middle" x="67.5" y="-85.5" font-family="Helvetica,sans-Serif" font-size="10.00"> max_size &gt;</text>
</a>
</g>
</g>
<!-- Node2&#45;&gt;Node1 -->
<g id="edge1" class="edge">
<title>Node2&#45;&gt;Node1</title>
<path fill="none" stroke="#9a32cd" stroke-dasharray="5,2" d="M67.5,-68.09C67.5,-55.76 67.5,-41.22 67.5,-30.73"/>
<polygon fill="#9a32cd" stroke="#9a32cd" points="64,-68.2 67.5,-78.2 71,-68.21 64,-68.2"/>
<text text-anchor="middle" x="75" y="-52" font-family="Helvetica,sans-Serif" font-size="10.00"> arr</text>
</g>
<!-- Node3 -->
<g id="node3" class="node">
<title>Node3</title>
<g id="a_node3"><a target="_blank" xlink:href="http://en.cppreference.com/w/cpp/types/integer" xlink:title=" ">
<polygon fill="white" stroke="#bfbfbf" points="35,-156.5 35,-175.5 100,-175.5 100,-156.5 35,-156.5"/>
<text text-anchor="middle" x="67.5" y="-163.5" font-family="Helvetica,sans-Serif" font-size="10.00">std::int16_t</text>
</a>
</g>
</g>
<!-- Node3&#45;&gt;Node2 -->
<g id="edge2" class="edge">
<title>Node3&#45;&gt;Node2</title>
<path fill="none" stroke="#9a32cd" stroke-dasharray="5,2" d="M67.5,-146.24C67.5,-134.41 67.5,-119.38 67.5,-108.58"/>
<polygon fill="#9a32cd" stroke="#9a32cd" points="64,-146.36 67.5,-156.36 71,-146.36 64,-146.36"/>
<text text-anchor="middle" x="89" y="-130" font-family="Helvetica,sans-Serif" font-size="10.00"> elements</text>
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 2.9 KiB

View File

@@ -0,0 +1,5 @@
<map id="dsu" name="dsu">
<area shape="rect" id="node1" title="Disjoint sets union data structure, class based representation." alt="" coords="61,243,104,269"/>
<area shape="rect" id="node2" href="/Users/runner/work/C-Plus-Plus/C-Plus-Plus/doc/cppreference-doxygen-web.tag.xml$cpp/container/vector" title=" " alt="" coords="5,95,160,121"/>
<area shape="rect" id="node3" href="/Users/runner/work/C-Plus-Plus/C-Plus-Plus/doc/cppreference-doxygen-web.tag.xml$cpp/types/integer" title=" " alt="" coords="35,5,130,32"/>
</map>

View File

@@ -0,0 +1 @@
82d7aaebf57e6e6505c21d9f55329fd8

View File

@@ -0,0 +1,58 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<!-- Generated by graphviz version 2.50.0 (20211204.2007)
-->
<!-- Title: dsu Pages: 1 -->
<svg width="124pt" height="206pt"
viewBox="0.00 0.00 124.00 206.00" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<g id="graph0" class="graph" transform="scale(1 1) rotate(0) translate(4 202)">
<title>dsu</title>
<polygon fill="white" stroke="transparent" points="-4,4 -4,-202 120,-202 120,4 -4,4"/>
<!-- Node1 -->
<g id="node1" class="node">
<title>Node1</title>
<g id="a_node1"><a xlink:title="Disjoint sets union data structure, class based representation.">
<polygon fill="#bfbfbf" stroke="black" points="42,-0.5 42,-19.5 74,-19.5 74,-0.5 42,-0.5"/>
<text text-anchor="middle" x="58" y="-7.5" font-family="Helvetica,sans-Serif" font-size="10.00">dsu</text>
</a>
</g>
</g>
<!-- Node2 -->
<g id="node2" class="node">
<title>Node2</title>
<g id="a_node2"><a target="_blank" xlink:href="http://en.cppreference.com/w/cpp/container/vector" xlink:title=" ">
<polygon fill="white" stroke="black" points="0,-111.5 0,-130.5 116,-130.5 116,-111.5 0,-111.5"/>
<text text-anchor="middle" x="58" y="-118.5" font-family="Helvetica,sans-Serif" font-size="10.00">std::vector&lt; uint64_t &gt;</text>
</a>
</g>
</g>
<!-- Node2&#45;&gt;Node1 -->
<g id="edge1" class="edge">
<title>Node2&#45;&gt;Node1</title>
<path fill="none" stroke="#9a32cd" stroke-dasharray="5,2" d="M58,-101.19C58,-77.28 58,-36.99 58,-19.51"/>
<polygon fill="#9a32cd" stroke="#9a32cd" points="54.5,-101.45 58,-111.45 61.5,-101.45 54.5,-101.45"/>
<text text-anchor="middle" x="85.5" y="-85" font-family="Helvetica,sans-Serif" font-size="10.00"> depth</text>
<text text-anchor="middle" x="85.5" y="-74" font-family="Helvetica,sans-Serif" font-size="10.00">maxElement</text>
<text text-anchor="middle" x="85.5" y="-63" font-family="Helvetica,sans-Serif" font-size="10.00">minElement</text>
<text text-anchor="middle" x="85.5" y="-52" font-family="Helvetica,sans-Serif" font-size="10.00">p</text>
<text text-anchor="middle" x="85.5" y="-41" font-family="Helvetica,sans-Serif" font-size="10.00">setSize</text>
</g>
<!-- Node3 -->
<g id="node3" class="node">
<title>Node3</title>
<g id="a_node3"><a target="_blank" xlink:href="http://en.cppreference.com/w/cpp/types/integer" xlink:title=" ">
<polygon fill="white" stroke="#bfbfbf" points="22.5,-178.5 22.5,-197.5 93.5,-197.5 93.5,-178.5 22.5,-178.5"/>
<text text-anchor="middle" x="58" y="-185.5" font-family="Helvetica,sans-Serif" font-size="10.00">std::uint64_t</text>
</a>
</g>
</g>
<!-- Node3&#45;&gt;Node2 -->
<g id="edge2" class="edge">
<title>Node3&#45;&gt;Node2</title>
<path fill="none" stroke="#9a32cd" stroke-dasharray="5,2" d="M58,-168.04C58,-155.67 58,-140.12 58,-130.63"/>
<polygon fill="#9a32cd" stroke="#9a32cd" points="54.5,-168.23 58,-178.23 61.5,-168.23 54.5,-168.23"/>
<text text-anchor="middle" x="79.5" y="-152" font-family="Helvetica,sans-Serif" font-size="10.00"> elements</text>
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 3.0 KiB

View File

@@ -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++: dynamic_programming/0_1_knapsack.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">&#160;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&amp;dn=expat.txt MIT */
var searchBox = new SearchBox("searchBox", "../../search",'Search','.html');
@@ -97,7 +97,7 @@ $(document).ready(function(){initNavTree('db/d16/0__1__knapsack_8cpp.html','../.
</div><!--header-->
<div class="contents">
<p>Implementation of <a href="https://en.wikipedia.org/wiki/Knapsack_problem" target="_blank">0-1 Knapsack Problem</a>
<p>Implementation of [0-1 <a class="el" href="../../d7/daf/namespace_knapsack.html" title="Implementation of 0-1 Knapsack problem.">Knapsack</a> Problem] (<a href="https://en.wikipedia.org/wiki/Knapsack_problem">https://en.wikipedia.org/wiki/Knapsack_problem</a>)
<a href="#details">More...</a></p>
<div class="textblock"><code>#include &lt;array&gt;</code><br />
<code>#include &lt;cassert&gt;</code><br />
@@ -133,7 +133,7 @@ Functions</h2></td></tr>
<tr class="separator:ae66f6b31b5ad750f1fe042a706a4e3d4"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<div class="textblock"><p >Implementation of <a href="https://en.wikipedia.org/wiki/Knapsack_problem" target="_blank">0-1 Knapsack Problem</a> </p>
<div class="textblock"><p >Implementation of [0-1 <a class="el" href="../../d7/daf/namespace_knapsack.html" title="Implementation of 0-1 Knapsack problem.">Knapsack</a> Problem] (<a href="https://en.wikipedia.org/wiki/Knapsack_problem">https://en.wikipedia.org/wiki/Knapsack_problem</a>) </p>
<p >Given weights and values of n items, put these items in a knapsack of capacity <code>W</code> to get the maximum total value in the knapsack. In other words, given two integer arrays <code>val[0..n-1]</code> and <code>wt[0..n-1]</code> which represent values and weights associated with n items respectively. Also given an integer W which represents knapsack capacity, find out the maximum value subset of <code>val[]</code> such that sum of the weights of this subset is smaller than or equal to W. You cannot break an item, either pick the complete item or dont pick it (0-1 property)</p>
<h3><a class="anchor" id="autotoc_md66"></a>
Algorithm</h3>
@@ -160,11 +160,11 @@ Algorithm</h3>
<p>Main function. </p>
<dl class="section return"><dt>Returns</dt><dd>0 on exit </dd></dl>
<div class="fragment"><div class="line"><a id="l00126" name="l00126"></a><span class="lineno"> 126</span> {</div>
<div class="line"><a id="l00127" name="l00127"></a><span class="lineno"> 127</span> <span class="comment">// Testing</span></div>
<div class="line"><a id="l00128" name="l00128"></a><span class="lineno"> 128</span> <a class="code hl_function" href="../../db/d16/0__1__knapsack_8cpp.html#aa8dca7b867074164d5f45b0f3851269d">test</a>();</div>
<div class="line"><a id="l00129" name="l00129"></a><span class="lineno"> 129</span> <span class="keywordflow">return</span> 0;</div>
<div class="line"><a id="l00130" name="l00130"></a><span class="lineno"> 130</span>}</div>
<div class="fragment"><div class="line"><span class="lineno"> 126</span> {</div>
<div class="line"><span class="lineno"> 127</span> <span class="comment">// Testing</span></div>
<div class="line"><span class="lineno"> 128</span> <a class="code hl_function" href="../../db/d16/0__1__knapsack_8cpp.html#aa8dca7b867074164d5f45b0f3851269d">test</a>();</div>
<div class="line"><span class="lineno"> 129</span> <span class="keywordflow">return</span> 0;</div>
<div class="line"><span class="lineno"> 130</span>}</div>
<div class="ttc" id="a0__1__knapsack_8cpp_html_aa8dca7b867074164d5f45b0f3851269d"><div class="ttname"><a href="../../db/d16/0__1__knapsack_8cpp.html#aa8dca7b867074164d5f45b0f3851269d">test</a></div><div class="ttdeci">static void test()</div><div class="ttdoc">Function to test above algorithm.</div><div class="ttdef"><b>Definition:</b> 0_1_knapsack.cpp:96</div></div>
</div><!-- fragment --><div class="dynheader">
Here is the call graph for this function:</div>
@@ -225,43 +225,43 @@ template&lt;size_t n&gt; </div>
</dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>maximum value obtainable with given capacity. </dd></dl>
<div class="fragment"><div class="line"><a id="l00052" name="l00052"></a><span class="lineno"> 52</span> {</div>
<div class="line"><a id="l00053" name="l00053"></a><span class="lineno"> 53</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector&lt;std::vector&lt;int&gt;</a> &gt; maxValue(n + 1,</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/vector.html">std::vector&lt;int&gt;</a>(capacity + 1, 0));</div>
<div class="line"><a id="l00055" name="l00055"></a><span class="lineno"> 55</span> <span class="comment">// outer loop will select no of items allowed</span></div>
<div class="line"><a id="l00056" name="l00056"></a><span class="lineno"> 56</span> <span class="comment">// inner loop will select capcity of knapsack bag</span></div>
<div class="line"><a id="l00057" name="l00057"></a><span class="lineno"> 57</span> <span class="keywordtype">int</span> items = <span class="keyword">sizeof</span>(weight) / <span class="keyword">sizeof</span>(weight[0]);</div>
<div class="line"><a id="l00058" name="l00058"></a><span class="lineno"> 58</span> <span class="keywordflow">for</span> (<span class="keywordtype">size_t</span> i = 0; i &lt; items + 1; ++i) {</div>
<div class="line"><a id="l00059" name="l00059"></a><span class="lineno"> 59</span> <span class="keywordflow">for</span> (<span class="keywordtype">size_t</span> j = 0; j &lt; capacity + 1; ++j) {</div>
<div class="line"><a id="l00060" name="l00060"></a><span class="lineno"> 60</span> <span class="keywordflow">if</span> (i == 0 || j == 0) {</div>
<div class="line"><a id="l00061" name="l00061"></a><span class="lineno"> 61</span> <span class="comment">// if no of items is zero or capacity is zero, then maxValue</span></div>
<div class="line"><a id="l00062" name="l00062"></a><span class="lineno"> 62</span> <span class="comment">// will be zero</span></div>
<div class="line"><a id="l00063" name="l00063"></a><span class="lineno"> 63</span> maxValue[i][j] = 0;</div>
<div class="line"><a id="l00064" name="l00064"></a><span class="lineno"> 64</span> } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (weight[i - 1] &lt;= j) {</div>
<div class="line"><a id="l00065" name="l00065"></a><span class="lineno"> 65</span> <span class="comment">// if the ith item&#39;s weight(in actual array it will be at i-1)</span></div>
<div class="line"><a id="l00066" name="l00066"></a><span class="lineno"> 66</span> <span class="comment">// is less than or equal to the allowed weight i.e. j then we</span></div>
<div class="line"><a id="l00067" name="l00067"></a><span class="lineno"> 67</span> <span class="comment">// can pick that item for our knapsack. maxValue will be the</span></div>
<div class="line"><a id="l00068" name="l00068"></a><span class="lineno"> 68</span> <span class="comment">// obtained either by picking the current item or by not picking</span></div>
<div class="line"><a id="l00069" name="l00069"></a><span class="lineno"> 69</span> <span class="comment">// current item</span></div>
<div class="line"><a id="l00070" name="l00070"></a><span class="lineno"> 70</span> </div>
<div class="line"><a id="l00071" name="l00071"></a><span class="lineno"> 71</span> <span class="comment">// picking current item</span></div>
<div class="line"><a id="l00072" name="l00072"></a><span class="lineno"> 72</span> <span class="keywordtype">int</span> profit1 = value[i - 1] + maxValue[i - 1][j - weight[i - 1]];</div>
<div class="line"><a id="l00073" name="l00073"></a><span class="lineno"> 73</span> </div>
<div class="line"><a id="l00074" name="l00074"></a><span class="lineno"> 74</span> <span class="comment">// not picking current item</span></div>
<div class="line"><a id="l00075" name="l00075"></a><span class="lineno"> 75</span> <span class="keywordtype">int</span> profit2 = maxValue[i - 1][j];</div>
<div class="line"><a id="l00076" name="l00076"></a><span class="lineno"> 76</span> </div>
<div class="line"><a id="l00077" name="l00077"></a><span class="lineno"> 77</span> maxValue[i][j] = <a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/algorithm/max.html">std::max</a>(profit1, profit2);</div>
<div class="line"><a id="l00078" name="l00078"></a><span class="lineno"> 78</span> } <span class="keywordflow">else</span> {</div>
<div class="line"><a id="l00079" name="l00079"></a><span class="lineno"> 79</span> <span class="comment">// as weight of current item is greater than allowed weight, so</span></div>
<div class="line"><a id="l00080" name="l00080"></a><span class="lineno"> 80</span> <span class="comment">// maxProfit will be profit obtained by excluding current item.</span></div>
<div class="line"><a id="l00081" name="l00081"></a><span class="lineno"> 81</span> maxValue[i][j] = maxValue[i - 1][j];</div>
<div class="line"><a id="l00082" name="l00082"></a><span class="lineno"> 82</span> }</div>
<div class="line"><a id="l00083" name="l00083"></a><span class="lineno"> 83</span> }</div>
<div class="line"><a id="l00084" name="l00084"></a><span class="lineno"> 84</span> }</div>
<div class="line"><a id="l00085" name="l00085"></a><span class="lineno"> 85</span> </div>
<div class="line"><a id="l00086" name="l00086"></a><span class="lineno"> 86</span> <span class="comment">// returning maximum value</span></div>
<div class="line"><a id="l00087" name="l00087"></a><span class="lineno"> 87</span> <span class="keywordflow">return</span> maxValue[items][capacity];</div>
<div class="line"><a id="l00088" name="l00088"></a><span class="lineno"> 88</span>}</div>
<div class="fragment"><div class="line"><span class="lineno"> 52</span> {</div>
<div class="line"><span class="lineno"> 53</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector&lt;std::vector&lt;int&gt;</a> &gt; maxValue(n + 1,</div>
<div class="line"><span class="lineno"> 54</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector&lt;int&gt;</a>(capacity + 1, 0));</div>
<div class="line"><span class="lineno"> 55</span> <span class="comment">// outer loop will select no of items allowed</span></div>
<div class="line"><span class="lineno"> 56</span> <span class="comment">// inner loop will select capcity of knapsack bag</span></div>
<div class="line"><span class="lineno"> 57</span> <span class="keywordtype">int</span> items = <span class="keyword">sizeof</span>(weight) / <span class="keyword">sizeof</span>(weight[0]);</div>
<div class="line"><span class="lineno"> 58</span> <span class="keywordflow">for</span> (<span class="keywordtype">size_t</span> i = 0; i &lt; items + 1; ++i) {</div>
<div class="line"><span class="lineno"> 59</span> <span class="keywordflow">for</span> (<span class="keywordtype">size_t</span> j = 0; j &lt; capacity + 1; ++j) {</div>
<div class="line"><span class="lineno"> 60</span> <span class="keywordflow">if</span> (i == 0 || j == 0) {</div>
<div class="line"><span class="lineno"> 61</span> <span class="comment">// if no of items is zero or capacity is zero, then maxValue</span></div>
<div class="line"><span class="lineno"> 62</span> <span class="comment">// will be zero</span></div>
<div class="line"><span class="lineno"> 63</span> maxValue[i][j] = 0;</div>
<div class="line"><span class="lineno"> 64</span> } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (weight[i - 1] &lt;= j) {</div>
<div class="line"><span class="lineno"> 65</span> <span class="comment">// if the ith item&#39;s weight(in actual array it will be at i-1)</span></div>
<div class="line"><span class="lineno"> 66</span> <span class="comment">// is less than or equal to the allowed weight i.e. j then we</span></div>
<div class="line"><span class="lineno"> 67</span> <span class="comment">// can pick that item for our knapsack. maxValue will be the</span></div>
<div class="line"><span class="lineno"> 68</span> <span class="comment">// obtained either by picking the current item or by not picking</span></div>
<div class="line"><span class="lineno"> 69</span> <span class="comment">// current item</span></div>
<div class="line"><span class="lineno"> 70</span> </div>
<div class="line"><span class="lineno"> 71</span> <span class="comment">// picking current item</span></div>
<div class="line"><span class="lineno"> 72</span> <span class="keywordtype">int</span> profit1 = value[i - 1] + maxValue[i - 1][j - weight[i - 1]];</div>
<div class="line"><span class="lineno"> 73</span> </div>
<div class="line"><span class="lineno"> 74</span> <span class="comment">// not picking current item</span></div>
<div class="line"><span class="lineno"> 75</span> <span class="keywordtype">int</span> profit2 = maxValue[i - 1][j];</div>
<div class="line"><span class="lineno"> 76</span> </div>
<div class="line"><span class="lineno"> 77</span> maxValue[i][j] = <a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/algorithm/max.html">std::max</a>(profit1, profit2);</div>
<div class="line"><span class="lineno"> 78</span> } <span class="keywordflow">else</span> {</div>
<div class="line"><span class="lineno"> 79</span> <span class="comment">// as weight of current item is greater than allowed weight, so</span></div>
<div class="line"><span class="lineno"> 80</span> <span class="comment">// maxProfit will be profit obtained by excluding current item.</span></div>
<div class="line"><span class="lineno"> 81</span> maxValue[i][j] = maxValue[i - 1][j];</div>
<div class="line"><span class="lineno"> 82</span> }</div>
<div class="line"><span class="lineno"> 83</span> }</div>
<div class="line"><span class="lineno"> 84</span> }</div>
<div class="line"><span class="lineno"> 85</span> </div>
<div class="line"><span class="lineno"> 86</span> <span class="comment">// returning maximum value</span></div>
<div class="line"><span class="lineno"> 87</span> <span class="keywordflow">return</span> maxValue[items][capacity];</div>
<div class="line"><span class="lineno"> 88</span>}</div>
<div class="ttc" id="amax_html"><div class="ttname"><a href="http://en.cppreference.com/w/cpp/algorithm/max.html">std::max</a></div><div class="ttdeci">T max(T... args)</div></div>
<div class="ttc" id="avector_html"><div class="ttname"><a href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector</a></div></div>
</div><!-- fragment --><div class="dynheader">
@@ -298,31 +298,31 @@ Here is the call graph for this function:</div>
<p>Function to test above algorithm. </p>
<dl class="section return"><dt>Returns</dt><dd>void </dd></dl>
<div class="fragment"><div class="line"><a id="l00096" name="l00096"></a><span class="lineno"> 96</span> {</div>
<div class="line"><a id="l00097" name="l00097"></a><span class="lineno"> 97</span> <span class="comment">// Test 1</span></div>
<div class="line"><a id="l00098" name="l00098"></a><span class="lineno"> 98</span> <span class="keyword">const</span> <span class="keywordtype">int</span> n1 = 3; <span class="comment">// number of items</span></div>
<div class="line"><a id="l00099" name="l00099"></a><span class="lineno"> 99</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/array.html">std::array&lt;int, n1&gt;</a> weight1 = {10, 20, 30}; <span class="comment">// weight of each item</span></div>
<div class="line"><a id="l00100" name="l00100"></a><span class="lineno"> 100</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/array.html">std::array&lt;int, n1&gt;</a> value1 = {60, 100, 120}; <span class="comment">// value of each item</span></div>
<div class="line"><a id="l00101" name="l00101"></a><span class="lineno"> 101</span> <span class="keyword">const</span> <span class="keywordtype">int</span> capacity1 = 50; <span class="comment">// capacity of carrying bag</span></div>
<div class="line"><a id="l00102" name="l00102"></a><span class="lineno"> 102</span> <span class="keyword">const</span> <span class="keywordtype">int</span> max_value1 = <a class="code hl_function" href="../../db/d16/0__1__knapsack_8cpp.html#a15edf30f336885e5b851f6b7199c6cd1">dynamic_programming::knapsack::maxKnapsackValue</a>(</div>
<div class="line"><a id="l00103" name="l00103"></a><span class="lineno"> 103</span> capacity1, weight1, value1);</div>
<div class="line"><a id="l00104" name="l00104"></a><span class="lineno"> 104</span> <span class="keyword">const</span> <span class="keywordtype">int</span> expected_max_value1 = 220;</div>
<div class="line"><a id="l00105" name="l00105"></a><span class="lineno"> 105</span> assert(max_value1 == expected_max_value1);</div>
<div class="line"><a id="l00106" name="l00106"></a><span class="lineno"> 106</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;Maximum Knapsack value with &quot;</span> &lt;&lt; n1 &lt;&lt; <span class="stringliteral">&quot; items is &quot;</span></div>
<div class="line"><a id="l00107" name="l00107"></a><span class="lineno"> 107</span> &lt;&lt; max_value1 &lt;&lt; <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="l00108" name="l00108"></a><span class="lineno"> 108</span> </div>
<div class="line"><a id="l00109" name="l00109"></a><span class="lineno"> 109</span> <span class="comment">// Test 2</span></div>
<div class="line"><a id="l00110" name="l00110"></a><span class="lineno"> 110</span> <span class="keyword">const</span> <span class="keywordtype">int</span> n2 = 4; <span class="comment">// number of items</span></div>
<div class="line"><a id="l00111" name="l00111"></a><span class="lineno"> 111</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/array.html">std::array&lt;int, n2&gt;</a> weight2 = {24, 10, 10, 7}; <span class="comment">// weight of each item</span></div>
<div class="line"><a id="l00112" name="l00112"></a><span class="lineno"> 112</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/array.html">std::array&lt;int, n2&gt;</a> value2 = {24, 18, 18, 10}; <span class="comment">// value of each item</span></div>
<div class="line"><a id="l00113" name="l00113"></a><span class="lineno"> 113</span> <span class="keyword">const</span> <span class="keywordtype">int</span> capacity2 = 25; <span class="comment">// capacity of carrying bag</span></div>
<div class="line"><a id="l00114" name="l00114"></a><span class="lineno"> 114</span> <span class="keyword">const</span> <span class="keywordtype">int</span> max_value2 = <a class="code hl_function" href="../../db/d16/0__1__knapsack_8cpp.html#a15edf30f336885e5b851f6b7199c6cd1">dynamic_programming::knapsack::maxKnapsackValue</a>(</div>
<div class="line"><a id="l00115" name="l00115"></a><span class="lineno"> 115</span> capacity2, weight2, value2);</div>
<div class="line"><a id="l00116" name="l00116"></a><span class="lineno"> 116</span> <span class="keyword">const</span> <span class="keywordtype">int</span> expected_max_value2 = 36;</div>
<div class="line"><a id="l00117" name="l00117"></a><span class="lineno"> 117</span> assert(max_value2 == expected_max_value2);</div>
<div class="line"><a id="l00118" name="l00118"></a><span class="lineno"> 118</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;Maximum Knapsack value with &quot;</span> &lt;&lt; n2 &lt;&lt; <span class="stringliteral">&quot; items is &quot;</span></div>
<div class="line"><a id="l00119" name="l00119"></a><span class="lineno"> 119</span> &lt;&lt; max_value2 &lt;&lt; <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="l00120" name="l00120"></a><span class="lineno"> 120</span>}</div>
<div class="fragment"><div class="line"><span class="lineno"> 96</span> {</div>
<div class="line"><span class="lineno"> 97</span> <span class="comment">// Test 1</span></div>
<div class="line"><span class="lineno"> 98</span> <span class="keyword">const</span> <span class="keywordtype">int</span> n1 = 3; <span class="comment">// number of items</span></div>
<div class="line"><span class="lineno"> 99</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/array.html">std::array&lt;int, n1&gt;</a> weight1 = {10, 20, 30}; <span class="comment">// weight of each item</span></div>
<div class="line"><span class="lineno"> 100</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/array.html">std::array&lt;int, n1&gt;</a> value1 = {60, 100, 120}; <span class="comment">// value of each item</span></div>
<div class="line"><span class="lineno"> 101</span> <span class="keyword">const</span> <span class="keywordtype">int</span> capacity1 = 50; <span class="comment">// capacity of carrying bag</span></div>
<div class="line"><span class="lineno"> 102</span> <span class="keyword">const</span> <span class="keywordtype">int</span> max_value1 = <a class="code hl_function" href="../../db/d16/0__1__knapsack_8cpp.html#a15edf30f336885e5b851f6b7199c6cd1">dynamic_programming::knapsack::maxKnapsackValue</a>(</div>
<div class="line"><span class="lineno"> 103</span> capacity1, weight1, value1);</div>
<div class="line"><span class="lineno"> 104</span> <span class="keyword">const</span> <span class="keywordtype">int</span> expected_max_value1 = 220;</div>
<div class="line"><span class="lineno"> 105</span> assert(max_value1 == expected_max_value1);</div>
<div class="line"><span class="lineno"> 106</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;Maximum Knapsack value with &quot;</span> &lt;&lt; n1 &lt;&lt; <span class="stringliteral">&quot; items is &quot;</span></div>
<div class="line"><span class="lineno"> 107</span> &lt;&lt; max_value1 &lt;&lt; <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"> 108</span> </div>
<div class="line"><span class="lineno"> 109</span> <span class="comment">// Test 2</span></div>
<div class="line"><span class="lineno"> 110</span> <span class="keyword">const</span> <span class="keywordtype">int</span> n2 = 4; <span class="comment">// number of items</span></div>
<div class="line"><span class="lineno"> 111</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/array.html">std::array&lt;int, n2&gt;</a> weight2 = {24, 10, 10, 7}; <span class="comment">// weight of each item</span></div>
<div class="line"><span class="lineno"> 112</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/array.html">std::array&lt;int, n2&gt;</a> value2 = {24, 18, 18, 10}; <span class="comment">// value of each item</span></div>
<div class="line"><span class="lineno"> 113</span> <span class="keyword">const</span> <span class="keywordtype">int</span> capacity2 = 25; <span class="comment">// capacity of carrying bag</span></div>
<div class="line"><span class="lineno"> 114</span> <span class="keyword">const</span> <span class="keywordtype">int</span> max_value2 = <a class="code hl_function" href="../../db/d16/0__1__knapsack_8cpp.html#a15edf30f336885e5b851f6b7199c6cd1">dynamic_programming::knapsack::maxKnapsackValue</a>(</div>
<div class="line"><span class="lineno"> 115</span> capacity2, weight2, value2);</div>
<div class="line"><span class="lineno"> 116</span> <span class="keyword">const</span> <span class="keywordtype">int</span> expected_max_value2 = 36;</div>
<div class="line"><span class="lineno"> 117</span> assert(max_value2 == expected_max_value2);</div>
<div class="line"><span class="lineno"> 118</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;Maximum Knapsack value with &quot;</span> &lt;&lt; n2 &lt;&lt; <span class="stringliteral">&quot; items is &quot;</span></div>
<div class="line"><span class="lineno"> 119</span> &lt;&lt; max_value2 &lt;&lt; <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"> 120</span>}</div>
<div class="ttc" id="a0__1__knapsack_8cpp_html_a15edf30f336885e5b851f6b7199c6cd1"><div class="ttname"><a href="../../db/d16/0__1__knapsack_8cpp.html#a15edf30f336885e5b851f6b7199c6cd1">dynamic_programming::knapsack::maxKnapsackValue</a></div><div class="ttdeci">int maxKnapsackValue(const int capacity, const std::array&lt; int, n &gt; &amp;weight, const std::array&lt; int, n &gt; &amp;value)</div><div class="ttdoc">Picking up all those items whose combined weight is below given capacity and calculating value of tho...</div><div class="ttdef"><b>Definition:</b> 0_1_knapsack.cpp:51</div></div>
<div class="ttc" id="aarray_html"><div class="ttname"><a href="http://en.cppreference.com/w/cpp/container/array.html">std::array</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>
@@ -342,7 +342,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_8a20dd5bfd5341a725342bf72b6b686f.html">dynamic_programming</a></li><li class="navelem"><a class="el" href="../../db/d16/0__1__knapsack_8cpp.html">0_1_knapsack.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>

View File

@@ -1,4 +1,4 @@
<map id="dynamic_programming::knapsack::maxKnapsackValue" name="dynamic_programming::knapsack::maxKnapsackValue">
<area shape="rect" id="node1" title="Picking up all those items whose combined weight is below given capacity and calculating value of tho..." alt="" coords="5,29,215,71"/>
<area shape="rect" id="node2" href="/Users/runner/work/C-Plus-Plus/C-Plus-Plus/doc/cppreference-doxygen-web.tag.xml$cpp/algorithm/max.html#" title=" " alt="" coords="263,37,336,63"/>
<area shape="rect" id="node2" href="/Users/runner/work/C-Plus-Plus/C-Plus-Plus/doc/cppreference-doxygen-web.tag.xml$cpp/algorithm/max#" title=" " alt="" coords="263,37,336,63"/>
</map>

View File

@@ -1 +1 @@
c86f60a494594907b1dcc48d575dc9f8
7b48bda1c0bc6b9b8c47158dc2d11519

View File

@@ -28,7 +28,7 @@
<!-- Node2 -->
<g id="node2" class="node">
<title>Node2</title>
<g id="a_node2"><a target="_blank" xlink:href="http://en.cppreference.com/w/cpp/algorithm/max.html#" xlink:title=" ">
<g id="a_node2"><a target="_blank" xlink:href="http://en.cppreference.com/w/cpp/algorithm/max#" xlink:title=" ">
<polygon fill="white" stroke="black" points="193,-6 193,-25 248,-25 248,-6 193,-6"/>
<text text-anchor="middle" x="220.5" y="-13" font-family="Helvetica,sans-Serif" font-size="10.00">std::max</text>
</a>

Before

Width:  |  Height:  |  Size: 2.2 KiB

After

Width:  |  Height:  |  Size: 2.2 KiB

View File

@@ -1,4 +1,4 @@
<map id="test" name="test">
<area shape="rect" id="node1" title="Function to test above algorithm." alt="" coords="5,5,49,32"/>
<area shape="rect" id="node2" href="/Users/runner/work/C-Plus-Plus/C-Plus-Plus/doc/cppreference-doxygen-web.tag.xml$cpp/io/manip/endl.html#" title=" " alt="" coords="97,5,169,32"/>
<area shape="rect" id="node2" href="/Users/runner/work/C-Plus-Plus/C-Plus-Plus/doc/cppreference-doxygen-web.tag.xml$cpp/io/manip/endl#" title=" " alt="" coords="97,5,169,32"/>
</map>

View File

@@ -1 +1 @@
64c90610e30b3ab35b411975a63245fd
6725c7e36dfa354b77bf80ef690e3c61

View File

@@ -21,7 +21,7 @@
<!-- Node2 -->
<g id="node2" class="node">
<title>Node2</title>
<g id="a_node2"><a target="_blank" xlink:href="http://en.cppreference.com/w/cpp/io/manip/endl.html#" xlink:title=" ">
<g id="a_node2"><a target="_blank" xlink:href="http://en.cppreference.com/w/cpp/io/manip/endl#" xlink:title=" ">
<polygon fill="white" stroke="black" points="69,-0.5 69,-19.5 123,-19.5 123,-0.5 69,-0.5"/>
<text text-anchor="middle" x="96" y="-7.5" font-family="Helvetica,sans-Serif" font-size="10.00">std::endl</text>
</a>

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 1.6 KiB

View File

@@ -1,5 +1,5 @@
<map id="main" name="main">
<area shape="rect" id="node1" title="Main function." alt="" coords="5,5,56,32"/>
<area shape="rect" id="node2" href="$db/d16/0__1__knapsack_8cpp.html#aa8dca7b867074164d5f45b0f3851269d" title="Function to test above algorithm." alt="" coords="104,5,148,32"/>
<area shape="rect" id="node3" href="/Users/runner/work/C-Plus-Plus/C-Plus-Plus/doc/cppreference-doxygen-web.tag.xml$cpp/io/manip/endl.html#" title=" " alt="" coords="196,5,268,32"/>
<area shape="rect" id="node3" href="/Users/runner/work/C-Plus-Plus/C-Plus-Plus/doc/cppreference-doxygen-web.tag.xml$cpp/io/manip/endl#" title=" " alt="" coords="196,5,268,32"/>
</map>

View File

@@ -1 +1 @@
9afee202f399d4d5a1866bc1fd0a1124
5197251d9d01fae606e4998b92ce05e7

View File

@@ -36,7 +36,7 @@
<!-- Node3 -->
<g id="node3" class="node">
<title>Node3</title>
<g id="a_node3"><a target="_blank" xlink:href="http://en.cppreference.com/w/cpp/io/manip/endl.html#" xlink:title=" ">
<g id="a_node3"><a target="_blank" xlink:href="http://en.cppreference.com/w/cpp/io/manip/endl#" xlink:title=" ">
<polygon fill="white" stroke="black" points="143,-0.5 143,-19.5 197,-19.5 197,-0.5 143,-0.5"/>
<text text-anchor="middle" x="170" y="-7.5" font-family="Helvetica,sans-Serif" font-size="10.00">std::endl</text>
</a>

Before

Width:  |  Height:  |  Size: 2.3 KiB

After

Width:  |  Height:  |  Size: 2.3 KiB

View File

@@ -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++: linear_probing::Entry Struct 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">&#160;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&amp;dn=expat.txt MIT */
var searchBox = new SearchBox("searchBox", "../../search",'Search','.html');
@@ -123,7 +123,7 @@ int&#160;</td><td class="memItemRight" valign="bottom"><b>key</b></td></tr>
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
<ul>
<li class="navelem"><a class="el" href="../../d8/d89/namespacelinear__probing.html">linear_probing</a></li><li class="navelem"><a class="el" href="../../db/d19/structlinear__probing_1_1_entry.html">Entry</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>

View File

@@ -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++: Member List</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">&#160;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&amp;dn=expat.txt MIT */
var searchBox = new SearchBox("searchBox", "../../search",'Search','.html');
@@ -108,7 +108,7 @@ $(document).ready(function(){initNavTree('dc/d61/classgraph_1_1_graph.html','../
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
<ul>
<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>

View File

@@ -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++: math/n_bonacci.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">&#160;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&amp;dn=expat.txt MIT */
var searchBox = new SearchBox("searchBox", "../../search",'Search','.html');
@@ -155,10 +155,10 @@ Functions</h2></td></tr>
<p>Main function. </p>
<dl class="section return"><dt>Returns</dt><dd>0 on exit </dd></dl>
<div class="fragment"><div class="line"><a id="l00120" name="l00120"></a><span class="lineno"> 120</span> {</div>
<div class="line"><a id="l00121" name="l00121"></a><span class="lineno"> 121</span> <a class="code hl_function" href="../../db/d27/n__bonacci_8cpp.html#aa8dca7b867074164d5f45b0f3851269d">test</a>(); <span class="comment">// run self-test implementations</span></div>
<div class="line"><a id="l00122" name="l00122"></a><span class="lineno"> 122</span> <span class="keywordflow">return</span> 0;</div>
<div class="line"><a id="l00123" name="l00123"></a><span class="lineno"> 123</span>}</div>
<div class="fragment"><div class="line"><span class="lineno"> 120</span> {</div>
<div class="line"><span class="lineno"> 121</span> <a class="code hl_function" href="../../db/d27/n__bonacci_8cpp.html#aa8dca7b867074164d5f45b0f3851269d">test</a>(); <span class="comment">// run self-test implementations</span></div>
<div class="line"><span class="lineno"> 122</span> <span class="keywordflow">return</span> 0;</div>
<div class="line"><span class="lineno"> 123</span>}</div>
<div class="ttc" id="an__bonacci_8cpp_html_aa8dca7b867074164d5f45b0f3851269d"><div class="ttname"><a href="../../db/d27/n__bonacci_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> n_bonacci.cpp:63</div></div>
</div><!-- fragment --><div class="dynheader">
Here is the call graph for this function:</div>
@@ -206,22 +206,22 @@ Here is the call graph for this function:</div>
<dl class="section return"><dt>Returns</dt><dd>the n-bonacci sequence as vector array </dd></dl>
<p >we initialise the (n-1)th term as 1 which is the sum of preceding N zeros</p>
<p >similarily the sum of preceding N zeros and the (N+1)th 1 is also 1</p>
<div class="fragment"><div class="line"><a id="l00041" name="l00041"></a><span class="lineno"> 41</span> {</div>
<div class="line"><a id="l00042" name="l00042"></a><span class="lineno"> 42</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector&lt;uint64_t&gt;</a> a(m, 0); <span class="comment">// we create an empty array of size m</span></div>
<div class="line"><a id="l00043" name="l00043"></a><span class="lineno"> 43</span> </div>
<div class="line"><a id="l00044" name="l00044"></a><span class="lineno"> 44</span> a[n - 1] = 1; <span class="comment">/// we initialise the (n-1)th term as 1 which is the sum of</span><span class="comment"></span></div>
<div class="line"><a id="l00045" name="l00045"></a><span class="lineno"> 45</span><span class="comment"> /// preceding N zeros</span></div>
<div class="line"><a id="l00046" name="l00046"></a><span class="lineno"> 46</span><span class="comment"></span> a[n] = 1; <span class="comment">/// similarily the sum of preceding N zeros and the (N+1)th 1 is</span><span class="comment"></span></div>
<div class="line"><a id="l00047" name="l00047"></a><span class="lineno"> 47</span><span class="comment"> /// also 1</span></div>
<div class="line"><a id="l00048" name="l00048"></a><span class="lineno"> 48</span><span class="comment"></span> <span class="keywordflow">for</span> (uint64_t i = n + 1; i &lt; m; i++) {</div>
<div class="line"><a id="l00049" name="l00049"></a><span class="lineno"> 49</span> <span class="comment">// this is an optimized solution that works in O(M) time and takes O(M)</span></div>
<div class="line"><a id="l00050" name="l00050"></a><span class="lineno"> 50</span> <span class="comment">// extra space here we use the concept of the sliding window the current</span></div>
<div class="line"><a id="l00051" name="l00051"></a><span class="lineno"> 51</span> <span class="comment">// term can be computed using the given formula</span></div>
<div class="line"><a id="l00052" name="l00052"></a><span class="lineno"> 52</span> a[i] = 2 * a[i - 1] - a[i - 1 - n];</div>
<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> <span class="keywordflow">return</span> a;</div>
<div class="line"><a id="l00055" name="l00055"></a><span class="lineno"> 55</span>}</div>
<div class="ttc" id="avector_html"><div class="ttname"><a href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector</a></div></div>
<div class="fragment"><div class="line"><span class="lineno"> 41</span> {</div>
<div class="line"><span class="lineno"> 42</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector&lt;uint64_t&gt;</a> a(m, 0); <span class="comment">// we create an empty array of size m</span></div>
<div class="line"><span class="lineno"> 43</span> </div>
<div class="line"><span class="lineno"> 44</span> a[n - 1] = 1; <span class="comment">/// we initialise the (n-1)th term as 1 which is the sum of</span><span class="comment"></span></div>
<div class="line"><span class="lineno"> 45</span><span class="comment"> /// preceding N zeros</span></div>
<div class="line"><span class="lineno"> 46</span><span class="comment"></span> a[n] = 1; <span class="comment">/// similarily the sum of preceding N zeros and the (N+1)th 1 is</span><span class="comment"></span></div>
<div class="line"><span class="lineno"> 47</span><span class="comment"> /// also 1</span></div>
<div class="line"><span class="lineno"> 48</span><span class="comment"></span> <span class="keywordflow">for</span> (uint64_t i = n + 1; i &lt; m; i++) {</div>
<div class="line"><span class="lineno"> 49</span> <span class="comment">// this is an optimized solution that works in O(M) time and takes O(M)</span></div>
<div class="line"><span class="lineno"> 50</span> <span class="comment">// extra space here we use the concept of the sliding window the current</span></div>
<div class="line"><span class="lineno"> 51</span> <span class="comment">// term can be computed using the given formula</span></div>
<div class="line"><span class="lineno"> 52</span> a[i] = 2 * a[i - 1] - a[i - 1 - n];</div>
<div class="line"><span class="lineno"> 53</span> }</div>
<div class="line"><span class="lineno"> 54</span> <span class="keywordflow">return</span> a;</div>
<div class="line"><span class="lineno"> 55</span>}</div>
<div class="ttc" id="avector_html"><div class="ttname"><a href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector&lt; uint64_t &gt;</a></div></div>
</div><!-- fragment --><div class="dynheader">
Here is the call graph for this function:</div>
<div class="dyncontent">
@@ -256,58 +256,58 @@ Here is the call graph for this function:</div>
<p>Self-test implementations. </p>
<dl class="section return"><dt>Returns</dt><dd>void </dd></dl>
<div class="fragment"><div class="line"><a id="l00063" name="l00063"></a><span class="lineno"> 63</span> {</div>
<div class="line"><a id="l00064" name="l00064"></a><span class="lineno"> 64</span> <span class="comment">// n = 1 m = 1 return [1, 1]</span></div>
<div class="line"><a id="l00065" name="l00065"></a><span class="lineno"> 65</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;1st test&quot;</span>;</div>
<div class="line"><a id="l00066" name="l00066"></a><span class="lineno"> 66</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector&lt;uint64_t&gt;</a> arr1 = <a class="code hl_function" href="../../db/d27/n__bonacci_8cpp.html#a6849b68f760be628d5975ab3eddec63d">math::n_bonacci::N_bonacci</a>(</div>
<div class="line"><a id="l00067" name="l00067"></a><span class="lineno"> 67</span> 1, 1); <span class="comment">// first input is the param n and second one is the param m for</span></div>
<div class="line"><a id="l00068" name="l00068"></a><span class="lineno"> 68</span> <span class="comment">// N-bonacci func</span></div>
<div class="line"><a id="l00069" name="l00069"></a><span class="lineno"> 69</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector&lt;uint64_t&gt;</a> output_array1 = {</div>
<div class="line"><a id="l00070" name="l00070"></a><span class="lineno"> 70</span> 1, 1}; <span class="comment">// It is the expected output series of length m</span></div>
<div class="line"><a id="l00071" name="l00071"></a><span class="lineno"> 71</span> assert(<a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/algorithm/equal.html">std::equal</a>(<a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/iterator/begin.html">std::begin</a>(arr1), <a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/iterator/end.html">std::end</a>(arr1),</div>
<div class="line"><a id="l00072" name="l00072"></a><span class="lineno"> 72</span> <a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/iterator/begin.html">std::begin</a>(output_array1)));</div>
<div class="line"><a id="l00073" name="l00073"></a><span class="lineno"> 73</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;passed&quot;</span> &lt;&lt; <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="l00074" name="l00074"></a><span class="lineno"> 74</span> </div>
<div class="line"><a id="l00075" name="l00075"></a><span class="lineno"> 75</span> <span class="comment">// n = 5 m = 15 return [0, 0, 0, 0, 1, 1, 2, 4, 8, 16, 31, 61, 120, 236,</span></div>
<div class="line"><a id="l00076" name="l00076"></a><span class="lineno"> 76</span> <span class="comment">// 464]</span></div>
<div class="line"><a id="l00077" name="l00077"></a><span class="lineno"> 77</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;2nd test&quot;</span>;</div>
<div class="line"><a id="l00078" name="l00078"></a><span class="lineno"> 78</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector&lt;uint64_t&gt;</a> arr2 = <a class="code hl_function" href="../../db/d27/n__bonacci_8cpp.html#a6849b68f760be628d5975ab3eddec63d">math::n_bonacci::N_bonacci</a>(</div>
<div class="line"><a id="l00079" name="l00079"></a><span class="lineno"> 79</span> 5, 15); <span class="comment">// first input is the param n and second one is the param m for</span></div>
<div class="line"><a id="l00080" name="l00080"></a><span class="lineno"> 80</span> <span class="comment">// N-bonacci func</span></div>
<div class="line"><a id="l00081" name="l00081"></a><span class="lineno"> 81</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector&lt;uint64_t&gt;</a> output_array2 = {</div>
<div class="line"><a id="l00082" name="l00082"></a><span class="lineno"> 82</span> 0, 0, 0, 0, 1, 1, 2, 4,</div>
<div class="line"><a id="l00083" name="l00083"></a><span class="lineno"> 83</span> 8, 16, 31, 61, 120, 236, 464}; <span class="comment">// It is the expected output series of</span></div>
<div class="line"><a id="l00084" name="l00084"></a><span class="lineno"> 84</span> <span class="comment">// length m</span></div>
<div class="line"><a id="l00085" name="l00085"></a><span class="lineno"> 85</span> assert(<a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/algorithm/equal.html">std::equal</a>(<a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/iterator/begin.html">std::begin</a>(arr2), <a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/iterator/end.html">std::end</a>(arr2),</div>
<div class="line"><a id="l00086" name="l00086"></a><span class="lineno"> 86</span> <a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/iterator/begin.html">std::begin</a>(output_array2)));</div>
<div class="line"><a id="l00087" name="l00087"></a><span class="lineno"> 87</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;passed&quot;</span> &lt;&lt; <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="l00088" name="l00088"></a><span class="lineno"> 88</span> </div>
<div class="line"><a id="l00089" name="l00089"></a><span class="lineno"> 89</span> <span class="comment">// n = 6 m = 17 return [0, 0, 0, 0, 0, 1, 1, 2, 4, 8, 16, 32, 63, 125, 248,</span></div>
<div class="line"><a id="l00090" name="l00090"></a><span class="lineno"> 90</span> <span class="comment">// 492, 976]</span></div>
<div class="line"><a id="l00091" name="l00091"></a><span class="lineno"> 91</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;3rd test&quot;</span>;</div>
<div class="line"><a id="l00092" name="l00092"></a><span class="lineno"> 92</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector&lt;uint64_t&gt;</a> arr3 = <a class="code hl_function" href="../../db/d27/n__bonacci_8cpp.html#a6849b68f760be628d5975ab3eddec63d">math::n_bonacci::N_bonacci</a>(</div>
<div class="line"><a id="l00093" name="l00093"></a><span class="lineno"> 93</span> 6, 17); <span class="comment">// first input is the param n and second one is the param m for</span></div>
<div class="line"><a id="l00094" name="l00094"></a><span class="lineno"> 94</span> <span class="comment">// N-bonacci func</span></div>
<div class="line"><a id="l00095" name="l00095"></a><span class="lineno"> 95</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector&lt;uint64_t&gt;</a> output_array3 = {</div>
<div class="line"><a id="l00096" name="l00096"></a><span class="lineno"> 96</span> 0, 0, 0, 0, 0, 1, 1, 2, 4,</div>
<div class="line"><a id="l00097" name="l00097"></a><span class="lineno"> 97</span> 8, 16, 32, 63, 125, 248, 492, 976}; <span class="comment">// It is the expected output series</span></div>
<div class="line"><a id="l00098" name="l00098"></a><span class="lineno"> 98</span> <span class="comment">// of length m</span></div>
<div class="line"><a id="l00099" name="l00099"></a><span class="lineno"> 99</span> assert(<a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/algorithm/equal.html">std::equal</a>(<a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/iterator/begin.html">std::begin</a>(arr3), <a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/iterator/end.html">std::end</a>(arr3),</div>
<div class="line"><a id="l00100" name="l00100"></a><span class="lineno"> 100</span> <a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/iterator/begin.html">std::begin</a>(output_array3)));</div>
<div class="line"><a id="l00101" name="l00101"></a><span class="lineno"> 101</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;passed&quot;</span> &lt;&lt; <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="l00102" name="l00102"></a><span class="lineno"> 102</span> </div>
<div class="line"><a id="l00103" name="l00103"></a><span class="lineno"> 103</span> <span class="comment">// n = 56 m = 15 return [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]</span></div>
<div class="line"><a id="l00104" name="l00104"></a><span class="lineno"> 104</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;4th test&quot;</span>;</div>
<div class="line"><a id="l00105" name="l00105"></a><span class="lineno"> 105</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector&lt;uint64_t&gt;</a> arr4 = <a class="code hl_function" href="../../db/d27/n__bonacci_8cpp.html#a6849b68f760be628d5975ab3eddec63d">math::n_bonacci::N_bonacci</a>(</div>
<div class="line"><a id="l00106" name="l00106"></a><span class="lineno"> 106</span> 56, 15); <span class="comment">// first input is the param n and second one is the param m</span></div>
<div class="line"><a id="l00107" name="l00107"></a><span class="lineno"> 107</span> <span class="comment">// for N-bonacci func</span></div>
<div class="line"><a id="l00108" name="l00108"></a><span class="lineno"> 108</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector&lt;uint64_t&gt;</a> output_array4 = {</div>
<div class="line"><a id="l00109" name="l00109"></a><span class="lineno"> 109</span> 0, 0, 0, 0, 0, 0, 0, 0,</div>
<div class="line"><a id="l00110" name="l00110"></a><span class="lineno"> 110</span> 0, 0, 0, 0, 0, 0, 0}; <span class="comment">// It is the expected output series of length m</span></div>
<div class="line"><a id="l00111" name="l00111"></a><span class="lineno"> 111</span> assert(<a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/algorithm/equal.html">std::equal</a>(<a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/iterator/begin.html">std::begin</a>(arr4), <a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/iterator/end.html">std::end</a>(arr4),</div>
<div class="line"><a id="l00112" name="l00112"></a><span class="lineno"> 112</span> <a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/iterator/begin.html">std::begin</a>(output_array4)));</div>
<div class="line"><a id="l00113" name="l00113"></a><span class="lineno"> 113</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;passed&quot;</span> &lt;&lt; <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="l00114" name="l00114"></a><span class="lineno"> 114</span>}</div>
<div class="fragment"><div class="line"><span class="lineno"> 63</span> {</div>
<div class="line"><span class="lineno"> 64</span> <span class="comment">// n = 1 m = 1 return [1, 1]</span></div>
<div class="line"><span class="lineno"> 65</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;1st test&quot;</span>;</div>
<div class="line"><span class="lineno"> 66</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector&lt;uint64_t&gt;</a> arr1 = <a class="code hl_function" href="../../db/d27/n__bonacci_8cpp.html#a6849b68f760be628d5975ab3eddec63d">math::n_bonacci::N_bonacci</a>(</div>
<div class="line"><span class="lineno"> 67</span> 1, 1); <span class="comment">// first input is the param n and second one is the param m for</span></div>
<div class="line"><span class="lineno"> 68</span> <span class="comment">// N-bonacci func</span></div>
<div class="line"><span class="lineno"> 69</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector&lt;uint64_t&gt;</a> output_array1 = {</div>
<div class="line"><span class="lineno"> 70</span> 1, 1}; <span class="comment">// It is the expected output series of length m</span></div>
<div class="line"><span class="lineno"> 71</span> assert(<a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/algorithm/equal.html">std::equal</a>(<a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/iterator/begin.html">std::begin</a>(arr1), <a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/iterator/end.html">std::end</a>(arr1),</div>
<div class="line"><span class="lineno"> 72</span> <a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/iterator/begin.html">std::begin</a>(output_array1)));</div>
<div class="line"><span class="lineno"> 73</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;passed&quot;</span> &lt;&lt; <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"> 74</span> </div>
<div class="line"><span class="lineno"> 75</span> <span class="comment">// n = 5 m = 15 return [0, 0, 0, 0, 1, 1, 2, 4, 8, 16, 31, 61, 120, 236,</span></div>
<div class="line"><span class="lineno"> 76</span> <span class="comment">// 464]</span></div>
<div class="line"><span class="lineno"> 77</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;2nd test&quot;</span>;</div>
<div class="line"><span class="lineno"> 78</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector&lt;uint64_t&gt;</a> arr2 = <a class="code hl_function" href="../../db/d27/n__bonacci_8cpp.html#a6849b68f760be628d5975ab3eddec63d">math::n_bonacci::N_bonacci</a>(</div>
<div class="line"><span class="lineno"> 79</span> 5, 15); <span class="comment">// first input is the param n and second one is the param m for</span></div>
<div class="line"><span class="lineno"> 80</span> <span class="comment">// N-bonacci func</span></div>
<div class="line"><span class="lineno"> 81</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector&lt;uint64_t&gt;</a> output_array2 = {</div>
<div class="line"><span class="lineno"> 82</span> 0, 0, 0, 0, 1, 1, 2, 4,</div>
<div class="line"><span class="lineno"> 83</span> 8, 16, 31, 61, 120, 236, 464}; <span class="comment">// It is the expected output series of</span></div>
<div class="line"><span class="lineno"> 84</span> <span class="comment">// length m</span></div>
<div class="line"><span class="lineno"> 85</span> assert(<a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/algorithm/equal.html">std::equal</a>(<a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/iterator/begin.html">std::begin</a>(arr2), <a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/iterator/end.html">std::end</a>(arr2),</div>
<div class="line"><span class="lineno"> 86</span> <a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/iterator/begin.html">std::begin</a>(output_array2)));</div>
<div class="line"><span class="lineno"> 87</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;passed&quot;</span> &lt;&lt; <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"> 88</span> </div>
<div class="line"><span class="lineno"> 89</span> <span class="comment">// n = 6 m = 17 return [0, 0, 0, 0, 0, 1, 1, 2, 4, 8, 16, 32, 63, 125, 248,</span></div>
<div class="line"><span class="lineno"> 90</span> <span class="comment">// 492, 976]</span></div>
<div class="line"><span class="lineno"> 91</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;3rd test&quot;</span>;</div>
<div class="line"><span class="lineno"> 92</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector&lt;uint64_t&gt;</a> arr3 = <a class="code hl_function" href="../../db/d27/n__bonacci_8cpp.html#a6849b68f760be628d5975ab3eddec63d">math::n_bonacci::N_bonacci</a>(</div>
<div class="line"><span class="lineno"> 93</span> 6, 17); <span class="comment">// first input is the param n and second one is the param m for</span></div>
<div class="line"><span class="lineno"> 94</span> <span class="comment">// N-bonacci func</span></div>
<div class="line"><span class="lineno"> 95</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector&lt;uint64_t&gt;</a> output_array3 = {</div>
<div class="line"><span class="lineno"> 96</span> 0, 0, 0, 0, 0, 1, 1, 2, 4,</div>
<div class="line"><span class="lineno"> 97</span> 8, 16, 32, 63, 125, 248, 492, 976}; <span class="comment">// It is the expected output series</span></div>
<div class="line"><span class="lineno"> 98</span> <span class="comment">// of length m</span></div>
<div class="line"><span class="lineno"> 99</span> assert(<a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/algorithm/equal.html">std::equal</a>(<a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/iterator/begin.html">std::begin</a>(arr3), <a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/iterator/end.html">std::end</a>(arr3),</div>
<div class="line"><span class="lineno"> 100</span> <a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/iterator/begin.html">std::begin</a>(output_array3)));</div>
<div class="line"><span class="lineno"> 101</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;passed&quot;</span> &lt;&lt; <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"> 102</span> </div>
<div class="line"><span class="lineno"> 103</span> <span class="comment">// n = 56 m = 15 return [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]</span></div>
<div class="line"><span class="lineno"> 104</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;4th test&quot;</span>;</div>
<div class="line"><span class="lineno"> 105</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector&lt;uint64_t&gt;</a> arr4 = <a class="code hl_function" href="../../db/d27/n__bonacci_8cpp.html#a6849b68f760be628d5975ab3eddec63d">math::n_bonacci::N_bonacci</a>(</div>
<div class="line"><span class="lineno"> 106</span> 56, 15); <span class="comment">// first input is the param n and second one is the param m</span></div>
<div class="line"><span class="lineno"> 107</span> <span class="comment">// for N-bonacci func</span></div>
<div class="line"><span class="lineno"> 108</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector&lt;uint64_t&gt;</a> output_array4 = {</div>
<div class="line"><span class="lineno"> 109</span> 0, 0, 0, 0, 0, 0, 0, 0,</div>
<div class="line"><span class="lineno"> 110</span> 0, 0, 0, 0, 0, 0, 0}; <span class="comment">// It is the expected output series of length m</span></div>
<div class="line"><span class="lineno"> 111</span> assert(<a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/algorithm/equal.html">std::equal</a>(<a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/iterator/begin.html">std::begin</a>(arr4), <a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/iterator/end.html">std::end</a>(arr4),</div>
<div class="line"><span class="lineno"> 112</span> <a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/iterator/begin.html">std::begin</a>(output_array4)));</div>
<div class="line"><span class="lineno"> 113</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;passed&quot;</span> &lt;&lt; <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"> 114</span>}</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="abegin_html"><div class="ttname"><a href="http://en.cppreference.com/w/cpp/iterator/begin.html">std::begin</a></div><div class="ttdeci">T begin(T... args)</div></div>
<div class="ttc" id="aend_html"><div class="ttname"><a href="http://en.cppreference.com/w/cpp/iterator/end.html">std::end</a></div><div class="ttdeci">T end(T... args)</div></div>
@@ -329,7 +329,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_296d53ceaeaa7e099814a6def439fe8a.html">math</a></li><li class="navelem"><a class="el" href="../../db/d27/n__bonacci_8cpp.html">n_bonacci.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>

View File

@@ -1,7 +1,7 @@
<map id="test" name="test">
<area shape="rect" id="node1" title="Self&#45;test implementations." alt="" coords="5,81,49,108"/>
<area shape="rect" id="node2" href="/Users/runner/work/C-Plus-Plus/C-Plus-Plus/doc/cppreference-doxygen-web.tag.xml$cpp/iterator/begin.html#" title=" " alt="" coords="97,5,176,32"/>
<area shape="rect" id="node3" href="/Users/runner/work/C-Plus-Plus/C-Plus-Plus/doc/cppreference-doxygen-web.tag.xml$cpp/iterator/end.html#" title=" " alt="" coords="102,56,171,83"/>
<area shape="rect" id="node4" href="/Users/runner/work/C-Plus-Plus/C-Plus-Plus/doc/cppreference-doxygen-web.tag.xml$cpp/io/manip/endl.html#" title=" " alt="" coords="101,107,173,133"/>
<area shape="rect" id="node5" href="/Users/runner/work/C-Plus-Plus/C-Plus-Plus/doc/cppreference-doxygen-web.tag.xml$cpp/algorithm/equal.html#" title=" " alt="" coords="97,157,176,184"/>
<area shape="rect" id="node2" href="/Users/runner/work/C-Plus-Plus/C-Plus-Plus/doc/cppreference-doxygen-web.tag.xml$cpp/iterator/begin#" title=" " alt="" coords="97,5,176,32"/>
<area shape="rect" id="node3" href="/Users/runner/work/C-Plus-Plus/C-Plus-Plus/doc/cppreference-doxygen-web.tag.xml$cpp/iterator/end#" title=" " alt="" coords="102,56,171,83"/>
<area shape="rect" id="node4" href="/Users/runner/work/C-Plus-Plus/C-Plus-Plus/doc/cppreference-doxygen-web.tag.xml$cpp/io/manip/endl#" title=" " alt="" coords="101,107,173,133"/>
<area shape="rect" id="node5" href="/Users/runner/work/C-Plus-Plus/C-Plus-Plus/doc/cppreference-doxygen-web.tag.xml$cpp/algorithm/equal#" title=" " alt="" coords="97,157,176,184"/>
</map>

View File

@@ -1 +1 @@
82ecc1261753a678db478e342f70dee2
94579618d8e8597b8ea75f029ea44ef1

View File

@@ -21,7 +21,7 @@
<!-- Node2 -->
<g id="node2" class="node">
<title>Node2</title>
<g id="a_node2"><a target="_blank" xlink:href="http://en.cppreference.com/w/cpp/iterator/begin.html#" xlink:title=" ">
<g id="a_node2"><a target="_blank" xlink:href="http://en.cppreference.com/w/cpp/iterator/begin#" xlink:title=" ">
<polygon fill="white" stroke="black" points="69,-114.5 69,-133.5 128,-133.5 128,-114.5 69,-114.5"/>
<text text-anchor="middle" x="98.5" y="-121.5" font-family="Helvetica,sans-Serif" font-size="10.00">std::begin</text>
</a>
@@ -36,7 +36,7 @@
<!-- Node3 -->
<g id="node3" class="node">
<title>Node3</title>
<g id="a_node3"><a target="_blank" xlink:href="http://en.cppreference.com/w/cpp/iterator/end.html#" xlink:title=" ">
<g id="a_node3"><a target="_blank" xlink:href="http://en.cppreference.com/w/cpp/iterator/end#" xlink:title=" ">
<polygon fill="white" stroke="black" points="72.5,-76.5 72.5,-95.5 124.5,-95.5 124.5,-76.5 72.5,-76.5"/>
<text text-anchor="middle" x="98.5" y="-83.5" font-family="Helvetica,sans-Serif" font-size="10.00">std::end</text>
</a>
@@ -51,7 +51,7 @@
<!-- Node4 -->
<g id="node4" class="node">
<title>Node4</title>
<g id="a_node4"><a target="_blank" xlink:href="http://en.cppreference.com/w/cpp/io/manip/endl.html#" xlink:title=" ">
<g id="a_node4"><a target="_blank" xlink:href="http://en.cppreference.com/w/cpp/io/manip/endl#" xlink:title=" ">
<polygon fill="white" stroke="black" points="71.5,-38.5 71.5,-57.5 125.5,-57.5 125.5,-38.5 71.5,-38.5"/>
<text text-anchor="middle" x="98.5" y="-45.5" font-family="Helvetica,sans-Serif" font-size="10.00">std::endl</text>
</a>
@@ -66,7 +66,7 @@
<!-- Node5 -->
<g id="node5" class="node">
<title>Node5</title>
<g id="a_node5"><a target="_blank" xlink:href="http://en.cppreference.com/w/cpp/algorithm/equal.html#" xlink:title=" ">
<g id="a_node5"><a target="_blank" xlink:href="http://en.cppreference.com/w/cpp/algorithm/equal#" xlink:title=" ">
<polygon fill="white" stroke="black" points="69,-0.5 69,-19.5 128,-19.5 128,-0.5 69,-0.5"/>
<text text-anchor="middle" x="98.5" y="-7.5" font-family="Helvetica,sans-Serif" font-size="10.00">std::equal</text>
</a>

Before

Width:  |  Height:  |  Size: 3.8 KiB

After

Width:  |  Height:  |  Size: 3.8 KiB

View File

@@ -1,8 +1,8 @@
<map id="main" name="main">
<area shape="rect" id="node1" title="Main function." alt="" coords="5,81,56,108"/>
<area shape="rect" id="node2" href="$db/d27/n__bonacci_8cpp.html#aa8dca7b867074164d5f45b0f3851269d" title="Self&#45;test implementations." alt="" coords="104,81,148,108"/>
<area shape="rect" id="node3" href="/Users/runner/work/C-Plus-Plus/C-Plus-Plus/doc/cppreference-doxygen-web.tag.xml$cpp/iterator/begin.html#" title=" " alt="" coords="196,5,275,32"/>
<area shape="rect" id="node4" href="/Users/runner/work/C-Plus-Plus/C-Plus-Plus/doc/cppreference-doxygen-web.tag.xml$cpp/iterator/end.html#" title=" " alt="" coords="201,56,270,83"/>
<area shape="rect" id="node5" href="/Users/runner/work/C-Plus-Plus/C-Plus-Plus/doc/cppreference-doxygen-web.tag.xml$cpp/io/manip/endl.html#" title=" " alt="" coords="199,107,271,133"/>
<area shape="rect" id="node6" href="/Users/runner/work/C-Plus-Plus/C-Plus-Plus/doc/cppreference-doxygen-web.tag.xml$cpp/algorithm/equal.html#" title=" " alt="" coords="196,157,275,184"/>
<area shape="rect" id="node3" href="/Users/runner/work/C-Plus-Plus/C-Plus-Plus/doc/cppreference-doxygen-web.tag.xml$cpp/iterator/begin#" title=" " alt="" coords="196,5,275,32"/>
<area shape="rect" id="node4" href="/Users/runner/work/C-Plus-Plus/C-Plus-Plus/doc/cppreference-doxygen-web.tag.xml$cpp/iterator/end#" title=" " alt="" coords="201,56,270,83"/>
<area shape="rect" id="node5" href="/Users/runner/work/C-Plus-Plus/C-Plus-Plus/doc/cppreference-doxygen-web.tag.xml$cpp/io/manip/endl#" title=" " alt="" coords="199,107,271,133"/>
<area shape="rect" id="node6" href="/Users/runner/work/C-Plus-Plus/C-Plus-Plus/doc/cppreference-doxygen-web.tag.xml$cpp/algorithm/equal#" title=" " alt="" coords="196,157,275,184"/>
</map>

View File

@@ -1 +1 @@
ae0eb23fc5285330c95c7105e84b277e
36a1a4638caf7c0235c9842bdf0d4bd5

View File

@@ -36,7 +36,7 @@
<!-- Node3 -->
<g id="node3" class="node">
<title>Node3</title>
<g id="a_node3"><a target="_blank" xlink:href="http://en.cppreference.com/w/cpp/iterator/begin.html#" xlink:title=" ">
<g id="a_node3"><a target="_blank" xlink:href="http://en.cppreference.com/w/cpp/iterator/begin#" xlink:title=" ">
<polygon fill="white" stroke="black" points="143,-114.5 143,-133.5 202,-133.5 202,-114.5 143,-114.5"/>
<text text-anchor="middle" x="172.5" y="-121.5" font-family="Helvetica,sans-Serif" font-size="10.00">std::begin</text>
</a>
@@ -51,7 +51,7 @@
<!-- Node4 -->
<g id="node4" class="node">
<title>Node4</title>
<g id="a_node4"><a target="_blank" xlink:href="http://en.cppreference.com/w/cpp/iterator/end.html#" xlink:title=" ">
<g id="a_node4"><a target="_blank" xlink:href="http://en.cppreference.com/w/cpp/iterator/end#" xlink:title=" ">
<polygon fill="white" stroke="black" points="146.5,-76.5 146.5,-95.5 198.5,-95.5 198.5,-76.5 146.5,-76.5"/>
<text text-anchor="middle" x="172.5" y="-83.5" font-family="Helvetica,sans-Serif" font-size="10.00">std::end</text>
</a>
@@ -66,7 +66,7 @@
<!-- Node5 -->
<g id="node5" class="node">
<title>Node5</title>
<g id="a_node5"><a target="_blank" xlink:href="http://en.cppreference.com/w/cpp/io/manip/endl.html#" xlink:title=" ">
<g id="a_node5"><a target="_blank" xlink:href="http://en.cppreference.com/w/cpp/io/manip/endl#" xlink:title=" ">
<polygon fill="white" stroke="black" points="145.5,-38.5 145.5,-57.5 199.5,-57.5 199.5,-38.5 145.5,-38.5"/>
<text text-anchor="middle" x="172.5" y="-45.5" font-family="Helvetica,sans-Serif" font-size="10.00">std::endl</text>
</a>
@@ -81,7 +81,7 @@
<!-- Node6 -->
<g id="node6" class="node">
<title>Node6</title>
<g id="a_node6"><a target="_blank" xlink:href="http://en.cppreference.com/w/cpp/algorithm/equal.html#" xlink:title=" ">
<g id="a_node6"><a target="_blank" xlink:href="http://en.cppreference.com/w/cpp/algorithm/equal#" xlink:title=" ">
<polygon fill="white" stroke="black" points="143,-0.5 143,-19.5 202,-19.5 202,-0.5 143,-0.5"/>
<text text-anchor="middle" x="172.5" y="-7.5" font-family="Helvetica,sans-Serif" font-size="10.00">std::equal</text>
</a>

Before

Width:  |  Height:  |  Size: 4.6 KiB

After

Width:  |  Height:  |  Size: 4.6 KiB

View File

@@ -0,0 +1,5 @@
<map id="geometry::jarvis::Convexhull" name="geometry::jarvis::Convexhull">
<area shape="rect" id="node1" title=" " alt="" coords="5,199,193,225"/>
<area shape="rect" id="node2" href="/Users/runner/work/C-Plus-Plus/C-Plus-Plus/doc/cppreference-doxygen-web.tag.xml$cpp/container/vector" title=" " alt="" coords="24,95,175,136"/>
<area shape="rect" id="node3" href="$d9/d5a/structgeometry_1_1jarvis_1_1_point.html" title=" " alt="" coords="23,5,176,32"/>
</map>

View File

@@ -0,0 +1 @@
960f4ae2ed9702cda159e1810b4fc164

View File

@@ -0,0 +1,55 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<!-- Generated by graphviz version 2.50.0 (20211204.2007)
-->
<!-- Title: geometry::jarvis::Convexhull Pages: 1 -->
<svg width="149pt" height="173pt"
viewBox="0.00 0.00 149.00 173.00" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<g id="graph0" class="graph" transform="scale(1 1) rotate(0) translate(4 169)">
<title>geometry::jarvis::Convexhull</title>
<polygon fill="white" stroke="transparent" points="-4,4 -4,-169 145,-169 145,4 -4,4"/>
<!-- Node1 -->
<g id="node1" class="node">
<title>Node1</title>
<g id="a_node1"><a xlink:title=" ">
<polygon fill="#bfbfbf" stroke="black" points="0,-0.5 0,-19.5 141,-19.5 141,-0.5 0,-0.5"/>
<text text-anchor="middle" x="70.5" y="-7.5" font-family="Helvetica,sans-Serif" font-size="10.00">geometry::jarvis::Convexhull</text>
</a>
</g>
</g>
<!-- Node2 -->
<g id="node2" class="node">
<title>Node2</title>
<g id="a_node2"><a target="_blank" xlink:href="http://en.cppreference.com/w/cpp/container/vector" xlink:title=" ">
<polygon fill="white" stroke="black" points="14,-67.5 14,-97.5 127,-97.5 127,-67.5 14,-67.5"/>
<text text-anchor="start" x="22" y="-85.5" font-family="Helvetica,sans-Serif" font-size="10.00">std::vector&lt; geometry</text>
<text text-anchor="middle" x="70.5" y="-74.5" font-family="Helvetica,sans-Serif" font-size="10.00">::jarvis::Point &gt;</text>
</a>
</g>
</g>
<!-- Node2&#45;&gt;Node1 -->
<g id="edge1" class="edge">
<title>Node2&#45;&gt;Node1</title>
<path fill="none" stroke="#9a32cd" stroke-dasharray="5,2" d="M70.5,-57.09C70.5,-44.21 70.5,-29.2 70.5,-19.89"/>
<polygon fill="#9a32cd" stroke="#9a32cd" points="67,-57.23 70.5,-67.23 74,-57.23 67,-57.23"/>
<text text-anchor="middle" x="85.5" y="-41" font-family="Helvetica,sans-Serif" font-size="10.00"> points</text>
</g>
<!-- Node3 -->
<g id="node3" class="node">
<title>Node3</title>
<g id="a_node3"><a xlink:href="../../d9/d5a/structgeometry_1_1jarvis_1_1_point.html" target="_top" xlink:title=" ">
<polygon fill="white" stroke="black" points="13,-145.5 13,-164.5 128,-164.5 128,-145.5 13,-145.5"/>
<text text-anchor="middle" x="70.5" y="-152.5" font-family="Helvetica,sans-Serif" font-size="10.00">geometry::jarvis::Point</text>
</a>
</g>
</g>
<!-- Node3&#45;&gt;Node2 -->
<g id="edge2" class="edge">
<title>Node3&#45;&gt;Node2</title>
<path fill="none" stroke="#9a32cd" stroke-dasharray="5,2" d="M70.5,-135.24C70.5,-123.41 70.5,-108.38 70.5,-97.58"/>
<polygon fill="#9a32cd" stroke="#9a32cd" points="67,-135.36 70.5,-145.36 74,-135.36 67,-135.36"/>
<text text-anchor="middle" x="92" y="-119" font-family="Helvetica,sans-Serif" font-size="10.00"> elements</text>
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 2.7 KiB

View File

@@ -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++: Member List</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">&#160;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&amp;dn=expat.txt MIT */
var searchBox = new SearchBox("searchBox", "../../search",'Search','.html');
@@ -106,7 +106,7 @@ $(document).ready(function(){initNavTree('da/d37/structdata__structures_1_1spars
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
<ul>
<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>

View File

@@ -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++: others/tower_of_hanoi.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">&#160;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&amp;dn=expat.txt MIT */
var searchBox = new SearchBox("searchBox", "../../search",'Search','.html');
@@ -142,27 +142,27 @@ Functions</h2></td></tr>
</table>
</div><div class="memdoc">
<p >Main function </p>
<div class="fragment"><div class="line"><a id="l00065" name="l00065"></a><span class="lineno"> 65</span> {</div>
<div class="line"><a id="l00066" name="l00066"></a><span class="lineno"> 66</span> <span class="keyword">struct </span><a class="code hl_struct" href="../../d2/d2c/structtower.html">tower</a> F, U, T;</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> F.<a class="code hl_variable" href="../../d2/d2c/structtower.html#acb535964abd34c47678a4ade0628223d">top</a> = 0;</div>
<div class="line"><a id="l00069" name="l00069"></a><span class="lineno"> 69</span> U.top = 0;</div>
<div class="line"><a id="l00070" name="l00070"></a><span class="lineno"> 70</span> T.top = 0;</div>
<div class="line"><a id="l00071" name="l00071"></a><span class="lineno"> 71</span> </div>
<div class="line"><a id="l00072" name="l00072"></a><span class="lineno"> 72</span> <span class="keywordtype">int</span> no;</div>
<div class="line"><a id="l00073" name="l00073"></a><span class="lineno"> 73</span> </div>
<div class="line"><a id="l00074" name="l00074"></a><span class="lineno"> 74</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 number of discs : &quot;</span>;</div>
<div class="line"><a id="l00075" name="l00075"></a><span class="lineno"> 75</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/basic_istream.html">std::cin</a> &gt;&gt; no;</div>
<div class="line"><a id="l00076" name="l00076"></a><span class="lineno"> 76</span> </div>
<div class="line"><a id="l00077" name="l00077"></a><span class="lineno"> 77</span> <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = no; i &gt; 0; i--) {</div>
<div class="line"><a id="l00078" name="l00078"></a><span class="lineno"> 78</span> F.values[F.top++] = i;</div>
<div class="line"><a id="l00079" name="l00079"></a><span class="lineno"> 79</span> }</div>
<div class="line"><a id="l00080" name="l00080"></a><span class="lineno"> 80</span> </div>
<div class="line"><a id="l00081" name="l00081"></a><span class="lineno"> 81</span> <a class="code hl_function" href="../../db/d3c/tower__of__hanoi_8cpp.html#a746d9a3984bba88fd6dd91978f6931ed">show</a>(&amp;F, &amp;T, &amp;U);</div>
<div class="line"><a id="l00082" name="l00082"></a><span class="lineno"> 82</span> <a class="code hl_function" href="../../db/d3c/tower__of__hanoi_8cpp.html#ab037f72a5eac476535a6cfbbcb965417">TH</a>(no, &amp;F, &amp;U, &amp;T);</div>
<div class="line"><a id="l00083" name="l00083"></a><span class="lineno"> 83</span> </div>
<div class="line"><a id="l00084" name="l00084"></a><span class="lineno"> 84</span> <span class="keywordflow">return</span> 0;</div>
<div class="line"><a id="l00085" name="l00085"></a><span class="lineno"> 85</span>}</div>
<div class="fragment"><div class="line"><span class="lineno"> 65</span> {</div>
<div class="line"><span class="lineno"> 66</span> <span class="keyword">struct </span><a class="code hl_struct" href="../../d2/d2c/structtower.html">tower</a> F, U, T;</div>
<div class="line"><span class="lineno"> 67</span> </div>
<div class="line"><span class="lineno"> 68</span> F.<a class="code hl_variable" href="../../d2/d2c/structtower.html#acb535964abd34c47678a4ade0628223d">top</a> = 0;</div>
<div class="line"><span class="lineno"> 69</span> U.top = 0;</div>
<div class="line"><span class="lineno"> 70</span> T.top = 0;</div>
<div class="line"><span class="lineno"> 71</span> </div>
<div class="line"><span class="lineno"> 72</span> <span class="keywordtype">int</span> no;</div>
<div class="line"><span class="lineno"> 73</span> </div>
<div class="line"><span class="lineno"> 74</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 number of discs : &quot;</span>;</div>
<div class="line"><span class="lineno"> 75</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/basic_istream.html">std::cin</a> &gt;&gt; no;</div>
<div class="line"><span class="lineno"> 76</span> </div>
<div class="line"><span class="lineno"> 77</span> <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = no; i &gt; 0; i--) {</div>
<div class="line"><span class="lineno"> 78</span> F.values[F.top++] = i;</div>
<div class="line"><span class="lineno"> 79</span> }</div>
<div class="line"><span class="lineno"> 80</span> </div>
<div class="line"><span class="lineno"> 81</span> <a class="code hl_function" href="../../db/d3c/tower__of__hanoi_8cpp.html#a746d9a3984bba88fd6dd91978f6931ed">show</a>(&amp;F, &amp;T, &amp;U);</div>
<div class="line"><span class="lineno"> 82</span> <a class="code hl_function" href="../../db/d3c/tower__of__hanoi_8cpp.html#ab037f72a5eac476535a6cfbbcb965417">TH</a>(no, &amp;F, &amp;U, &amp;T);</div>
<div class="line"><span class="lineno"> 83</span> </div>
<div class="line"><span class="lineno"> 84</span> <span class="keywordflow">return</span> 0;</div>
<div class="line"><span class="lineno"> 85</span>}</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="astructtower_html"><div class="ttname"><a href="../../d2/d2c/structtower.html">tower</a></div><div class="ttdef"><b>Definition:</b> tower_of_hanoi.cpp:11</div></div>
@@ -210,11 +210,11 @@ Here is the call graph for this function:</div>
</table>
</dd>
</dl>
<div class="fragment"><div class="line"><a id="l00039" name="l00039"></a><span class="lineno"> 39</span> {</div>
<div class="line"><a id="l00040" name="l00040"></a><span class="lineno"> 40</span> --From-&gt;<a class="code hl_variable" href="../../d2/d2c/structtower.html#acb535964abd34c47678a4ade0628223d">top</a>;</div>
<div class="line"><a id="l00041" name="l00041"></a><span class="lineno"> 41</span> To-&gt;<a class="code hl_variable" href="../../d2/d2c/structtower.html#a3ebb75c13c57d51a8a1ba1ea54a515e9">values</a>[To-&gt;<a class="code hl_variable" href="../../d2/d2c/structtower.html#acb535964abd34c47678a4ade0628223d">top</a>] = From-&gt;<a class="code hl_variable" href="../../d2/d2c/structtower.html#a3ebb75c13c57d51a8a1ba1ea54a515e9">values</a>[From-&gt;<a class="code hl_variable" href="../../d2/d2c/structtower.html#acb535964abd34c47678a4ade0628223d">top</a>];</div>
<div class="line"><a id="l00042" name="l00042"></a><span class="lineno"> 42</span> ++To-&gt;<a class="code hl_variable" href="../../d2/d2c/structtower.html#acb535964abd34c47678a4ade0628223d">top</a>;</div>
<div class="line"><a id="l00043" name="l00043"></a><span class="lineno"> 43</span>}</div>
<div class="fragment"><div class="line"><span class="lineno"> 39</span> {</div>
<div class="line"><span class="lineno"> 40</span> --From-&gt;<a class="code hl_variable" href="../../d2/d2c/structtower.html#acb535964abd34c47678a4ade0628223d">top</a>;</div>
<div class="line"><span class="lineno"> 41</span> To-&gt;<a class="code hl_variable" href="../../d2/d2c/structtower.html#a3ebb75c13c57d51a8a1ba1ea54a515e9">values</a>[To-&gt;<a class="code hl_variable" href="../../d2/d2c/structtower.html#acb535964abd34c47678a4ade0628223d">top</a>] = From-&gt;<a class="code hl_variable" href="../../d2/d2c/structtower.html#a3ebb75c13c57d51a8a1ba1ea54a515e9">values</a>[From-&gt;<a class="code hl_variable" href="../../d2/d2c/structtower.html#acb535964abd34c47678a4ade0628223d">top</a>];</div>
<div class="line"><span class="lineno"> 42</span> ++To-&gt;<a class="code hl_variable" href="../../d2/d2c/structtower.html#acb535964abd34c47678a4ade0628223d">top</a>;</div>
<div class="line"><span class="lineno"> 43</span>}</div>
<div class="ttc" id="astructtower_html_a3ebb75c13c57d51a8a1ba1ea54a515e9"><div class="ttname"><a href="../../d2/d2c/structtower.html#a3ebb75c13c57d51a8a1ba1ea54a515e9">tower::values</a></div><div class="ttdeci">int values[10]</div><div class="ttdoc">Values in the tower.</div><div class="ttdef"><b>Definition:</b> tower_of_hanoi.cpp:13</div></div>
</div><!-- fragment -->
</div>
@@ -251,20 +251,20 @@ Here is the call graph for this function:</div>
</table>
</div><div class="memdoc">
<p >Display the towers </p>
<div class="fragment"><div class="line"><a id="l00020" name="l00020"></a><span class="lineno"> 20</span> {</div>
<div class="line"><a id="l00021" name="l00021"></a><span class="lineno"> 21</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;\n\n\tF : &quot;</span>;</div>
<div class="line"><a id="l00022" name="l00022"></a><span class="lineno"> 22</span> <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i &lt; F-&gt;<a class="code hl_variable" href="../../d2/d2c/structtower.html#acb535964abd34c47678a4ade0628223d">top</a>; i++) {</div>
<div class="line"><a id="l00023" name="l00023"></a><span class="lineno"> 23</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/basic_ostream.html">std::cout</a> &lt;&lt; F-&gt;<a class="code hl_variable" href="../../d2/d2c/structtower.html#a3ebb75c13c57d51a8a1ba1ea54a515e9">values</a>[i] &lt;&lt; <span class="stringliteral">&quot;\t&quot;</span>;</div>
<div class="line"><a id="l00024" name="l00024"></a><span class="lineno"> 24</span> }</div>
<div class="line"><a id="l00025" name="l00025"></a><span class="lineno"> 25</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;\n\tU : &quot;</span>;</div>
<div class="line"><a id="l00026" name="l00026"></a><span class="lineno"> 26</span> <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i &lt; U-&gt;<a class="code hl_variable" href="../../d2/d2c/structtower.html#acb535964abd34c47678a4ade0628223d">top</a>; i++) {</div>
<div class="line"><a id="l00027" name="l00027"></a><span class="lineno"> 27</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/basic_ostream.html">std::cout</a> &lt;&lt; U-&gt;<a class="code hl_variable" href="../../d2/d2c/structtower.html#a3ebb75c13c57d51a8a1ba1ea54a515e9">values</a>[i] &lt;&lt; <span class="stringliteral">&quot;\t&quot;</span>;</div>
<div class="line"><a id="l00028" name="l00028"></a><span class="lineno"> 28</span> }</div>
<div class="line"><a id="l00029" name="l00029"></a><span class="lineno"> 29</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;\n\tT : &quot;</span>;</div>
<div class="line"><a id="l00030" name="l00030"></a><span class="lineno"> 30</span> <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i &lt; T-&gt;<a class="code hl_variable" href="../../d2/d2c/structtower.html#acb535964abd34c47678a4ade0628223d">top</a>; i++) {</div>
<div class="line"><a id="l00031" name="l00031"></a><span class="lineno"> 31</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/basic_ostream.html">std::cout</a> &lt;&lt; T-&gt;<a class="code hl_variable" href="../../d2/d2c/structtower.html#a3ebb75c13c57d51a8a1ba1ea54a515e9">values</a>[i] &lt;&lt; <span class="stringliteral">&quot;\t&quot;</span>;</div>
<div class="line"><a id="l00032" name="l00032"></a><span class="lineno"> 32</span> }</div>
<div class="line"><a id="l00033" name="l00033"></a><span class="lineno"> 33</span>}</div>
<div class="fragment"><div class="line"><span class="lineno"> 20</span> {</div>
<div class="line"><span class="lineno"> 21</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;\n\n\tF : &quot;</span>;</div>
<div class="line"><span class="lineno"> 22</span> <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i &lt; F-&gt;<a class="code hl_variable" href="../../d2/d2c/structtower.html#acb535964abd34c47678a4ade0628223d">top</a>; i++) {</div>
<div class="line"><span class="lineno"> 23</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/basic_ostream.html">std::cout</a> &lt;&lt; F-&gt;<a class="code hl_variable" href="../../d2/d2c/structtower.html#a3ebb75c13c57d51a8a1ba1ea54a515e9">values</a>[i] &lt;&lt; <span class="stringliteral">&quot;\t&quot;</span>;</div>
<div class="line"><span class="lineno"> 24</span> }</div>
<div class="line"><span class="lineno"> 25</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;\n\tU : &quot;</span>;</div>
<div class="line"><span class="lineno"> 26</span> <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i &lt; U-&gt;<a class="code hl_variable" href="../../d2/d2c/structtower.html#acb535964abd34c47678a4ade0628223d">top</a>; i++) {</div>
<div class="line"><span class="lineno"> 27</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/basic_ostream.html">std::cout</a> &lt;&lt; U-&gt;<a class="code hl_variable" href="../../d2/d2c/structtower.html#a3ebb75c13c57d51a8a1ba1ea54a515e9">values</a>[i] &lt;&lt; <span class="stringliteral">&quot;\t&quot;</span>;</div>
<div class="line"><span class="lineno"> 28</span> }</div>
<div class="line"><span class="lineno"> 29</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;\n\tT : &quot;</span>;</div>
<div class="line"><span class="lineno"> 30</span> <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i &lt; T-&gt;<a class="code hl_variable" href="../../d2/d2c/structtower.html#acb535964abd34c47678a4ade0628223d">top</a>; i++) {</div>
<div class="line"><span class="lineno"> 31</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/basic_ostream.html">std::cout</a> &lt;&lt; T-&gt;<a class="code hl_variable" href="../../d2/d2c/structtower.html#a3ebb75c13c57d51a8a1ba1ea54a515e9">values</a>[i] &lt;&lt; <span class="stringliteral">&quot;\t&quot;</span>;</div>
<div class="line"><span class="lineno"> 32</span> }</div>
<div class="line"><span class="lineno"> 33</span>}</div>
</div><!-- fragment -->
</div>
</div>
@@ -314,17 +314,17 @@ Here is the call graph for this function:</div>
</table>
</dd>
</dl>
<div class="fragment"><div class="line"><a id="l00052" name="l00052"></a><span class="lineno"> 52</span> {</div>
<div class="line"><a id="l00053" name="l00053"></a><span class="lineno"> 53</span> <span class="keywordflow">if</span> (n == 1) {</div>
<div class="line"><a id="l00054" name="l00054"></a><span class="lineno"> 54</span> <a class="code hl_function" href="../../db/d3c/tower__of__hanoi_8cpp.html#af4cfc41e546f1f8d25f01e0804e8b61d">mov</a>(From, To);</div>
<div class="line"><a id="l00055" name="l00055"></a><span class="lineno"> 55</span> <a class="code hl_function" href="../../db/d3c/tower__of__hanoi_8cpp.html#a746d9a3984bba88fd6dd91978f6931ed">show</a>(From, To, Using);</div>
<div class="line"><a id="l00056" name="l00056"></a><span class="lineno"> 56</span> } <span class="keywordflow">else</span> {</div>
<div class="line"><a id="l00057" name="l00057"></a><span class="lineno"> 57</span> <a class="code hl_function" href="../../db/d3c/tower__of__hanoi_8cpp.html#ab037f72a5eac476535a6cfbbcb965417">TH</a>(n - 1, From, To, Using);</div>
<div class="line"><a id="l00058" name="l00058"></a><span class="lineno"> 58</span> <a class="code hl_function" href="../../db/d3c/tower__of__hanoi_8cpp.html#af4cfc41e546f1f8d25f01e0804e8b61d">mov</a>(From, To);</div>
<div class="line"><a id="l00059" name="l00059"></a><span class="lineno"> 59</span> <a class="code hl_function" href="../../db/d3c/tower__of__hanoi_8cpp.html#a746d9a3984bba88fd6dd91978f6931ed">show</a>(From, To, Using);</div>
<div class="line"><a id="l00060" name="l00060"></a><span class="lineno"> 60</span> <a class="code hl_function" href="../../db/d3c/tower__of__hanoi_8cpp.html#ab037f72a5eac476535a6cfbbcb965417">TH</a>(n - 1, Using, From, To);</div>
<div class="line"><a id="l00061" name="l00061"></a><span class="lineno"> 61</span> }</div>
<div class="line"><a id="l00062" name="l00062"></a><span class="lineno"> 62</span>}</div>
<div class="fragment"><div class="line"><span class="lineno"> 52</span> {</div>
<div class="line"><span class="lineno"> 53</span> <span class="keywordflow">if</span> (n == 1) {</div>
<div class="line"><span class="lineno"> 54</span> <a class="code hl_function" href="../../db/d3c/tower__of__hanoi_8cpp.html#af4cfc41e546f1f8d25f01e0804e8b61d">mov</a>(From, To);</div>
<div class="line"><span class="lineno"> 55</span> <a class="code hl_function" href="../../db/d3c/tower__of__hanoi_8cpp.html#a746d9a3984bba88fd6dd91978f6931ed">show</a>(From, To, Using);</div>
<div class="line"><span class="lineno"> 56</span> } <span class="keywordflow">else</span> {</div>
<div class="line"><span class="lineno"> 57</span> <a class="code hl_function" href="../../db/d3c/tower__of__hanoi_8cpp.html#ab037f72a5eac476535a6cfbbcb965417">TH</a>(n - 1, From, To, Using);</div>
<div class="line"><span class="lineno"> 58</span> <a class="code hl_function" href="../../db/d3c/tower__of__hanoi_8cpp.html#af4cfc41e546f1f8d25f01e0804e8b61d">mov</a>(From, To);</div>
<div class="line"><span class="lineno"> 59</span> <a class="code hl_function" href="../../db/d3c/tower__of__hanoi_8cpp.html#a746d9a3984bba88fd6dd91978f6931ed">show</a>(From, To, Using);</div>
<div class="line"><span class="lineno"> 60</span> <a class="code hl_function" href="../../db/d3c/tower__of__hanoi_8cpp.html#ab037f72a5eac476535a6cfbbcb965417">TH</a>(n - 1, Using, From, To);</div>
<div class="line"><span class="lineno"> 61</span> }</div>
<div class="line"><span class="lineno"> 62</span>}</div>
<div class="ttc" id="atower__of__hanoi_8cpp_html_af4cfc41e546f1f8d25f01e0804e8b61d"><div class="ttname"><a href="../../db/d3c/tower__of__hanoi_8cpp.html#af4cfc41e546f1f8d25f01e0804e8b61d">mov</a></div><div class="ttdeci">void mov(tower *From, tower *To)</div><div class="ttdef"><b>Definition:</b> tower_of_hanoi.cpp:39</div></div>
</div><!-- fragment --><div class="dynheader">
Here is the call graph for this function:</div>
@@ -341,7 +341,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_9510827d0b234b3cc54b29892f217477.html">others</a></li><li class="navelem"><a class="el" href="../../db/d3c/tower__of__hanoi_8cpp.html">tower_of_hanoi.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>

View File

@@ -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++: sorting/wave_sort.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">&#160;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&amp;dn=expat.txt MIT */
var searchBox = new SearchBox("searchBox", "../../search",'Search','.html');
@@ -154,10 +154,10 @@ Functions</h2></td></tr>
<p>Main function. </p>
<dl class="section return"><dt>Returns</dt><dd>0 on exit </dd></dl>
<div class="fragment"><div class="line"><a id="l00091" name="l00091"></a><span class="lineno"> 91</span> {</div>
<div class="line"><a id="l00092" name="l00092"></a><span class="lineno"> 92</span> <a class="code hl_function" href="../../db/d3f/wave__sort_8cpp.html#aa8dca7b867074164d5f45b0f3851269d">test</a>(); <span class="comment">// run self-test implementations</span></div>
<div class="line"><a id="l00093" name="l00093"></a><span class="lineno"> 93</span> <span class="keywordflow">return</span> 0;</div>
<div class="line"><a id="l00094" name="l00094"></a><span class="lineno"> 94</span>}</div>
<div class="fragment"><div class="line"><span class="lineno"> 91</span> {</div>
<div class="line"><span class="lineno"> 92</span> <a class="code hl_function" href="../../db/d3f/wave__sort_8cpp.html#aa8dca7b867074164d5f45b0f3851269d">test</a>(); <span class="comment">// run self-test implementations</span></div>
<div class="line"><span class="lineno"> 93</span> <span class="keywordflow">return</span> 0;</div>
<div class="line"><span class="lineno"> 94</span>}</div>
<div class="ttc" id="awave__sort_8cpp_html_aa8dca7b867074164d5f45b0f3851269d"><div class="ttname"><a href="../../db/d3f/wave__sort_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> wave_sort.cpp:53</div></div>
</div><!-- fragment --><div class="dynheader">
Here is the call graph for this function:</div>
@@ -193,42 +193,42 @@ Here is the call graph for this function:</div>
<p>Self-test implementations. </p>
<dl class="section return"><dt>Returns</dt><dd>void </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> <span class="comment">// [10, 90, 49, 2, 1, 5, 23] return [2, 1, 10, 5, 49, 23, 90]</span></div>
<div class="line"><a id="l00055" name="l00055"></a><span class="lineno"> 55</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector&lt;int64_t&gt;</a> array1 = {10, 90, 49, 2, 1, 5, 23};</div>
<div class="line"><a id="l00056" name="l00056"></a><span class="lineno"> 56</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;Test 1... &quot;</span>;</div>
<div class="line"><a id="l00057" name="l00057"></a><span class="lineno"> 57</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector&lt;int64_t&gt;</a> arr1 = <a class="code hl_function" href="../../db/d3f/wave__sort_8cpp.html#a7d4f243b9dc13ace4ef77e30dbc56f12">sorting::wave_sort::waveSort</a>(array1, 7);</div>
<div class="line"><a id="l00058" name="l00058"></a><span class="lineno"> 58</span> <span class="keyword">const</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector&lt;int64_t&gt;</a> o1 = {2, 1, 10, 5, 49, 23, 90};</div>
<div class="line"><a id="l00059" name="l00059"></a><span class="lineno"> 59</span> assert(arr1 == o1);</div>
<div class="line"><a id="l00060" name="l00060"></a><span class="lineno"> 60</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;passed&quot;</span> &lt;&lt; <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="l00061" name="l00061"></a><span class="lineno"> 61</span> </div>
<div class="line"><a id="l00062" name="l00062"></a><span class="lineno"> 62</span> <span class="comment">// [1, 3, 4, 2, 7, 8] return [2, 1, 4, 3, 8, 7]</span></div>
<div class="line"><a id="l00063" name="l00063"></a><span class="lineno"> 63</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector&lt;int64_t&gt;</a> array2 = {1, 3, 4, 2, 7, 8};</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/io/basic_ostream.html">std::cout</a> &lt;&lt; <span class="stringliteral">&quot;Test 2... &quot;</span>;</div>
<div class="line"><a id="l00065" name="l00065"></a><span class="lineno"> 65</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector&lt;int64_t&gt;</a> arr2 = <a class="code hl_function" href="../../db/d3f/wave__sort_8cpp.html#a7d4f243b9dc13ace4ef77e30dbc56f12">sorting::wave_sort::waveSort</a>(array2, 6);</div>
<div class="line"><a id="l00066" name="l00066"></a><span class="lineno"> 66</span> <span class="keyword">const</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector&lt;int64_t&gt;</a> o2 = {2, 1, 4, 3, 8, 7};</div>
<div class="line"><a id="l00067" name="l00067"></a><span class="lineno"> 67</span> assert(arr2 == o2);</div>
<div class="line"><a id="l00068" name="l00068"></a><span class="lineno"> 68</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;passed&quot;</span> &lt;&lt; <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="l00069" name="l00069"></a><span class="lineno"> 69</span> </div>
<div class="line"><a id="l00070" name="l00070"></a><span class="lineno"> 70</span> <span class="comment">// [3, 3, 3, 3] return [3, 3, 3, 3]</span></div>
<div class="line"><a id="l00071" name="l00071"></a><span class="lineno"> 71</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector&lt;int64_t&gt;</a> array3 = {3, 3, 3, 3};</div>
<div class="line"><a id="l00072" name="l00072"></a><span class="lineno"> 72</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;Test 3... &quot;</span>;</div>
<div class="line"><a id="l00073" name="l00073"></a><span class="lineno"> 73</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector&lt;int64_t&gt;</a> arr3 = <a class="code hl_function" href="../../db/d3f/wave__sort_8cpp.html#a7d4f243b9dc13ace4ef77e30dbc56f12">sorting::wave_sort::waveSort</a>(array3, 4);</div>
<div class="line"><a id="l00074" name="l00074"></a><span class="lineno"> 74</span> <span class="keyword">const</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector&lt;int64_t&gt;</a> o3 = {3, 3, 3, 3};</div>
<div class="line"><a id="l00075" name="l00075"></a><span class="lineno"> 75</span> assert(arr3 == o3);</div>
<div class="line"><a id="l00076" name="l00076"></a><span class="lineno"> 76</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;passed&quot;</span> &lt;&lt; <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="l00077" name="l00077"></a><span class="lineno"> 77</span> </div>
<div class="line"><a id="l00078" name="l00078"></a><span class="lineno"> 78</span> <span class="comment">// [9, 4, 6, 8, 14, 3] return [4, 3, 8, 6, 14, 9]</span></div>
<div class="line"><a id="l00079" name="l00079"></a><span class="lineno"> 79</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector&lt;int64_t&gt;</a> array4 = {9, 4, 6, 8, 14, 3};</div>
<div class="line"><a id="l00080" name="l00080"></a><span class="lineno"> 80</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;Test 4... &quot;</span>;</div>
<div class="line"><a id="l00081" name="l00081"></a><span class="lineno"> 81</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector&lt;int64_t&gt;</a> arr4 = <a class="code hl_function" href="../../db/d3f/wave__sort_8cpp.html#a7d4f243b9dc13ace4ef77e30dbc56f12">sorting::wave_sort::waveSort</a>(array4, 6);</div>
<div class="line"><a id="l00082" name="l00082"></a><span class="lineno"> 82</span> <span class="keyword">const</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector&lt;int64_t&gt;</a> o4 = {4, 3, 8, 6, 14, 9};</div>
<div class="line"><a id="l00083" name="l00083"></a><span class="lineno"> 83</span> assert(arr4 == o4);</div>
<div class="line"><a id="l00084" name="l00084"></a><span class="lineno"> 84</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;passed&quot;</span> &lt;&lt; <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="l00085" name="l00085"></a><span class="lineno"> 85</span>}</div>
<div class="fragment"><div class="line"><span class="lineno"> 53</span> {</div>
<div class="line"><span class="lineno"> 54</span> <span class="comment">// [10, 90, 49, 2, 1, 5, 23] return [2, 1, 10, 5, 49, 23, 90]</span></div>
<div class="line"><span class="lineno"> 55</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector&lt;int64_t&gt;</a> array1 = {10, 90, 49, 2, 1, 5, 23};</div>
<div class="line"><span class="lineno"> 56</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;Test 1... &quot;</span>;</div>
<div class="line"><span class="lineno"> 57</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector&lt;int64_t&gt;</a> arr1 = <a class="code hl_function" href="../../db/d3f/wave__sort_8cpp.html#a7d4f243b9dc13ace4ef77e30dbc56f12">sorting::wave_sort::waveSort</a>(array1, 7);</div>
<div class="line"><span class="lineno"> 58</span> <span class="keyword">const</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector&lt;int64_t&gt;</a> o1 = {2, 1, 10, 5, 49, 23, 90};</div>
<div class="line"><span class="lineno"> 59</span> assert(arr1 == o1);</div>
<div class="line"><span class="lineno"> 60</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;passed&quot;</span> &lt;&lt; <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"> 61</span> </div>
<div class="line"><span class="lineno"> 62</span> <span class="comment">// [1, 3, 4, 2, 7, 8] return [2, 1, 4, 3, 8, 7]</span></div>
<div class="line"><span class="lineno"> 63</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector&lt;int64_t&gt;</a> array2 = {1, 3, 4, 2, 7, 8};</div>
<div class="line"><span class="lineno"> 64</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;Test 2... &quot;</span>;</div>
<div class="line"><span class="lineno"> 65</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector&lt;int64_t&gt;</a> arr2 = <a class="code hl_function" href="../../db/d3f/wave__sort_8cpp.html#a7d4f243b9dc13ace4ef77e30dbc56f12">sorting::wave_sort::waveSort</a>(array2, 6);</div>
<div class="line"><span class="lineno"> 66</span> <span class="keyword">const</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector&lt;int64_t&gt;</a> o2 = {2, 1, 4, 3, 8, 7};</div>
<div class="line"><span class="lineno"> 67</span> assert(arr2 == o2);</div>
<div class="line"><span class="lineno"> 68</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;passed&quot;</span> &lt;&lt; <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"> 69</span> </div>
<div class="line"><span class="lineno"> 70</span> <span class="comment">// [3, 3, 3, 3] return [3, 3, 3, 3]</span></div>
<div class="line"><span class="lineno"> 71</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector&lt;int64_t&gt;</a> array3 = {3, 3, 3, 3};</div>
<div class="line"><span class="lineno"> 72</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;Test 3... &quot;</span>;</div>
<div class="line"><span class="lineno"> 73</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector&lt;int64_t&gt;</a> arr3 = <a class="code hl_function" href="../../db/d3f/wave__sort_8cpp.html#a7d4f243b9dc13ace4ef77e30dbc56f12">sorting::wave_sort::waveSort</a>(array3, 4);</div>
<div class="line"><span class="lineno"> 74</span> <span class="keyword">const</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector&lt;int64_t&gt;</a> o3 = {3, 3, 3, 3};</div>
<div class="line"><span class="lineno"> 75</span> assert(arr3 == o3);</div>
<div class="line"><span class="lineno"> 76</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;passed&quot;</span> &lt;&lt; <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"> 77</span> </div>
<div class="line"><span class="lineno"> 78</span> <span class="comment">// [9, 4, 6, 8, 14, 3] return [4, 3, 8, 6, 14, 9]</span></div>
<div class="line"><span class="lineno"> 79</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector&lt;int64_t&gt;</a> array4 = {9, 4, 6, 8, 14, 3};</div>
<div class="line"><span class="lineno"> 80</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;Test 4... &quot;</span>;</div>
<div class="line"><span class="lineno"> 81</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector&lt;int64_t&gt;</a> arr4 = <a class="code hl_function" href="../../db/d3f/wave__sort_8cpp.html#a7d4f243b9dc13ace4ef77e30dbc56f12">sorting::wave_sort::waveSort</a>(array4, 6);</div>
<div class="line"><span class="lineno"> 82</span> <span class="keyword">const</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector&lt;int64_t&gt;</a> o4 = {4, 3, 8, 6, 14, 9};</div>
<div class="line"><span class="lineno"> 83</span> assert(arr4 == o4);</div>
<div class="line"><span class="lineno"> 84</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;passed&quot;</span> &lt;&lt; <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"> 85</span>}</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="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="avector_html"><div class="ttname"><a href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector</a></div></div>
<div class="ttc" id="avector_html"><div class="ttname"><a href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector&lt; int64_t &gt;</a></div></div>
<div class="ttc" id="awave__sort_8cpp_html_a7d4f243b9dc13ace4ef77e30dbc56f12"><div class="ttname"><a href="../../db/d3f/wave__sort_8cpp.html#a7d4f243b9dc13ace4ef77e30dbc56f12">sorting::wave_sort::waveSort</a></div><div class="ttdeci">std::vector&lt; T &gt; waveSort(const std::vector&lt; T &gt; &amp;in_arr, int64_t n)</div><div class="ttdoc">The main function implements that implements the Wave Sort algorithm.</div><div class="ttdef"><b>Definition:</b> wave_sort.cpp:34</div></div>
</div><!-- fragment --><div class="dynheader">
Here is the call graph for this function:</div>
@@ -281,18 +281,18 @@ template&lt;typename T &gt; </div>
</dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>arr the wave sorted array </dd></dl>
<div class="fragment"><div class="line"><a id="l00034" name="l00034"></a><span class="lineno"> 34</span> {</div>
<div class="line"><a id="l00035" name="l00035"></a><span class="lineno"> 35</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector&lt;T&gt;</a> arr(in_arr);</div>
<div class="line"><a id="l00036" name="l00036"></a><span class="lineno"> 36</span> </div>
<div class="line"><a id="l00037" name="l00037"></a><span class="lineno"> 37</span> <span class="keywordflow">for</span> (int64_t i = 0; i &lt; n; i++) {</div>
<div class="line"><a id="l00038" name="l00038"></a><span class="lineno"> 38</span> arr[i] = in_arr[i];</div>
<div class="line"><a id="l00039" name="l00039"></a><span class="lineno"> 39</span> }</div>
<div class="line"><a id="l00040" name="l00040"></a><span class="lineno"> 40</span> <a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/algorithm/sort.html">std::sort</a>(arr.begin(), arr.end());</div>
<div class="line"><a id="l00041" name="l00041"></a><span class="lineno"> 41</span> <span class="keywordflow">for</span> (int64_t i = 0; i &lt; n - 1; i += 2) { <span class="comment">// swap all the adjacent elements</span></div>
<div class="line"><a id="l00042" name="l00042"></a><span class="lineno"> 42</span> <a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/algorithm/swap.html">std::swap</a>(arr[i], arr[i + 1]);</div>
<div class="line"><a id="l00043" name="l00043"></a><span class="lineno"> 43</span> }</div>
<div class="line"><a id="l00044" name="l00044"></a><span class="lineno"> 44</span> <span class="keywordflow">return</span> arr;</div>
<div class="line"><a id="l00045" name="l00045"></a><span class="lineno"> 45</span>}</div>
<div class="fragment"><div class="line"><span class="lineno"> 34</span> {</div>
<div class="line"><span class="lineno"> 35</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector&lt;T&gt;</a> arr(in_arr);</div>
<div class="line"><span class="lineno"> 36</span> </div>
<div class="line"><span class="lineno"> 37</span> <span class="keywordflow">for</span> (int64_t i = 0; i &lt; n; i++) {</div>
<div class="line"><span class="lineno"> 38</span> arr[i] = in_arr[i];</div>
<div class="line"><span class="lineno"> 39</span> }</div>
<div class="line"><span class="lineno"> 40</span> <a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/algorithm/sort.html">std::sort</a>(arr.begin(), arr.end());</div>
<div class="line"><span class="lineno"> 41</span> <span class="keywordflow">for</span> (int64_t i = 0; i &lt; n - 1; i += 2) { <span class="comment">// swap all the adjacent elements</span></div>
<div class="line"><span class="lineno"> 42</span> <a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/algorithm/swap.html">std::swap</a>(arr[i], arr[i + 1]);</div>
<div class="line"><span class="lineno"> 43</span> }</div>
<div class="line"><span class="lineno"> 44</span> <span class="keywordflow">return</span> arr;</div>
<div class="line"><span class="lineno"> 45</span>}</div>
<div class="ttc" id="asort_html"><div class="ttname"><a href="http://en.cppreference.com/w/cpp/algorithm/sort.html">std::sort</a></div><div class="ttdeci">T sort(T... args)</div></div>
<div class="ttc" id="aswap_html"><div class="ttname"><a href="http://en.cppreference.com/w/cpp/algorithm/swap.html">std::swap</a></div><div class="ttdeci">T swap(T... args)</div></div>
</div><!-- fragment --><div class="dynheader">
@@ -310,7 +310,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_bb1b521853a9c46347182a9d10420771.html">sorting</a></li><li class="navelem"><a class="el" href="../../db/d3f/wave__sort_8cpp.html">wave_sort.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>

View File

@@ -1,7 +1,7 @@
<map id="sorting::wave_sort::waveSort" name="sorting::wave_sort::waveSort">
<area shape="rect" id="node1" title="The main function implements that implements the Wave Sort algorithm." alt="" coords="5,74,135,115"/>
<area shape="rect" id="node2" href="/Users/runner/work/C-Plus-Plus/C-Plus-Plus/doc/cppreference-doxygen-web.tag.xml$cpp/container/vector/begin.html#" title=" " alt="" coords="183,5,305,32"/>
<area shape="rect" id="node3" href="/Users/runner/work/C-Plus-Plus/C-Plus-Plus/doc/cppreference-doxygen-web.tag.xml$cpp/container/vector/end.html#" title=" " alt="" coords="187,56,301,83"/>
<area shape="rect" id="node4" href="/Users/runner/work/C-Plus-Plus/C-Plus-Plus/doc/cppreference-doxygen-web.tag.xml$cpp/algorithm/sort.html#" title=" " alt="" coords="209,107,279,133"/>
<area shape="rect" id="node5" href="/Users/runner/work/C-Plus-Plus/C-Plus-Plus/doc/cppreference-doxygen-web.tag.xml$cpp/algorithm/swap.html#" title=" " alt="" coords="205,157,283,184"/>
<area shape="rect" id="node2" href="/Users/runner/work/C-Plus-Plus/C-Plus-Plus/doc/cppreference-doxygen-web.tag.xml$cpp/container/vector/begin#" title=" " alt="" coords="183,5,305,32"/>
<area shape="rect" id="node3" href="/Users/runner/work/C-Plus-Plus/C-Plus-Plus/doc/cppreference-doxygen-web.tag.xml$cpp/container/vector/end#" title=" " alt="" coords="187,56,301,83"/>
<area shape="rect" id="node4" href="/Users/runner/work/C-Plus-Plus/C-Plus-Plus/doc/cppreference-doxygen-web.tag.xml$cpp/algorithm/sort#" title=" " alt="" coords="209,107,279,133"/>
<area shape="rect" id="node5" href="/Users/runner/work/C-Plus-Plus/C-Plus-Plus/doc/cppreference-doxygen-web.tag.xml$cpp/algorithm/swap#" title=" " alt="" coords="205,157,283,184"/>
</map>

View File

@@ -1 +1 @@
6929d064a9481d143e44c949ce54ab0e
bcdcc752be9236c745b2a3cdd3c1b143

View File

@@ -28,7 +28,7 @@
<!-- Node2 -->
<g id="node2" class="node">
<title>Node2</title>
<g id="a_node2"><a target="_blank" xlink:href="http://en.cppreference.com/w/cpp/container/vector/begin.html#" xlink:title=" ">
<g id="a_node2"><a target="_blank" xlink:href="http://en.cppreference.com/w/cpp/container/vector/begin#" xlink:title=" ">
<polygon fill="white" stroke="black" points="133,-114.5 133,-133.5 225,-133.5 225,-114.5 133,-114.5"/>
<text text-anchor="middle" x="179" y="-121.5" font-family="Helvetica,sans-Serif" font-size="10.00">std::vector::begin</text>
</a>
@@ -43,7 +43,7 @@
<!-- Node3 -->
<g id="node3" class="node">
<title>Node3</title>
<g id="a_node3"><a target="_blank" xlink:href="http://en.cppreference.com/w/cpp/container/vector/end.html#" xlink:title=" ">
<g id="a_node3"><a target="_blank" xlink:href="http://en.cppreference.com/w/cpp/container/vector/end#" xlink:title=" ">
<polygon fill="white" stroke="black" points="136.5,-76.5 136.5,-95.5 221.5,-95.5 221.5,-76.5 136.5,-76.5"/>
<text text-anchor="middle" x="179" y="-83.5" font-family="Helvetica,sans-Serif" font-size="10.00">std::vector::end</text>
</a>
@@ -58,7 +58,7 @@
<!-- Node4 -->
<g id="node4" class="node">
<title>Node4</title>
<g id="a_node4"><a target="_blank" xlink:href="http://en.cppreference.com/w/cpp/algorithm/sort.html#" xlink:title=" ">
<g id="a_node4"><a target="_blank" xlink:href="http://en.cppreference.com/w/cpp/algorithm/sort#" xlink:title=" ">
<polygon fill="white" stroke="black" points="152.5,-38.5 152.5,-57.5 205.5,-57.5 205.5,-38.5 152.5,-38.5"/>
<text text-anchor="middle" x="179" y="-45.5" font-family="Helvetica,sans-Serif" font-size="10.00">std::sort</text>
</a>
@@ -73,7 +73,7 @@
<!-- Node5 -->
<g id="node5" class="node">
<title>Node5</title>
<g id="a_node5"><a target="_blank" xlink:href="http://en.cppreference.com/w/cpp/algorithm/swap.html#" xlink:title=" ">
<g id="a_node5"><a target="_blank" xlink:href="http://en.cppreference.com/w/cpp/algorithm/swap#" xlink:title=" ">
<polygon fill="white" stroke="black" points="149.5,-0.5 149.5,-19.5 208.5,-19.5 208.5,-0.5 149.5,-0.5"/>
<text text-anchor="middle" x="179" y="-7.5" font-family="Helvetica,sans-Serif" font-size="10.00">std::swap</text>
</a>

Before

Width:  |  Height:  |  Size: 4.4 KiB

After

Width:  |  Height:  |  Size: 4.4 KiB

View File

@@ -1,4 +1,4 @@
<map id="test" name="test">
<area shape="rect" id="node1" title="Self&#45;test implementations." alt="" coords="5,5,49,32"/>
<area shape="rect" id="node2" href="/Users/runner/work/C-Plus-Plus/C-Plus-Plus/doc/cppreference-doxygen-web.tag.xml$cpp/io/manip/endl.html#" title=" " alt="" coords="97,5,169,32"/>
<area shape="rect" id="node2" href="/Users/runner/work/C-Plus-Plus/C-Plus-Plus/doc/cppreference-doxygen-web.tag.xml$cpp/io/manip/endl#" title=" " alt="" coords="97,5,169,32"/>
</map>

View File

@@ -1 +1 @@
e183666d54c346b35c418105d98411c7
b0dc874831a2dd2acf585064047c8738

View File

@@ -21,7 +21,7 @@
<!-- Node2 -->
<g id="node2" class="node">
<title>Node2</title>
<g id="a_node2"><a target="_blank" xlink:href="http://en.cppreference.com/w/cpp/io/manip/endl.html#" xlink:title=" ">
<g id="a_node2"><a target="_blank" xlink:href="http://en.cppreference.com/w/cpp/io/manip/endl#" xlink:title=" ">
<polygon fill="white" stroke="black" points="69,-0.5 69,-19.5 123,-19.5 123,-0.5 69,-0.5"/>
<text text-anchor="middle" x="96" y="-7.5" font-family="Helvetica,sans-Serif" font-size="10.00">std::endl</text>
</a>

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 1.6 KiB

View File

@@ -1,5 +1,5 @@
<map id="main" name="main">
<area shape="rect" id="node1" title="Main function." alt="" coords="5,5,56,32"/>
<area shape="rect" id="node2" href="$db/d3f/wave__sort_8cpp.html#aa8dca7b867074164d5f45b0f3851269d" title="Self&#45;test implementations." alt="" coords="104,5,148,32"/>
<area shape="rect" id="node3" href="/Users/runner/work/C-Plus-Plus/C-Plus-Plus/doc/cppreference-doxygen-web.tag.xml$cpp/io/manip/endl.html#" title=" " alt="" coords="196,5,268,32"/>
<area shape="rect" id="node3" href="/Users/runner/work/C-Plus-Plus/C-Plus-Plus/doc/cppreference-doxygen-web.tag.xml$cpp/io/manip/endl#" title=" " alt="" coords="196,5,268,32"/>
</map>

View File

@@ -1 +1 @@
2cedd1010f61591cd1dc7b83213d00c9
5db4afe9809e1f6f9774ca0b16b50da3

View File

@@ -36,7 +36,7 @@
<!-- Node3 -->
<g id="node3" class="node">
<title>Node3</title>
<g id="a_node3"><a target="_blank" xlink:href="http://en.cppreference.com/w/cpp/io/manip/endl.html#" xlink:title=" ">
<g id="a_node3"><a target="_blank" xlink:href="http://en.cppreference.com/w/cpp/io/manip/endl#" xlink:title=" ">
<polygon fill="white" stroke="black" points="143,-0.5 143,-19.5 197,-19.5 197,-0.5 143,-0.5"/>
<text text-anchor="middle" x="170" y="-7.5" font-family="Helvetica,sans-Serif" font-size="10.00">std::endl</text>
</a>

Before

Width:  |  Height:  |  Size: 2.3 KiB

After

Width:  |  Height:  |  Size: 2.3 KiB

View File

@@ -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++: math/integral_approximation2.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">&#160;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&amp;dn=expat.txt MIT */
var searchBox = new SearchBox("searchBox", "../../search",'Search','.html');
@@ -201,36 +201,36 @@ Functions</h2></td></tr>
</dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>A vector of size num_samples with samples distributed according to the pdf </dd></dl>
<div class="fragment"><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> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector&lt;double&gt;</a> samples;</div>
<div class="line"><a id="l00069" name="l00069"></a><span class="lineno"> 69</span> samples.<a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector/reserve.html">reserve</a>(num_samples);</div>
<div class="line"><a id="l00070" name="l00070"></a><span class="lineno"> 70</span> </div>
<div class="line"><a id="l00071" name="l00071"></a><span class="lineno"> 71</span> <span class="keywordtype">double</span> x_t = start_point;</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> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/numeric/random.html">std::default_random_engine</a> generator;</div>
<div class="line"><a id="l00074" name="l00074"></a><span class="lineno"> 74</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/numeric/random/uniform_real_distribution.html">std::uniform_real_distribution&lt;double&gt;</a> uniform(0.0, 1.0);</div>
<div class="line"><a id="l00075" name="l00075"></a><span class="lineno"> 75</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/numeric/random/normal_distribution.html">std::normal_distribution&lt;double&gt;</a> normal(0.0, 1.0);</div>
<div class="line"><a id="l00076" name="l00076"></a><span class="lineno"> 76</span> generator.seed(<a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/chrono/c/time.html">time</a>(<span class="keyword">nullptr</span>));</div>
<div class="line"><a id="l00077" name="l00077"></a><span class="lineno"> 77</span> </div>
<div class="line"><a id="l00078" name="l00078"></a><span class="lineno"> 78</span> <span class="keywordflow">for</span> (uint32_t t = 0; t &lt; num_samples + discard; ++t) {</div>
<div class="line"><a id="l00079" name="l00079"></a><span class="lineno"> 79</span> <span class="comment">// Generate a new proposal according to some mutation strategy.</span></div>
<div class="line"><a id="l00080" name="l00080"></a><span class="lineno"> 80</span> <span class="comment">// This is arbitrary and can be swapped.</span></div>
<div class="line"><a id="l00081" name="l00081"></a><span class="lineno"> 81</span> <span class="keywordtype">double</span> x_dash = normal(generator) + x_t;</div>
<div class="line"><a id="l00082" name="l00082"></a><span class="lineno"> 82</span> <span class="keywordtype">double</span> acceptance_probability = <a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/algorithm/min.html">std::min</a>(pdf(x_dash) / pdf(x_t), 1.0);</div>
<div class="line"><a id="l00083" name="l00083"></a><span class="lineno"> 83</span> <span class="keywordtype">double</span> u = uniform(generator);</div>
<div class="line"><a id="l00084" name="l00084"></a><span class="lineno"> 84</span> </div>
<div class="line"><a id="l00085" name="l00085"></a><span class="lineno"> 85</span> <span class="comment">// Accept &quot;new state&quot; according to the acceptance_probability</span></div>
<div class="line"><a id="l00086" name="l00086"></a><span class="lineno"> 86</span> <span class="keywordflow">if</span> (u &lt;= acceptance_probability) {</div>
<div class="line"><a id="l00087" name="l00087"></a><span class="lineno"> 87</span> x_t = x_dash;</div>
<div class="line"><a id="l00088" name="l00088"></a><span class="lineno"> 88</span> }</div>
<div class="line"><a id="l00089" name="l00089"></a><span class="lineno"> 89</span> </div>
<div class="line"><a id="l00090" name="l00090"></a><span class="lineno"> 90</span> <span class="keywordflow">if</span> (t &gt;= discard) {</div>
<div class="line"><a id="l00091" name="l00091"></a><span class="lineno"> 91</span> samples.<a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector/push_back.html">push_back</a>(x_t);</div>
<div class="line"><a id="l00092" name="l00092"></a><span class="lineno"> 92</span> }</div>
<div class="line"><a id="l00093" name="l00093"></a><span class="lineno"> 93</span> }</div>
<div class="line"><a id="l00094" name="l00094"></a><span class="lineno"> 94</span> </div>
<div class="line"><a id="l00095" name="l00095"></a><span class="lineno"> 95</span> <span class="keywordflow">return</span> samples;</div>
<div class="line"><a id="l00096" name="l00096"></a><span class="lineno"> 96</span>}</div>
<div class="fragment"><div class="line"><span class="lineno"> 67</span> {</div>
<div class="line"><span class="lineno"> 68</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector&lt;double&gt;</a> samples;</div>
<div class="line"><span class="lineno"> 69</span> samples.<a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector/reserve.html">reserve</a>(num_samples);</div>
<div class="line"><span class="lineno"> 70</span> </div>
<div class="line"><span class="lineno"> 71</span> <span class="keywordtype">double</span> x_t = start_point;</div>
<div class="line"><span class="lineno"> 72</span> </div>
<div class="line"><span class="lineno"> 73</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/numeric/random.html">std::default_random_engine</a> generator;</div>
<div class="line"><span class="lineno"> 74</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/numeric/random/uniform_real_distribution.html">std::uniform_real_distribution&lt;double&gt;</a> uniform(0.0, 1.0);</div>
<div class="line"><span class="lineno"> 75</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/numeric/random/normal_distribution.html">std::normal_distribution&lt;double&gt;</a> normal(0.0, 1.0);</div>
<div class="line"><span class="lineno"> 76</span> generator.seed(<a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/chrono/c/time.html">time</a>(<span class="keyword">nullptr</span>));</div>
<div class="line"><span class="lineno"> 77</span> </div>
<div class="line"><span class="lineno"> 78</span> <span class="keywordflow">for</span> (uint32_t t = 0; t &lt; num_samples + discard; ++t) {</div>
<div class="line"><span class="lineno"> 79</span> <span class="comment">// Generate a new proposal according to some mutation strategy.</span></div>
<div class="line"><span class="lineno"> 80</span> <span class="comment">// This is arbitrary and can be swapped.</span></div>
<div class="line"><span class="lineno"> 81</span> <span class="keywordtype">double</span> x_dash = normal(generator) + x_t;</div>
<div class="line"><span class="lineno"> 82</span> <span class="keywordtype">double</span> acceptance_probability = <a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/algorithm/min.html">std::min</a>(pdf(x_dash) / pdf(x_t), 1.0);</div>
<div class="line"><span class="lineno"> 83</span> <span class="keywordtype">double</span> u = uniform(generator);</div>
<div class="line"><span class="lineno"> 84</span> </div>
<div class="line"><span class="lineno"> 85</span> <span class="comment">// Accept &quot;new state&quot; according to the acceptance_probability</span></div>
<div class="line"><span class="lineno"> 86</span> <span class="keywordflow">if</span> (u &lt;= acceptance_probability) {</div>
<div class="line"><span class="lineno"> 87</span> x_t = x_dash;</div>
<div class="line"><span class="lineno"> 88</span> }</div>
<div class="line"><span class="lineno"> 89</span> </div>
<div class="line"><span class="lineno"> 90</span> <span class="keywordflow">if</span> (t &gt;= discard) {</div>
<div class="line"><span class="lineno"> 91</span> samples.<a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector/push_back.html">push_back</a>(x_t);</div>
<div class="line"><span class="lineno"> 92</span> }</div>
<div class="line"><span class="lineno"> 93</span> }</div>
<div class="line"><span class="lineno"> 94</span> </div>
<div class="line"><span class="lineno"> 95</span> <span class="keywordflow">return</span> samples;</div>
<div class="line"><span class="lineno"> 96</span>}</div>
<div class="ttc" id="amin_html"><div class="ttname"><a href="http://en.cppreference.com/w/cpp/algorithm/min.html">std::min</a></div><div class="ttdeci">T min(T... args)</div></div>
<div class="ttc" id="anormal_distribution_html"><div class="ttname"><a href="http://en.cppreference.com/w/cpp/numeric/random/normal_distribution.html">std::normal_distribution</a></div></div>
<div class="ttc" id="apush_back_html"><div class="ttname"><a href="http://en.cppreference.com/w/cpp/container/vector/push_back.html">std::vector::push_back</a></div><div class="ttdeci">T push_back(T... args)</div></div>
@@ -238,7 +238,7 @@ Functions</h2></td></tr>
<div class="ttc" id="areserve_html"><div class="ttname"><a href="http://en.cppreference.com/w/cpp/container/vector/reserve.html">std::vector::reserve</a></div><div class="ttdeci">T reserve(T... args)</div></div>
<div class="ttc" id="atime_html"><div class="ttname"><a href="http://en.cppreference.com/w/cpp/chrono/c/time.html">std::time</a></div><div class="ttdeci">T time(T... args)</div></div>
<div class="ttc" id="auniform_real_distribution_html"><div class="ttname"><a href="http://en.cppreference.com/w/cpp/numeric/random/uniform_real_distribution.html">std::uniform_real_distribution</a></div></div>
<div class="ttc" id="avector_html"><div class="ttname"><a href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector</a></div></div>
<div class="ttc" id="avector_html"><div class="ttname"><a href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector&lt; double &gt;</a></div></div>
</div><!-- fragment --><div class="dynheader">
Here is the call graph for this function:</div>
<div class="dyncontent">
@@ -297,17 +297,17 @@ Here is the call graph for this function:</div>
</dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>The approximation of the integral according to 1/N \sum_{i}^N f(x_i) / p(x_i) </dd></dl>
<div class="fragment"><div class="line"><a id="l00114" name="l00114"></a><span class="lineno"> 114</span> {</div>
<div class="line"><a id="l00115" name="l00115"></a><span class="lineno"> 115</span> <span class="keywordtype">double</span> integral = 0.0;</div>
<div class="line"><a id="l00116" name="l00116"></a><span class="lineno"> 116</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector&lt;double&gt;</a> samples =</div>
<div class="line"><a id="l00117" name="l00117"></a><span class="lineno"> 117</span> <a class="code hl_function" href="../../db/d40/integral__approximation2_8cpp.html#a71249ee535f16f8ed2e9cc8f0199a2cf">generate_samples</a>(start_point, pdf, num_samples);</div>
<div class="line"><a id="l00118" name="l00118"></a><span class="lineno"> 118</span> </div>
<div class="line"><a id="l00119" name="l00119"></a><span class="lineno"> 119</span> <span class="keywordflow">for</span> (<span class="keywordtype">double</span> sample : samples) {</div>
<div class="line"><a id="l00120" name="l00120"></a><span class="lineno"> 120</span> integral += <span class="keyword">function</span>(sample) / pdf(sample);</div>
<div class="line"><a id="l00121" name="l00121"></a><span class="lineno"> 121</span> }</div>
<div class="line"><a id="l00122" name="l00122"></a><span class="lineno"> 122</span> </div>
<div class="line"><a id="l00123" name="l00123"></a><span class="lineno"> 123</span> <span class="keywordflow">return</span> integral / <span class="keyword">static_cast&lt;</span><span class="keywordtype">double</span><span class="keyword">&gt;</span>(samples.size());</div>
<div class="line"><a id="l00124" name="l00124"></a><span class="lineno"> 124</span>}</div>
<div class="fragment"><div class="line"><span class="lineno"> 114</span> {</div>
<div class="line"><span class="lineno"> 115</span> <span class="keywordtype">double</span> integral = 0.0;</div>
<div class="line"><span class="lineno"> 116</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector&lt;double&gt;</a> samples =</div>
<div class="line"><span class="lineno"> 117</span> <a class="code hl_function" href="../../db/d40/integral__approximation2_8cpp.html#a71249ee535f16f8ed2e9cc8f0199a2cf">generate_samples</a>(start_point, pdf, num_samples);</div>
<div class="line"><span class="lineno"> 118</span> </div>
<div class="line"><span class="lineno"> 119</span> <span class="keywordflow">for</span> (<span class="keywordtype">double</span> sample : samples) {</div>
<div class="line"><span class="lineno"> 120</span> integral += function(sample) / pdf(sample);</div>
<div class="line"><span class="lineno"> 121</span> }</div>
<div class="line"><span class="lineno"> 122</span> </div>
<div class="line"><span class="lineno"> 123</span> <span class="keywordflow">return</span> integral / <span class="keyword">static_cast&lt;</span><span class="keywordtype">double</span><span class="keyword">&gt;</span>(samples.size());</div>
<div class="line"><span class="lineno"> 124</span>}</div>
<div class="ttc" id="aintegral__approximation2_8cpp_html_a71249ee535f16f8ed2e9cc8f0199a2cf"><div class="ttname"><a href="../../db/d40/integral__approximation2_8cpp.html#a71249ee535f16f8ed2e9cc8f0199a2cf">math::monte_carlo::generate_samples</a></div><div class="ttdeci">std::vector&lt; double &gt; generate_samples(const double &amp;start_point, const Function &amp;pdf, const uint32_t &amp;num_samples, const uint32_t &amp;discard=100000)</div><div class="ttdoc">short-hand for std::functions used in this implementation</div><div class="ttdef"><b>Definition:</b> integral_approximation2.cpp:64</div></div>
</div><!-- fragment --><div class="dynheader">
Here is the call graph for this function:</div>
@@ -336,10 +336,10 @@ Here is the call graph for this function:</div>
<p>Main function. </p>
<dl class="section return"><dt>Returns</dt><dd>0 on exit </dd></dl>
<div class="fragment"><div class="line"><a id="l00215" name="l00215"></a><span class="lineno"> 215</span> {</div>
<div class="line"><a id="l00216" name="l00216"></a><span class="lineno"> 216</span> <a class="code hl_function" href="../../db/d40/integral__approximation2_8cpp.html#aa8dca7b867074164d5f45b0f3851269d">test</a>(); <span class="comment">// run self-test implementations</span></div>
<div class="line"><a id="l00217" name="l00217"></a><span class="lineno"> 217</span> <span class="keywordflow">return</span> 0;</div>
<div class="line"><a id="l00218" name="l00218"></a><span class="lineno"> 218</span>}</div>
<div class="fragment"><div class="line"><span class="lineno"> 215</span> {</div>
<div class="line"><span class="lineno"> 216</span> <a class="code hl_function" href="../../db/d40/integral__approximation2_8cpp.html#aa8dca7b867074164d5f45b0f3851269d">test</a>(); <span class="comment">// run self-test implementations</span></div>
<div class="line"><span class="lineno"> 217</span> <span class="keywordflow">return</span> 0;</div>
<div class="line"><span class="lineno"> 218</span>}</div>
<div class="ttc" id="aintegral__approximation2_8cpp_html_aa8dca7b867074164d5f45b0f3851269d"><div class="ttname"><a href="../../db/d40/integral__approximation2_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> integral_approximation2.cpp:133</div></div>
</div><!-- fragment --><div class="dynheader">
Here is the call graph for this function:</div>
@@ -375,83 +375,83 @@ Here is the call graph for this function:</div>
<p>Self-test implementations. </p>
<dl class="section return"><dt>Returns</dt><dd>void </dd></dl>
<div class="fragment"><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> <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;Disclaimer: Because this is a randomized algorithm,&quot;</span></div>
<div class="line"><a id="l00135" name="l00135"></a><span class="lineno"> 135</span> &lt;&lt; <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="l00136" name="l00136"></a><span class="lineno"> 136</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/basic_ostream.html">std::cout</a></div>
<div class="line"><a id="l00137" name="l00137"></a><span class="lineno"> 137</span> &lt;&lt; <span class="stringliteral">&quot;it may happen that singular samples deviate from the true result.&quot;</span></div>
<div class="line"><a id="l00138" name="l00138"></a><span class="lineno"> 138</span> &lt;&lt; <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="l00139" name="l00139"></a><span class="lineno"> 139</span> &lt;&lt; <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> </div>
<div class="line"><a id="l00142" name="l00142"></a><span class="lineno"> 142</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/utility/functional/function.html">math::monte_carlo::Function</a> <a class="code hl_function" href="../../d4/d18/composite__simpson__rule_8cpp.html#a4251b4df4748a0b9c43a48f61bdd2397">f</a>;</div>
<div class="line"><a id="l00143" name="l00143"></a><span class="lineno"> 143</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/utility/functional/function.html">math::monte_carlo::Function</a> pdf;</div>
<div class="line"><a id="l00144" name="l00144"></a><span class="lineno"> 144</span> <span class="keywordtype">double</span> integral = 0;</div>
<div class="line"><a id="l00145" name="l00145"></a><span class="lineno"> 145</span> <span class="keywordtype">double</span> <a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/algorithm/lower_bound.html">lower_bound</a> = 0, <a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/algorithm/upper_bound.html">upper_bound</a> = 0;</div>
<div class="line"><a id="l00146" name="l00146"></a><span class="lineno"> 146</span> </div>
<div class="line"><a id="l00147" name="l00147"></a><span class="lineno"> 147</span> <span class="comment">/* \int_{-2}^{2} -x^2 + 4 dx */</span></div>
<div class="line"><a id="l00148" name="l00148"></a><span class="lineno"> 148</span> <a class="code hl_function" href="../../d4/d18/composite__simpson__rule_8cpp.html#a4251b4df4748a0b9c43a48f61bdd2397">f</a> = [&amp;](<span class="keywordtype">double</span>&amp; x) { <span class="keywordflow">return</span> -x * x + 4.0; };</div>
<div class="line"><a id="l00149" name="l00149"></a><span class="lineno"> 149</span> </div>
<div class="line"><a id="l00150" name="l00150"></a><span class="lineno"> 150</span> <a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/algorithm/lower_bound.html">lower_bound</a> = -2.0;</div>
<div class="line"><a id="l00151" name="l00151"></a><span class="lineno"> 151</span> <a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/algorithm/upper_bound.html">upper_bound</a> = 2.0;</div>
<div class="line"><a id="l00152" name="l00152"></a><span class="lineno"> 152</span> pdf = [&amp;](<span class="keywordtype">double</span>&amp; x) {</div>
<div class="line"><a id="l00153" name="l00153"></a><span class="lineno"> 153</span> <span class="keywordflow">if</span> (x &gt;= lower_bound &amp;&amp; x &lt;= -1.0) {</div>
<div class="line"><a id="l00154" name="l00154"></a><span class="lineno"> 154</span> <span class="keywordflow">return</span> 0.1;</div>
<div class="line"><a id="l00155" name="l00155"></a><span class="lineno"> 155</span> }</div>
<div class="line"><a id="l00156" name="l00156"></a><span class="lineno"> 156</span> <span class="keywordflow">if</span> (x &lt;= upper_bound &amp;&amp; x &gt;= 1.0) {</div>
<div class="line"><a id="l00157" name="l00157"></a><span class="lineno"> 157</span> <span class="keywordflow">return</span> 0.1;</div>
<div class="line"><a id="l00158" name="l00158"></a><span class="lineno"> 158</span> }</div>
<div class="line"><a id="l00159" name="l00159"></a><span class="lineno"> 159</span> <span class="keywordflow">if</span> (x &gt; -1.0 &amp;&amp; x &lt; 1.0) {</div>
<div class="line"><a id="l00160" name="l00160"></a><span class="lineno"> 160</span> <span class="keywordflow">return</span> 0.4;</div>
<div class="line"><a id="l00161" name="l00161"></a><span class="lineno"> 161</span> }</div>
<div class="line"><a id="l00162" name="l00162"></a><span class="lineno"> 162</span> <span class="keywordflow">return</span> 0.0;</div>
<div class="line"><a id="l00163" name="l00163"></a><span class="lineno"> 163</span> };</div>
<div class="line"><a id="l00164" name="l00164"></a><span class="lineno"> 164</span> </div>
<div class="line"><a id="l00165" name="l00165"></a><span class="lineno"> 165</span> integral = <a class="code hl_function" href="../../db/d40/integral__approximation2_8cpp.html#af7da9ba8932f1f48b9bbc2d80471af51">math::monte_carlo::integral_monte_carlo</a>(</div>
<div class="line"><a id="l00166" name="l00166"></a><span class="lineno"> 166</span> (upper_bound - lower_bound) / 2.0, f, pdf);</div>
<div class="line"><a id="l00167" name="l00167"></a><span class="lineno"> 167</span> </div>
<div class="line"><a id="l00168" name="l00168"></a><span class="lineno"> 168</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;This number should be close to 10.666666: &quot;</span> &lt;&lt; integral</div>
<div class="line"><a id="l00169" name="l00169"></a><span class="lineno"> 169</span> &lt;&lt; <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="l00170" name="l00170"></a><span class="lineno"> 170</span> </div>
<div class="line"><a id="l00171" name="l00171"></a><span class="lineno"> 171</span> <span class="comment">/* \int_{0}^{1} e^x dx */</span></div>
<div class="line"><a id="l00172" name="l00172"></a><span class="lineno"> 172</span> <a class="code hl_function" href="../../d4/d18/composite__simpson__rule_8cpp.html#a4251b4df4748a0b9c43a48f61bdd2397">f</a> = [&amp;](<span class="keywordtype">double</span>&amp; x) { <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); };</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> <a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/algorithm/lower_bound.html">lower_bound</a> = 0.0;</div>
<div class="line"><a id="l00175" name="l00175"></a><span class="lineno"> 175</span> <a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/algorithm/upper_bound.html">upper_bound</a> = 1.0;</div>
<div class="line"><a id="l00176" name="l00176"></a><span class="lineno"> 176</span> pdf = [&amp;](<span class="keywordtype">double</span>&amp; x) {</div>
<div class="line"><a id="l00177" name="l00177"></a><span class="lineno"> 177</span> <span class="keywordflow">if</span> (x &gt;= lower_bound &amp;&amp; x &lt;= 0.2) {</div>
<div class="line"><a id="l00178" name="l00178"></a><span class="lineno"> 178</span> <span class="keywordflow">return</span> 0.1;</div>
<div class="line"><a id="l00179" name="l00179"></a><span class="lineno"> 179</span> }</div>
<div class="line"><a id="l00180" name="l00180"></a><span class="lineno"> 180</span> <span class="keywordflow">if</span> (x &gt; 0.2 &amp;&amp; x &lt;= 0.4) {</div>
<div class="line"><a id="l00181" name="l00181"></a><span class="lineno"> 181</span> <span class="keywordflow">return</span> 0.4;</div>
<div class="line"><a id="l00182" name="l00182"></a><span class="lineno"> 182</span> }</div>
<div class="line"><a id="l00183" name="l00183"></a><span class="lineno"> 183</span> <span class="keywordflow">if</span> (x &gt; 0.4 &amp;&amp; x &lt; upper_bound) {</div>
<div class="line"><a id="l00184" name="l00184"></a><span class="lineno"> 184</span> <span class="keywordflow">return</span> 1.5;</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> <span class="keywordflow">return</span> 0.0;</div>
<div class="line"><a id="l00187" name="l00187"></a><span class="lineno"> 187</span> };</div>
<div class="line"><a id="l00188" name="l00188"></a><span class="lineno"> 188</span> </div>
<div class="line"><a id="l00189" name="l00189"></a><span class="lineno"> 189</span> integral = <a class="code hl_function" href="../../db/d40/integral__approximation2_8cpp.html#af7da9ba8932f1f48b9bbc2d80471af51">math::monte_carlo::integral_monte_carlo</a>(</div>
<div class="line"><a id="l00190" name="l00190"></a><span class="lineno"> 190</span> (upper_bound - lower_bound) / 2.0, f, pdf);</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> <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;This number should be close to 1.7182818: &quot;</span> &lt;&lt; integral</div>
<div class="line"><a id="l00193" name="l00193"></a><span class="lineno"> 193</span> &lt;&lt; <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="l00194" name="l00194"></a><span class="lineno"> 194</span> </div>
<div class="line"><a id="l00195" name="l00195"></a><span class="lineno"> 195</span> <span class="comment">/* \int_{-\infty}^{\infty} sinc(x) dx, sinc(x) = sin(pi * x) / (pi * x)</span></div>
<div class="line"><a id="l00196" name="l00196"></a><span class="lineno"> 196</span><span class="comment"> This is a difficult integral because of its infinite domain.</span></div>
<div class="line"><a id="l00197" name="l00197"></a><span class="lineno"> 197</span><span class="comment"> Therefore, it may deviate largely from the expected result.</span></div>
<div class="line"><a id="l00198" name="l00198"></a><span class="lineno"> 198</span><span class="comment"> */</span></div>
<div class="line"><a id="l00199" name="l00199"></a><span class="lineno"> 199</span> <a class="code hl_function" href="../../d4/d18/composite__simpson__rule_8cpp.html#a4251b4df4748a0b9c43a48f61bdd2397">f</a> = [&amp;](<span class="keywordtype">double</span>&amp; x) { <span class="keywordflow">return</span> <a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/numeric/math/sin.html">std::sin</a>(M_PI * x) / (M_PI * x); };</div>
<div class="line"><a id="l00200" name="l00200"></a><span class="lineno"> 200</span> </div>
<div class="line"><a id="l00201" name="l00201"></a><span class="lineno"> 201</span> pdf = [&amp;](<span class="keywordtype">double</span>&amp; x) {</div>
<div class="line"><a id="l00202" name="l00202"></a><span class="lineno"> 202</span> <span class="keywordflow">return</span> 1.0 / <a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/numeric/math/sqrt.html">std::sqrt</a>(2.0 * M_PI) * <a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/numeric/math/exp.html">std::exp</a>(-x * x / 2.0);</div>
<div class="line"><a id="l00203" name="l00203"></a><span class="lineno"> 203</span> };</div>
<div class="line"><a id="l00204" name="l00204"></a><span class="lineno"> 204</span> </div>
<div class="line"><a id="l00205" name="l00205"></a><span class="lineno"> 205</span> integral = <a class="code hl_function" href="../../db/d40/integral__approximation2_8cpp.html#af7da9ba8932f1f48b9bbc2d80471af51">math::monte_carlo::integral_monte_carlo</a>(0.0, f, pdf, 10000000);</div>
<div class="line"><a id="l00206" name="l00206"></a><span class="lineno"> 206</span> </div>
<div class="line"><a id="l00207" name="l00207"></a><span class="lineno"> 207</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;This number should be close to 1.0: &quot;</span> &lt;&lt; integral</div>
<div class="line"><a id="l00208" name="l00208"></a><span class="lineno"> 208</span> &lt;&lt; <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="l00209" name="l00209"></a><span class="lineno"> 209</span>}</div>
<div class="fragment"><div class="line"><span class="lineno"> 133</span> {</div>
<div class="line"><span class="lineno"> 134</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;Disclaimer: Because this is a randomized algorithm,&quot;</span></div>
<div class="line"><span class="lineno"> 135</span> &lt;&lt; <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"> 136</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/basic_ostream.html">std::cout</a></div>
<div class="line"><span class="lineno"> 137</span> &lt;&lt; <span class="stringliteral">&quot;it may happen that singular samples deviate from the true result.&quot;</span></div>
<div class="line"><span class="lineno"> 138</span> &lt;&lt; <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"> 139</span> &lt;&lt; <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> </div>
<div class="line"><span class="lineno"> 142</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/utility/functional/function.html">math::monte_carlo::Function</a> <a class="code hl_function" href="../../d4/d18/composite__simpson__rule_8cpp.html#a4251b4df4748a0b9c43a48f61bdd2397">f</a>;</div>
<div class="line"><span class="lineno"> 143</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/utility/functional/function.html">math::monte_carlo::Function</a> pdf;</div>
<div class="line"><span class="lineno"> 144</span> <span class="keywordtype">double</span> integral = 0;</div>
<div class="line"><span class="lineno"> 145</span> <span class="keywordtype">double</span> <a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/algorithm/lower_bound.html">lower_bound</a> = 0, <a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/algorithm/upper_bound.html">upper_bound</a> = 0;</div>
<div class="line"><span class="lineno"> 146</span> </div>
<div class="line"><span class="lineno"> 147</span> <span class="comment">/* \int_{-2}^{2} -x^2 + 4 dx */</span></div>
<div class="line"><span class="lineno"> 148</span> <a class="code hl_function" href="../../d4/d18/composite__simpson__rule_8cpp.html#a4251b4df4748a0b9c43a48f61bdd2397">f</a> = [&amp;](<span class="keywordtype">double</span>&amp; x) { <span class="keywordflow">return</span> -x * x + 4.0; };</div>
<div class="line"><span class="lineno"> 149</span> </div>
<div class="line"><span class="lineno"> 150</span> <a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/algorithm/lower_bound.html">lower_bound</a> = -2.0;</div>
<div class="line"><span class="lineno"> 151</span> <a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/algorithm/upper_bound.html">upper_bound</a> = 2.0;</div>
<div class="line"><span class="lineno"> 152</span> pdf = [&amp;](<span class="keywordtype">double</span>&amp; x) {</div>
<div class="line"><span class="lineno"> 153</span> <span class="keywordflow">if</span> (x &gt;= lower_bound &amp;&amp; x &lt;= -1.0) {</div>
<div class="line"><span class="lineno"> 154</span> <span class="keywordflow">return</span> 0.1;</div>
<div class="line"><span class="lineno"> 155</span> }</div>
<div class="line"><span class="lineno"> 156</span> <span class="keywordflow">if</span> (x &lt;= upper_bound &amp;&amp; x &gt;= 1.0) {</div>
<div class="line"><span class="lineno"> 157</span> <span class="keywordflow">return</span> 0.1;</div>
<div class="line"><span class="lineno"> 158</span> }</div>
<div class="line"><span class="lineno"> 159</span> <span class="keywordflow">if</span> (x &gt; -1.0 &amp;&amp; x &lt; 1.0) {</div>
<div class="line"><span class="lineno"> 160</span> <span class="keywordflow">return</span> 0.4;</div>
<div class="line"><span class="lineno"> 161</span> }</div>
<div class="line"><span class="lineno"> 162</span> <span class="keywordflow">return</span> 0.0;</div>
<div class="line"><span class="lineno"> 163</span> };</div>
<div class="line"><span class="lineno"> 164</span> </div>
<div class="line"><span class="lineno"> 165</span> integral = <a class="code hl_function" href="../../db/d40/integral__approximation2_8cpp.html#af7da9ba8932f1f48b9bbc2d80471af51">math::monte_carlo::integral_monte_carlo</a>(</div>
<div class="line"><span class="lineno"> 166</span> (upper_bound - lower_bound) / 2.0, f, pdf);</div>
<div class="line"><span class="lineno"> 167</span> </div>
<div class="line"><span class="lineno"> 168</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;This number should be close to 10.666666: &quot;</span> &lt;&lt; integral</div>
<div class="line"><span class="lineno"> 169</span> &lt;&lt; <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"> 170</span> </div>
<div class="line"><span class="lineno"> 171</span> <span class="comment">/* \int_{0}^{1} e^x dx */</span></div>
<div class="line"><span class="lineno"> 172</span> <a class="code hl_function" href="../../d4/d18/composite__simpson__rule_8cpp.html#a4251b4df4748a0b9c43a48f61bdd2397">f</a> = [&amp;](<span class="keywordtype">double</span>&amp; x) { <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); };</div>
<div class="line"><span class="lineno"> 173</span> </div>
<div class="line"><span class="lineno"> 174</span> <a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/algorithm/lower_bound.html">lower_bound</a> = 0.0;</div>
<div class="line"><span class="lineno"> 175</span> <a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/algorithm/upper_bound.html">upper_bound</a> = 1.0;</div>
<div class="line"><span class="lineno"> 176</span> pdf = [&amp;](<span class="keywordtype">double</span>&amp; x) {</div>
<div class="line"><span class="lineno"> 177</span> <span class="keywordflow">if</span> (x &gt;= lower_bound &amp;&amp; x &lt;= 0.2) {</div>
<div class="line"><span class="lineno"> 178</span> <span class="keywordflow">return</span> 0.1;</div>
<div class="line"><span class="lineno"> 179</span> }</div>
<div class="line"><span class="lineno"> 180</span> <span class="keywordflow">if</span> (x &gt; 0.2 &amp;&amp; x &lt;= 0.4) {</div>
<div class="line"><span class="lineno"> 181</span> <span class="keywordflow">return</span> 0.4;</div>
<div class="line"><span class="lineno"> 182</span> }</div>
<div class="line"><span class="lineno"> 183</span> <span class="keywordflow">if</span> (x &gt; 0.4 &amp;&amp; x &lt; upper_bound) {</div>
<div class="line"><span class="lineno"> 184</span> <span class="keywordflow">return</span> 1.5;</div>
<div class="line"><span class="lineno"> 185</span> }</div>
<div class="line"><span class="lineno"> 186</span> <span class="keywordflow">return</span> 0.0;</div>
<div class="line"><span class="lineno"> 187</span> };</div>
<div class="line"><span class="lineno"> 188</span> </div>
<div class="line"><span class="lineno"> 189</span> integral = <a class="code hl_function" href="../../db/d40/integral__approximation2_8cpp.html#af7da9ba8932f1f48b9bbc2d80471af51">math::monte_carlo::integral_monte_carlo</a>(</div>
<div class="line"><span class="lineno"> 190</span> (upper_bound - lower_bound) / 2.0, f, pdf);</div>
<div class="line"><span class="lineno"> 191</span> </div>
<div class="line"><span class="lineno"> 192</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;This number should be close to 1.7182818: &quot;</span> &lt;&lt; integral</div>
<div class="line"><span class="lineno"> 193</span> &lt;&lt; <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"> 194</span> </div>
<div class="line"><span class="lineno"> 195</span> <span class="comment">/* \int_{-\infty}^{\infty} sinc(x) dx, sinc(x) = sin(pi * x) / (pi * x)</span></div>
<div class="line"><span class="lineno"> 196</span><span class="comment"> This is a difficult integral because of its infinite domain.</span></div>
<div class="line"><span class="lineno"> 197</span><span class="comment"> Therefore, it may deviate largely from the expected result.</span></div>
<div class="line"><span class="lineno"> 198</span><span class="comment"> */</span></div>
<div class="line"><span class="lineno"> 199</span> <a class="code hl_function" href="../../d4/d18/composite__simpson__rule_8cpp.html#a4251b4df4748a0b9c43a48f61bdd2397">f</a> = [&amp;](<span class="keywordtype">double</span>&amp; x) { <span class="keywordflow">return</span> <a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/numeric/math/sin.html">std::sin</a>(M_PI * x) / (M_PI * x); };</div>
<div class="line"><span class="lineno"> 200</span> </div>
<div class="line"><span class="lineno"> 201</span> pdf = [&amp;](<span class="keywordtype">double</span>&amp; x) {</div>
<div class="line"><span class="lineno"> 202</span> <span class="keywordflow">return</span> 1.0 / <a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/numeric/math/sqrt.html">std::sqrt</a>(2.0 * M_PI) * <a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/numeric/math/exp.html">std::exp</a>(-x * x / 2.0);</div>
<div class="line"><span class="lineno"> 203</span> };</div>
<div class="line"><span class="lineno"> 204</span> </div>
<div class="line"><span class="lineno"> 205</span> integral = <a class="code hl_function" href="../../db/d40/integral__approximation2_8cpp.html#af7da9ba8932f1f48b9bbc2d80471af51">math::monte_carlo::integral_monte_carlo</a>(0.0, f, pdf, 10000000);</div>
<div class="line"><span class="lineno"> 206</span> </div>
<div class="line"><span class="lineno"> 207</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;This number should be close to 1.0: &quot;</span> &lt;&lt; integral</div>
<div class="line"><span class="lineno"> 208</span> &lt;&lt; <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"> 209</span>}</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="acomposite__simpson__rule_8cpp_html_a4251b4df4748a0b9c43a48f61bdd2397"><div class="ttname"><a href="../../d4/d18/composite__simpson__rule_8cpp.html#a4251b4df4748a0b9c43a48f61bdd2397">numerical_methods::simpson_method::f</a></div><div class="ttdeci">double f(double x)</div><div class="ttdoc">A function f(x) that will be used to test the method.</div><div class="ttdef"><b>Definition:</b> composite_simpson_rule.cpp:113</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>
@@ -477,7 +477,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_296d53ceaeaa7e099814a6def439fe8a.html">math</a></li><li class="navelem"><a class="el" href="../../db/d40/integral__approximation2_8cpp.html">integral_approximation2.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>

View File

@@ -1,6 +1,6 @@
<map id="math::monte_carlo::generate_samples" name="math::monte_carlo::generate_samples">
<area shape="rect" id="node1" title="short&#45;hand for std::functions used in this implementation" alt="" coords="5,49,144,90"/>
<area shape="rect" id="node2" href="/Users/runner/work/C-Plus-Plus/C-Plus-Plus/doc/cppreference-doxygen-web.tag.xml$cpp/algorithm/min.html#" title=" " alt="" coords="235,5,304,32"/>
<area shape="rect" id="node3" href="/Users/runner/work/C-Plus-Plus/C-Plus-Plus/doc/cppreference-doxygen-web.tag.xml$cpp/container/vector/push_back.html#" title=" " alt="" coords="192,56,347,83"/>
<area shape="rect" id="node4" href="/Users/runner/work/C-Plus-Plus/C-Plus-Plus/doc/cppreference-doxygen-web.tag.xml$cpp/container/vector/reserve.html#" title=" " alt="" coords="202,107,337,133"/>
<area shape="rect" id="node2" href="/Users/runner/work/C-Plus-Plus/C-Plus-Plus/doc/cppreference-doxygen-web.tag.xml$cpp/algorithm/min#" title=" " alt="" coords="235,5,304,32"/>
<area shape="rect" id="node3" href="/Users/runner/work/C-Plus-Plus/C-Plus-Plus/doc/cppreference-doxygen-web.tag.xml$cpp/container/vector/push_back#" title=" " alt="" coords="192,56,347,83"/>
<area shape="rect" id="node4" href="/Users/runner/work/C-Plus-Plus/C-Plus-Plus/doc/cppreference-doxygen-web.tag.xml$cpp/container/vector/reserve#" title=" " alt="" coords="202,107,337,133"/>
</map>

View File

@@ -1 +1 @@
3a679f87fcf84b642be9208e2dfec84c
11b12de3606b3b696afa045f00a8a640

View File

@@ -28,7 +28,7 @@
<!-- Node2 -->
<g id="node2" class="node">
<title>Node2</title>
<g id="a_node2"><a target="_blank" xlink:href="http://en.cppreference.com/w/cpp/algorithm/min.html#" xlink:title=" ">
<g id="a_node2"><a target="_blank" xlink:href="http://en.cppreference.com/w/cpp/algorithm/min#" xlink:title=" ">
<polygon fill="white" stroke="black" points="172,-76.5 172,-95.5 224,-95.5 224,-76.5 172,-76.5"/>
<text text-anchor="middle" x="198" y="-83.5" font-family="Helvetica,sans-Serif" font-size="10.00">std::min</text>
</a>
@@ -43,7 +43,7 @@
<!-- Node3 -->
<g id="node3" class="node">
<title>Node3</title>
<g id="a_node3"><a target="_blank" xlink:href="http://en.cppreference.com/w/cpp/container/vector/push_back.html#" xlink:title=" ">
<g id="a_node3"><a target="_blank" xlink:href="http://en.cppreference.com/w/cpp/container/vector/push_back#" xlink:title=" ">
<polygon fill="white" stroke="black" points="140,-38.5 140,-57.5 256,-57.5 256,-38.5 140,-38.5"/>
<text text-anchor="middle" x="198" y="-45.5" font-family="Helvetica,sans-Serif" font-size="10.00">std::vector::push_back</text>
</a>
@@ -58,7 +58,7 @@
<!-- Node4 -->
<g id="node4" class="node">
<title>Node4</title>
<g id="a_node4"><a target="_blank" xlink:href="http://en.cppreference.com/w/cpp/container/vector/reserve.html#" xlink:title=" ">
<g id="a_node4"><a target="_blank" xlink:href="http://en.cppreference.com/w/cpp/container/vector/reserve#" xlink:title=" ">
<polygon fill="white" stroke="black" points="147.5,-0.5 147.5,-19.5 248.5,-19.5 248.5,-0.5 147.5,-0.5"/>
<text text-anchor="middle" x="198" y="-7.5" font-family="Helvetica,sans-Serif" font-size="10.00">std::vector::reserve</text>
</a>

Before

Width:  |  Height:  |  Size: 3.6 KiB

After

Width:  |  Height:  |  Size: 3.6 KiB

View File

@@ -1,7 +1,7 @@
<map id="test" name="test">
<area shape="rect" id="node1" title="Self&#45;test implementations." alt="" coords="5,81,49,108"/>
<area shape="rect" id="node2" href="/Users/runner/work/C-Plus-Plus/C-Plus-Plus/doc/cppreference-doxygen-web.tag.xml$cpp/io/manip/endl.html#" title=" " alt="" coords="97,5,169,32"/>
<area shape="rect" id="node3" href="/Users/runner/work/C-Plus-Plus/C-Plus-Plus/doc/cppreference-doxygen-web.tag.xml$cpp/numeric/math/exp.html#" title=" " alt="" coords="99,56,168,83"/>
<area shape="rect" id="node4" href="/Users/runner/work/C-Plus-Plus/C-Plus-Plus/doc/cppreference-doxygen-web.tag.xml$cpp/numeric/math/sin.html#" title=" " alt="" coords="101,107,166,133"/>
<area shape="rect" id="node5" href="/Users/runner/work/C-Plus-Plus/C-Plus-Plus/doc/cppreference-doxygen-web.tag.xml$cpp/numeric/math/sqrt.html#" title=" " alt="" coords="98,157,169,184"/>
<area shape="rect" id="node2" href="/Users/runner/work/C-Plus-Plus/C-Plus-Plus/doc/cppreference-doxygen-web.tag.xml$cpp/io/manip/endl#" title=" " alt="" coords="97,5,169,32"/>
<area shape="rect" id="node3" href="/Users/runner/work/C-Plus-Plus/C-Plus-Plus/doc/cppreference-doxygen-web.tag.xml$cpp/numeric/math/exp#" title=" " alt="" coords="99,56,168,83"/>
<area shape="rect" id="node4" href="/Users/runner/work/C-Plus-Plus/C-Plus-Plus/doc/cppreference-doxygen-web.tag.xml$cpp/numeric/math/sin#" title=" " alt="" coords="101,107,166,133"/>
<area shape="rect" id="node5" href="/Users/runner/work/C-Plus-Plus/C-Plus-Plus/doc/cppreference-doxygen-web.tag.xml$cpp/numeric/math/sqrt#" title=" " alt="" coords="98,157,169,184"/>
</map>

View File

@@ -1 +1 @@
622fbdac78e8364ce6c073de02e68f54
65c1b3e46a52f433f8a0d38814ad02ca

View File

@@ -21,7 +21,7 @@
<!-- Node2 -->
<g id="node2" class="node">
<title>Node2</title>
<g id="a_node2"><a target="_blank" xlink:href="http://en.cppreference.com/w/cpp/io/manip/endl.html#" xlink:title=" ">
<g id="a_node2"><a target="_blank" xlink:href="http://en.cppreference.com/w/cpp/io/manip/endl#" xlink:title=" ">
<polygon fill="white" stroke="black" points="69,-114.5 69,-133.5 123,-133.5 123,-114.5 69,-114.5"/>
<text text-anchor="middle" x="96" y="-121.5" font-family="Helvetica,sans-Serif" font-size="10.00">std::endl</text>
</a>
@@ -36,7 +36,7 @@
<!-- Node3 -->
<g id="node3" class="node">
<title>Node3</title>
<g id="a_node3"><a target="_blank" xlink:href="http://en.cppreference.com/w/cpp/numeric/math/exp.html#" xlink:title=" ">
<g id="a_node3"><a target="_blank" xlink:href="http://en.cppreference.com/w/cpp/numeric/math/exp#" xlink:title=" ">
<polygon fill="white" stroke="black" points="70,-76.5 70,-95.5 122,-95.5 122,-76.5 70,-76.5"/>
<text text-anchor="middle" x="96" y="-83.5" font-family="Helvetica,sans-Serif" font-size="10.00">std::exp</text>
</a>
@@ -51,7 +51,7 @@
<!-- Node4 -->
<g id="node4" class="node">
<title>Node4</title>
<g id="a_node4"><a target="_blank" xlink:href="http://en.cppreference.com/w/cpp/numeric/math/sin.html#" xlink:title=" ">
<g id="a_node4"><a target="_blank" xlink:href="http://en.cppreference.com/w/cpp/numeric/math/sin#" xlink:title=" ">
<polygon fill="white" stroke="black" points="71.5,-38.5 71.5,-57.5 120.5,-57.5 120.5,-38.5 71.5,-38.5"/>
<text text-anchor="middle" x="96" y="-45.5" font-family="Helvetica,sans-Serif" font-size="10.00">std::sin</text>
</a>
@@ -66,7 +66,7 @@
<!-- Node5 -->
<g id="node5" class="node">
<title>Node5</title>
<g id="a_node5"><a target="_blank" xlink:href="http://en.cppreference.com/w/cpp/numeric/math/sqrt.html#" xlink:title=" ">
<g id="a_node5"><a target="_blank" xlink:href="http://en.cppreference.com/w/cpp/numeric/math/sqrt#" xlink:title=" ">
<polygon fill="white" stroke="black" points="69.5,-0.5 69.5,-19.5 122.5,-19.5 122.5,-0.5 69.5,-0.5"/>
<text text-anchor="middle" x="96" y="-7.5" font-family="Helvetica,sans-Serif" font-size="10.00">std::sqrt</text>
</a>

Before

Width:  |  Height:  |  Size: 3.8 KiB

After

Width:  |  Height:  |  Size: 3.8 KiB

View File

@@ -1,8 +1,8 @@
<map id="main" name="main">
<area shape="rect" id="node1" title="Main function." alt="" coords="5,81,56,108"/>
<area shape="rect" id="node2" href="$db/d40/integral__approximation2_8cpp.html#aa8dca7b867074164d5f45b0f3851269d" title="Self&#45;test implementations." alt="" coords="104,81,148,108"/>
<area shape="rect" id="node3" href="/Users/runner/work/C-Plus-Plus/C-Plus-Plus/doc/cppreference-doxygen-web.tag.xml$cpp/io/manip/endl.html#" title=" " alt="" coords="196,5,268,32"/>
<area shape="rect" id="node4" href="/Users/runner/work/C-Plus-Plus/C-Plus-Plus/doc/cppreference-doxygen-web.tag.xml$cpp/numeric/math/exp.html#" title=" " alt="" coords="197,56,267,83"/>
<area shape="rect" id="node5" href="/Users/runner/work/C-Plus-Plus/C-Plus-Plus/doc/cppreference-doxygen-web.tag.xml$cpp/numeric/math/sin.html#" title=" " alt="" coords="199,107,265,133"/>
<area shape="rect" id="node6" href="/Users/runner/work/C-Plus-Plus/C-Plus-Plus/doc/cppreference-doxygen-web.tag.xml$cpp/numeric/math/sqrt.html#" title=" " alt="" coords="197,157,267,184"/>
<area shape="rect" id="node3" href="/Users/runner/work/C-Plus-Plus/C-Plus-Plus/doc/cppreference-doxygen-web.tag.xml$cpp/io/manip/endl#" title=" " alt="" coords="196,5,268,32"/>
<area shape="rect" id="node4" href="/Users/runner/work/C-Plus-Plus/C-Plus-Plus/doc/cppreference-doxygen-web.tag.xml$cpp/numeric/math/exp#" title=" " alt="" coords="197,56,267,83"/>
<area shape="rect" id="node5" href="/Users/runner/work/C-Plus-Plus/C-Plus-Plus/doc/cppreference-doxygen-web.tag.xml$cpp/numeric/math/sin#" title=" " alt="" coords="199,107,265,133"/>
<area shape="rect" id="node6" href="/Users/runner/work/C-Plus-Plus/C-Plus-Plus/doc/cppreference-doxygen-web.tag.xml$cpp/numeric/math/sqrt#" title=" " alt="" coords="197,157,267,184"/>
</map>

View File

@@ -1 +1 @@
87d957db15915ba0b9079108122e1563
1907c121e9946a692f4fb4616598544f

View File

@@ -36,7 +36,7 @@
<!-- Node3 -->
<g id="node3" class="node">
<title>Node3</title>
<g id="a_node3"><a target="_blank" xlink:href="http://en.cppreference.com/w/cpp/io/manip/endl.html#" xlink:title=" ">
<g id="a_node3"><a target="_blank" xlink:href="http://en.cppreference.com/w/cpp/io/manip/endl#" xlink:title=" ">
<polygon fill="white" stroke="black" points="143,-114.5 143,-133.5 197,-133.5 197,-114.5 143,-114.5"/>
<text text-anchor="middle" x="170" y="-121.5" font-family="Helvetica,sans-Serif" font-size="10.00">std::endl</text>
</a>
@@ -51,7 +51,7 @@
<!-- Node4 -->
<g id="node4" class="node">
<title>Node4</title>
<g id="a_node4"><a target="_blank" xlink:href="http://en.cppreference.com/w/cpp/numeric/math/exp.html#" xlink:title=" ">
<g id="a_node4"><a target="_blank" xlink:href="http://en.cppreference.com/w/cpp/numeric/math/exp#" xlink:title=" ">
<polygon fill="white" stroke="black" points="144,-76.5 144,-95.5 196,-95.5 196,-76.5 144,-76.5"/>
<text text-anchor="middle" x="170" y="-83.5" font-family="Helvetica,sans-Serif" font-size="10.00">std::exp</text>
</a>
@@ -66,7 +66,7 @@
<!-- Node5 -->
<g id="node5" class="node">
<title>Node5</title>
<g id="a_node5"><a target="_blank" xlink:href="http://en.cppreference.com/w/cpp/numeric/math/sin.html#" xlink:title=" ">
<g id="a_node5"><a target="_blank" xlink:href="http://en.cppreference.com/w/cpp/numeric/math/sin#" xlink:title=" ">
<polygon fill="white" stroke="black" points="145.5,-38.5 145.5,-57.5 194.5,-57.5 194.5,-38.5 145.5,-38.5"/>
<text text-anchor="middle" x="170" y="-45.5" font-family="Helvetica,sans-Serif" font-size="10.00">std::sin</text>
</a>
@@ -81,7 +81,7 @@
<!-- Node6 -->
<g id="node6" class="node">
<title>Node6</title>
<g id="a_node6"><a target="_blank" xlink:href="http://en.cppreference.com/w/cpp/numeric/math/sqrt.html#" xlink:title=" ">
<g id="a_node6"><a target="_blank" xlink:href="http://en.cppreference.com/w/cpp/numeric/math/sqrt#" xlink:title=" ">
<polygon fill="white" stroke="black" points="143.5,-0.5 143.5,-19.5 196.5,-19.5 196.5,-0.5 143.5,-0.5"/>
<text text-anchor="middle" x="170" y="-7.5" font-family="Helvetica,sans-Serif" font-size="10.00">std::sqrt</text>
</a>

Before

Width:  |  Height:  |  Size: 4.6 KiB

After

Width:  |  Height:  |  Size: 4.6 KiB

View File

@@ -1,8 +1,8 @@
<map id="math::monte_carlo::integral_monte_carlo" name="math::monte_carlo::integral_monte_carlo">
<area shape="rect" id="node1" title="Compute an approximation of an integral using Monte Carlo integration." alt="" coords="5,78,148,119"/>
<area shape="rect" id="node2" href="$db/d40/integral__approximation2_8cpp.html#a71249ee535f16f8ed2e9cc8f0199a2cf" title="short&#45;hand for std::functions used in this implementation" alt="" coords="196,49,335,90"/>
<area shape="rect" id="node6" href="/Users/runner/work/C-Plus-Plus/C-Plus-Plus/doc/cppreference-doxygen-web.tag.xml$cpp/container/vector/size.html#" title=" " alt="" coords="207,115,323,141"/>
<area shape="rect" id="node3" href="/Users/runner/work/C-Plus-Plus/C-Plus-Plus/doc/cppreference-doxygen-web.tag.xml$cpp/algorithm/min.html#" title=" " alt="" coords="425,5,495,32"/>
<area shape="rect" id="node4" href="/Users/runner/work/C-Plus-Plus/C-Plus-Plus/doc/cppreference-doxygen-web.tag.xml$cpp/container/vector/push_back.html#" title=" " alt="" coords="383,56,537,83"/>
<area shape="rect" id="node5" href="/Users/runner/work/C-Plus-Plus/C-Plus-Plus/doc/cppreference-doxygen-web.tag.xml$cpp/container/vector/reserve.html#" title=" " alt="" coords="393,107,527,133"/>
<area shape="rect" id="node6" href="/Users/runner/work/C-Plus-Plus/C-Plus-Plus/doc/cppreference-doxygen-web.tag.xml$cpp/container/vector/size#" title=" " alt="" coords="207,115,323,141"/>
<area shape="rect" id="node3" href="/Users/runner/work/C-Plus-Plus/C-Plus-Plus/doc/cppreference-doxygen-web.tag.xml$cpp/algorithm/min#" title=" " alt="" coords="425,5,495,32"/>
<area shape="rect" id="node4" href="/Users/runner/work/C-Plus-Plus/C-Plus-Plus/doc/cppreference-doxygen-web.tag.xml$cpp/container/vector/push_back#" title=" " alt="" coords="383,56,537,83"/>
<area shape="rect" id="node5" href="/Users/runner/work/C-Plus-Plus/C-Plus-Plus/doc/cppreference-doxygen-web.tag.xml$cpp/container/vector/reserve#" title=" " alt="" coords="393,107,527,133"/>
</map>

View File

@@ -1 +1 @@
fb76a30ea0b4c0681c06849e0844eff8
4262de1437868b6c15f6ccbac695bfc5

View File

@@ -44,7 +44,7 @@
<!-- Node6 -->
<g id="node6" class="node">
<title>Node6</title>
<g id="a_node6"><a target="_blank" xlink:href="http://en.cppreference.com/w/cpp/container/vector/size.html#" xlink:title=" ">
<g id="a_node6"><a target="_blank" xlink:href="http://en.cppreference.com/w/cpp/container/vector/size#" xlink:title=" ">
<polygon fill="white" stroke="black" points="151.5,-0.5 151.5,-19.5 238.5,-19.5 238.5,-0.5 151.5,-0.5"/>
<text text-anchor="middle" x="195" y="-7.5" font-family="Helvetica,sans-Serif" font-size="10.00">std::vector::size</text>
</a>
@@ -65,7 +65,7 @@
<!-- Node3 -->
<g id="node3" class="node">
<title>Node3</title>
<g id="a_node3"><a target="_blank" xlink:href="http://en.cppreference.com/w/cpp/algorithm/min.html#" xlink:title=" ">
<g id="a_node3"><a target="_blank" xlink:href="http://en.cppreference.com/w/cpp/algorithm/min#" xlink:title=" ">
<polygon fill="white" stroke="black" points="315,-82.5 315,-101.5 367,-101.5 367,-82.5 315,-82.5"/>
<text text-anchor="middle" x="341" y="-89.5" font-family="Helvetica,sans-Serif" font-size="10.00">std::min</text>
</a>
@@ -80,7 +80,7 @@
<!-- Node4 -->
<g id="node4" class="node">
<title>Node4</title>
<g id="a_node4"><a target="_blank" xlink:href="http://en.cppreference.com/w/cpp/container/vector/push_back.html#" xlink:title=" ">
<g id="a_node4"><a target="_blank" xlink:href="http://en.cppreference.com/w/cpp/container/vector/push_back#" xlink:title=" ">
<polygon fill="white" stroke="black" points="283,-44.5 283,-63.5 399,-63.5 399,-44.5 283,-44.5"/>
<text text-anchor="middle" x="341" y="-51.5" font-family="Helvetica,sans-Serif" font-size="10.00">std::vector::push_back</text>
</a>
@@ -95,7 +95,7 @@
<!-- Node5 -->
<g id="node5" class="node">
<title>Node5</title>
<g id="a_node5"><a target="_blank" xlink:href="http://en.cppreference.com/w/cpp/container/vector/reserve.html#" xlink:title=" ">
<g id="a_node5"><a target="_blank" xlink:href="http://en.cppreference.com/w/cpp/container/vector/reserve#" xlink:title=" ">
<polygon fill="white" stroke="black" points="290.5,-6.5 290.5,-25.5 391.5,-25.5 391.5,-6.5 290.5,-6.5"/>
<text text-anchor="middle" x="341" y="-13.5" font-family="Helvetica,sans-Serif" font-size="10.00">std::vector::reserve</text>
</a>

Before

Width:  |  Height:  |  Size: 5.6 KiB

After

Width:  |  Height:  |  Size: 5.6 KiB

View File

@@ -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++: data_structures::stack_using_queue::Stack Struct 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">&#160;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&amp;dn=expat.txt MIT */
var searchBox = new SearchBox("searchBox", "../../search",'Search','.html');
@@ -100,6 +100,12 @@ $(document).ready(function(){initNavTree('db/d5b/structdata__structures_1_1stack
<p><a class="el" href="../../db/d5b/structdata__structures_1_1stack__using__queue_1_1_stack.html" title="Stack Class implementation for basic methods of Stack Data Structure.">Stack</a> Class implementation for basic methods of <a class="el" href="../../db/d5b/structdata__structures_1_1stack__using__queue_1_1_stack.html" title="Stack Class implementation for basic methods of Stack Data Structure.">Stack</a> Data Structure.
<a href="../../db/d5b/structdata__structures_1_1stack__using__queue_1_1_stack.html#details">More...</a></p>
<div class="dynheader">
Collaboration diagram for data_structures::stack_using_queue::Stack:</div>
<div class="dyncontent">
<div class="center"><iframe scrolling="no" frameborder="0" src="../../d0/dea/structdata__structures_1_1stack__using__queue_1_1_stack__coll__graph.svg" width="163" height="246"><p><b>This browser is not able to show SVG: try Firefox, Chrome, Safari, or Opera instead.</b></p></iframe>
</div>
<center><span class="legend">[<a target="top" href="../../graph_legend.html">legend</a>]</span></center></div>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="pub-methods" name="pub-methods"></a>
Public Member Functions</h2></td></tr>
@@ -156,16 +162,24 @@ uint32_t&#160;</td><td class="memItemRight" valign="bottom"><b>current_size</b>
<p>Removes the topmost element from the stack. </p>
<dl class="section return"><dt>Returns</dt><dd>void </dd></dl>
<div class="fragment"><div class="line"><a id="l00061" name="l00061"></a><span class="lineno"> 61</span> {</div>
<div class="line"><a id="l00062" name="l00062"></a><span class="lineno"> 62</span> <span class="keywordflow">if</span> (<a class="code hl_variable" href="../../db/d5b/structdata__structures_1_1stack__using__queue_1_1_stack.html#acf8ca54d5dd6676f255fff3dedacc7c6">main_q</a>.empty()) {</div>
<div class="line"><a id="l00063" name="l00063"></a><span class="lineno"> 63</span> <span class="keywordflow">return</span>;</div>
<div class="line"><a id="l00064" name="l00064"></a><span class="lineno"> 64</span> }</div>
<div class="line"><a id="l00065" name="l00065"></a><span class="lineno"> 65</span> <a class="code hl_variable" href="../../db/d5b/structdata__structures_1_1stack__using__queue_1_1_stack.html#acf8ca54d5dd6676f255fff3dedacc7c6">main_q</a>.pop();</div>
<div class="line"><a id="l00066" name="l00066"></a><span class="lineno"> 66</span> <a class="code hl_variable" href="../../db/d5b/structdata__structures_1_1stack__using__queue_1_1_stack.html#afdfd2f4418c70b1bda50f2c3e416d80b">current_size</a>--;</div>
<div class="line"><a id="l00067" name="l00067"></a><span class="lineno"> 67</span> }</div>
<div class="fragment"><div class="line"><span class="lineno"> 61</span> {</div>
<div class="line"><span class="lineno"> 62</span> <span class="keywordflow">if</span> (<a class="code hl_variable" href="../../db/d5b/structdata__structures_1_1stack__using__queue_1_1_stack.html#acf8ca54d5dd6676f255fff3dedacc7c6">main_q</a>.<a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/queue/empty.html">empty</a>()) {</div>
<div class="line"><span class="lineno"> 63</span> <span class="keywordflow">return</span>;</div>
<div class="line"><span class="lineno"> 64</span> }</div>
<div class="line"><span class="lineno"> 65</span> <a class="code hl_variable" href="../../db/d5b/structdata__structures_1_1stack__using__queue_1_1_stack.html#acf8ca54d5dd6676f255fff3dedacc7c6">main_q</a>.<a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/queue/pop.html">pop</a>();</div>
<div class="line"><span class="lineno"> 66</span> <a class="code hl_variable" href="../../db/d5b/structdata__structures_1_1stack__using__queue_1_1_stack.html#afdfd2f4418c70b1bda50f2c3e416d80b">current_size</a>--;</div>
<div class="line"><span class="lineno"> 67</span> }</div>
<div class="ttc" id="aempty_html"><div class="ttname"><a href="http://en.cppreference.com/w/cpp/container/queue/empty.html">std::queue::empty</a></div><div class="ttdeci">T empty(T... args)</div></div>
<div class="ttc" id="apop_html"><div class="ttname"><a href="http://en.cppreference.com/w/cpp/container/queue/pop.html">std::queue::pop</a></div><div class="ttdeci">T pop(T... args)</div></div>
<div class="ttc" id="astructdata__structures_1_1stack__using__queue_1_1_stack_html_acf8ca54d5dd6676f255fff3dedacc7c6"><div class="ttname"><a href="../../db/d5b/structdata__structures_1_1stack__using__queue_1_1_stack.html#acf8ca54d5dd6676f255fff3dedacc7c6">data_structures::stack_using_queue::Stack::main_q</a></div><div class="ttdeci">std::queue&lt; int64_t &gt; main_q</div><div class="ttdoc">stores the current state of the stack</div><div class="ttdef"><b>Definition:</b> stack_using_queue.cpp:31</div></div>
<div class="ttc" id="astructdata__structures_1_1stack__using__queue_1_1_stack_html_afdfd2f4418c70b1bda50f2c3e416d80b"><div class="ttname"><a href="../../db/d5b/structdata__structures_1_1stack__using__queue_1_1_stack.html#afdfd2f4418c70b1bda50f2c3e416d80b">data_structures::stack_using_queue::Stack::current_size</a></div><div class="ttdeci">uint32_t current_size</div><div class="ttdoc">stores the current size of the stack</div><div class="ttdef"><b>Definition:</b> stack_using_queue.cpp:34</div></div>
</div><!-- fragment -->
</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/d5b/structdata__structures_1_1stack__using__queue_1_1_stack_abdd461689df4983a3ad3b05d853cf5eb_cgraph.svg" width="359" height="88"><p><b>This browser is not able to show SVG: try Firefox, Chrome, Safari, or Opera instead.</b></p></iframe>
</div>
</div>
</div>
</div>
<a id="af04a8f3536a52d8c9916086b656eefc2" name="af04a8f3536a52d8c9916086b656eefc2"></a>
@@ -200,18 +214,26 @@ uint32_t&#160;</td><td class="memItemRight" valign="bottom"><b>current_size</b>
</dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>void </dd></dl>
<div class="fragment"><div class="line"><a id="l00047" name="l00047"></a><span class="lineno"> 47</span> {</div>
<div class="line"><a id="l00048" name="l00048"></a><span class="lineno"> 48</span> <a class="code hl_variable" href="../../db/d5b/structdata__structures_1_1stack__using__queue_1_1_stack.html#a2f80f87fc6f6ded938426698bba89323">auxiliary_q</a>.push(val);</div>
<div class="line"><a id="l00049" name="l00049"></a><span class="lineno"> 49</span> <span class="keywordflow">while</span> (!<a class="code hl_variable" href="../../db/d5b/structdata__structures_1_1stack__using__queue_1_1_stack.html#acf8ca54d5dd6676f255fff3dedacc7c6">main_q</a>.empty()) {</div>
<div class="line"><a id="l00050" name="l00050"></a><span class="lineno"> 50</span> <a class="code hl_variable" href="../../db/d5b/structdata__structures_1_1stack__using__queue_1_1_stack.html#a2f80f87fc6f6ded938426698bba89323">auxiliary_q</a>.push(<a class="code hl_variable" href="../../db/d5b/structdata__structures_1_1stack__using__queue_1_1_stack.html#acf8ca54d5dd6676f255fff3dedacc7c6">main_q</a>.front());</div>
<div class="line"><a id="l00051" name="l00051"></a><span class="lineno"> 51</span> <a class="code hl_variable" href="../../db/d5b/structdata__structures_1_1stack__using__queue_1_1_stack.html#acf8ca54d5dd6676f255fff3dedacc7c6">main_q</a>.pop();</div>
<div class="line"><a id="l00052" name="l00052"></a><span class="lineno"> 52</span> }</div>
<div class="line"><a id="l00053" name="l00053"></a><span class="lineno"> 53</span> <a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/algorithm/swap.html">swap</a>(<a class="code hl_variable" href="../../db/d5b/structdata__structures_1_1stack__using__queue_1_1_stack.html#acf8ca54d5dd6676f255fff3dedacc7c6">main_q</a>, <a class="code hl_variable" href="../../db/d5b/structdata__structures_1_1stack__using__queue_1_1_stack.html#a2f80f87fc6f6ded938426698bba89323">auxiliary_q</a>);</div>
<div class="line"><a id="l00054" name="l00054"></a><span class="lineno"> 54</span> <a class="code hl_variable" href="../../db/d5b/structdata__structures_1_1stack__using__queue_1_1_stack.html#afdfd2f4418c70b1bda50f2c3e416d80b">current_size</a>++;</div>
<div class="line"><a id="l00055" name="l00055"></a><span class="lineno"> 55</span> }</div>
<div class="fragment"><div class="line"><span class="lineno"> 47</span> {</div>
<div class="line"><span class="lineno"> 48</span> <a class="code hl_variable" href="../../db/d5b/structdata__structures_1_1stack__using__queue_1_1_stack.html#a2f80f87fc6f6ded938426698bba89323">auxiliary_q</a>.<a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/queue/push.html">push</a>(val);</div>
<div class="line"><span class="lineno"> 49</span> <span class="keywordflow">while</span> (!<a class="code hl_variable" href="../../db/d5b/structdata__structures_1_1stack__using__queue_1_1_stack.html#acf8ca54d5dd6676f255fff3dedacc7c6">main_q</a>.<a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/queue/empty.html">empty</a>()) {</div>
<div class="line"><span class="lineno"> 50</span> <a class="code hl_variable" href="../../db/d5b/structdata__structures_1_1stack__using__queue_1_1_stack.html#a2f80f87fc6f6ded938426698bba89323">auxiliary_q</a>.<a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/queue/push.html">push</a>(<a class="code hl_variable" href="../../db/d5b/structdata__structures_1_1stack__using__queue_1_1_stack.html#acf8ca54d5dd6676f255fff3dedacc7c6">main_q</a>.<a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/queue/front.html">front</a>());</div>
<div class="line"><span class="lineno"> 51</span> <a class="code hl_variable" href="../../db/d5b/structdata__structures_1_1stack__using__queue_1_1_stack.html#acf8ca54d5dd6676f255fff3dedacc7c6">main_q</a>.<a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/queue/pop.html">pop</a>();</div>
<div class="line"><span class="lineno"> 52</span> }</div>
<div class="line"><span class="lineno"> 53</span> <a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/algorithm/swap.html">swap</a>(<a class="code hl_variable" href="../../db/d5b/structdata__structures_1_1stack__using__queue_1_1_stack.html#acf8ca54d5dd6676f255fff3dedacc7c6">main_q</a>, <a class="code hl_variable" href="../../db/d5b/structdata__structures_1_1stack__using__queue_1_1_stack.html#a2f80f87fc6f6ded938426698bba89323">auxiliary_q</a>);</div>
<div class="line"><span class="lineno"> 54</span> <a class="code hl_variable" href="../../db/d5b/structdata__structures_1_1stack__using__queue_1_1_stack.html#afdfd2f4418c70b1bda50f2c3e416d80b">current_size</a>++;</div>
<div class="line"><span class="lineno"> 55</span> }</div>
<div class="ttc" id="afront_html"><div class="ttname"><a href="http://en.cppreference.com/w/cpp/container/queue/front.html">std::queue::front</a></div><div class="ttdeci">T front(T... args)</div></div>
<div class="ttc" id="apush_html"><div class="ttname"><a href="http://en.cppreference.com/w/cpp/container/queue/push.html">std::queue::push</a></div><div class="ttdeci">T push(T... args)</div></div>
<div class="ttc" id="astructdata__structures_1_1stack__using__queue_1_1_stack_html_a2f80f87fc6f6ded938426698bba89323"><div class="ttname"><a href="../../db/d5b/structdata__structures_1_1stack__using__queue_1_1_stack.html#a2f80f87fc6f6ded938426698bba89323">data_structures::stack_using_queue::Stack::auxiliary_q</a></div><div class="ttdeci">std::queue&lt; int64_t &gt; auxiliary_q</div><div class="ttdef"><b>Definition:</b> stack_using_queue.cpp:32</div></div>
<div class="ttc" id="aswap_html"><div class="ttname"><a href="http://en.cppreference.com/w/cpp/algorithm/swap.html">std::swap</a></div><div class="ttdeci">T swap(T... args)</div></div>
</div><!-- fragment -->
</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/d5b/structdata__structures_1_1stack__using__queue_1_1_stack_af04a8f3536a52d8c9916086b656eefc2_cgraph.svg" width="366" height="190"><p><b>This browser is not able to show SVG: try Firefox, Chrome, Safari, or Opera instead.</b></p></iframe>
</div>
</div>
</div>
</div>
<a id="ac0ddec9ab8f778dad23ec446d7a77b39" name="ac0ddec9ab8f778dad23ec446d7a77b39"></a>
@@ -239,7 +261,7 @@ uint32_t&#160;</td><td class="memItemRight" valign="bottom"><b>current_size</b>
<p>Utility function to return the current size of the stack. </p>
<dl class="section return"><dt>Returns</dt><dd>current size of stack </dd></dl>
<div class="fragment"><div class="line"><a id="l00073" name="l00073"></a><span class="lineno"> 73</span>{ <span class="keywordflow">return</span> <a class="code hl_variable" href="../../db/d5b/structdata__structures_1_1stack__using__queue_1_1_stack.html#afdfd2f4418c70b1bda50f2c3e416d80b">current_size</a>; }</div>
<div class="fragment"><div class="line"><span class="lineno"> 73</span>{ <span class="keywordflow">return</span> <a class="code hl_variable" href="../../db/d5b/structdata__structures_1_1stack__using__queue_1_1_stack.html#afdfd2f4418c70b1bda50f2c3e416d80b">current_size</a>; }</div>
</div><!-- fragment -->
</div>
</div>
@@ -266,8 +288,14 @@ uint32_t&#160;</td><td class="memItemRight" valign="bottom"><b>current_size</b>
</table>
</div><div class="memdoc">
<p >Returns the top most element of the stack </p><dl class="section return"><dt>Returns</dt><dd>top element of the queue </dd></dl>
<div class="fragment"><div class="line"><a id="l00040" name="l00040"></a><span class="lineno"> 40</span>{ <span class="keywordflow">return</span> <a class="code hl_variable" href="../../db/d5b/structdata__structures_1_1stack__using__queue_1_1_stack.html#acf8ca54d5dd6676f255fff3dedacc7c6">main_q</a>.front(); }</div>
</div><!-- fragment -->
<div class="fragment"><div class="line"><span class="lineno"> 40</span>{ <span class="keywordflow">return</span> <a class="code hl_variable" href="../../db/d5b/structdata__structures_1_1stack__using__queue_1_1_stack.html#acf8ca54d5dd6676f255fff3dedacc7c6">main_q</a>.<a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/queue/front.html">front</a>(); }</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/d5b/structdata__structures_1_1stack__using__queue_1_1_stack_a5540434e1b41245205eee86f664906f7_cgraph.svg" width="347" height="52"><p><b>This browser is not able to show SVG: try Firefox, Chrome, Safari, or Opera instead.</b></p></iframe>
</div>
</div>
</div>
</div>
<h2 class="groupheader">Member Data Documentation</h2>
@@ -295,7 +323,7 @@ uint32_t&#160;</td><td class="memItemRight" valign="bottom"><b>current_size</b>
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
<ul>
<li class="navelem"><a class="el" href="../../d5/d3c/namespacedata__structures.html">data_structures</a></li><li class="navelem"><b>stack_using_queue</b></li><li class="navelem"><a class="el" href="../../db/d5b/structdata__structures_1_1stack__using__queue_1_1_stack.html">Stack</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>

View File

@@ -0,0 +1,4 @@
<map id="data_structures::stack_using_queue::Stack::top" name="data_structures::stack_using_queue::Stack::top">
<area shape="rect" id="node1" title=" " alt="" coords="5,5,176,47"/>
<area shape="rect" id="node2" href="/Users/runner/work/C-Plus-Plus/C-Plus-Plus/doc/cppreference-doxygen-web.tag.xml$cpp/container/queue/front#" title=" " alt="" coords="224,13,341,39"/>
</map>

View File

@@ -0,0 +1 @@
f56a9ba5e004b41e4264e9a5fc8151c2

View File

@@ -0,0 +1,38 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<!-- Generated by graphviz version 2.50.0 (20211204.2007)
-->
<!-- Title: data_structures::stack_using_queue::Stack::top Pages: 1 -->
<svg width="260pt" height="39pt"
viewBox="0.00 0.00 260.00 39.00" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<g id="graph0" class="graph" transform="scale(1 1) rotate(0) translate(4 35)">
<title>data_structures::stack_using_queue::Stack::top</title>
<polygon fill="white" stroke="transparent" points="-4,4 -4,-35 256,-35 256,4 -4,4"/>
<!-- Node1 -->
<g id="node1" class="node">
<title>Node1</title>
<g id="a_node1"><a xlink:title=" ">
<polygon fill="#bfbfbf" stroke="black" points="0,-0.5 0,-30.5 128,-30.5 128,-0.5 0,-0.5"/>
<text text-anchor="start" x="8" y="-18.5" font-family="Helvetica,sans-Serif" font-size="10.00">data_structures::stack</text>
<text text-anchor="middle" x="64" y="-7.5" font-family="Helvetica,sans-Serif" font-size="10.00">_using_queue::Stack::top</text>
</a>
</g>
</g>
<!-- Node2 -->
<g id="node2" class="node">
<title>Node2</title>
<g id="a_node2"><a target="_blank" xlink:href="http://en.cppreference.com/w/cpp/container/queue/front#" xlink:title=" ">
<polygon fill="white" stroke="black" points="164,-6 164,-25 252,-25 252,-6 164,-6"/>
<text text-anchor="middle" x="208" y="-13" font-family="Helvetica,sans-Serif" font-size="10.00">std::queue::front</text>
</a>
</g>
</g>
<!-- Node1&#45;&gt;Node2 -->
<g id="edge1" class="edge">
<title>Node1&#45;&gt;Node2</title>
<path fill="none" stroke="midnightblue" d="M128.11,-15.5C136.55,-15.5 145.14,-15.5 153.39,-15.5"/>
<polygon fill="midnightblue" stroke="midnightblue" points="153.63,-19 163.63,-15.5 153.63,-12 153.63,-19"/>
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 1.8 KiB

View File

@@ -0,0 +1,5 @@
<map id="data_structures::stack_using_queue::Stack::pop" name="data_structures::stack_using_queue::Stack::pop">
<area shape="rect" id="node1" title="Removes the topmost element from the stack." alt="" coords="5,23,179,65"/>
<area shape="rect" id="node2" href="/Users/runner/work/C-Plus-Plus/C-Plus-Plus/doc/cppreference-doxygen-web.tag.xml$cpp/container/queue/empty#" title=" " alt="" coords="227,5,353,32"/>
<area shape="rect" id="node3" href="/Users/runner/work/C-Plus-Plus/C-Plus-Plus/doc/cppreference-doxygen-web.tag.xml$cpp/container/queue/pop#" title=" " alt="" coords="234,56,346,83"/>
</map>

View File

@@ -0,0 +1 @@
26b016fcf183e13e5560a6012db72708

View File

@@ -0,0 +1,53 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<!-- Generated by graphviz version 2.50.0 (20211204.2007)
-->
<!-- Title: data_structures::stack_using_queue::Stack::pop Pages: 1 -->
<svg width="269pt" height="66pt"
viewBox="0.00 0.00 269.00 66.00" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<g id="graph0" class="graph" transform="scale(1 1) rotate(0) translate(4 62)">
<title>data_structures::stack_using_queue::Stack::pop</title>
<polygon fill="white" stroke="transparent" points="-4,4 -4,-62 265,-62 265,4 -4,4"/>
<!-- Node1 -->
<g id="node1" class="node">
<title>Node1</title>
<g id="a_node1"><a xlink:title="Removes the topmost element from the stack.">
<polygon fill="#bfbfbf" stroke="black" points="0,-14 0,-44 130,-44 130,-14 0,-14"/>
<text text-anchor="start" x="8" y="-32" font-family="Helvetica,sans-Serif" font-size="10.00">data_structures::stack</text>
<text text-anchor="middle" x="65" y="-21" font-family="Helvetica,sans-Serif" font-size="10.00">_using_queue::Stack::pop</text>
</a>
</g>
</g>
<!-- Node2 -->
<g id="node2" class="node">
<title>Node2</title>
<g id="a_node2"><a target="_blank" xlink:href="http://en.cppreference.com/w/cpp/container/queue/empty#" xlink:title=" ">
<polygon fill="white" stroke="black" points="166,-38.5 166,-57.5 261,-57.5 261,-38.5 166,-38.5"/>
<text text-anchor="middle" x="213.5" y="-45.5" font-family="Helvetica,sans-Serif" font-size="10.00">std::queue::empty</text>
</a>
</g>
</g>
<!-- Node1&#45;&gt;Node2 -->
<g id="edge1" class="edge">
<title>Node1&#45;&gt;Node2</title>
<path fill="none" stroke="midnightblue" d="M130.26,-37.33C138.78,-38.44 147.48,-39.57 155.86,-40.65"/>
<polygon fill="midnightblue" stroke="midnightblue" points="155.54,-44.14 165.9,-41.96 156.44,-37.2 155.54,-44.14"/>
</g>
<!-- Node3 -->
<g id="node3" class="node">
<title>Node3</title>
<g id="a_node3"><a target="_blank" xlink:href="http://en.cppreference.com/w/cpp/container/queue/pop#" xlink:title=" ">
<polygon fill="white" stroke="black" points="171.5,-0.5 171.5,-19.5 255.5,-19.5 255.5,-0.5 171.5,-0.5"/>
<text text-anchor="middle" x="213.5" y="-7.5" font-family="Helvetica,sans-Serif" font-size="10.00">std::queue::pop</text>
</a>
</g>
</g>
<!-- Node1&#45;&gt;Node3 -->
<g id="edge2" class="edge">
<title>Node1&#45;&gt;Node3</title>
<path fill="none" stroke="midnightblue" d="M130.26,-20.67C140.64,-19.32 151.27,-17.94 161.29,-16.64"/>
<polygon fill="midnightblue" stroke="midnightblue" points="162.02,-20.08 171.48,-15.32 161.12,-13.13 162.02,-20.08"/>
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 2.6 KiB

View File

@@ -0,0 +1,7 @@
<map id="data_structures::stack_using_queue::Stack::push" name="data_structures::stack_using_queue::Stack::push">
<area shape="rect" id="node1" title="Inserts an element to the top of the stack." alt="" coords="5,74,185,115"/>
<area shape="rect" id="node2" href="/Users/runner/work/C-Plus-Plus/C-Plus-Plus/doc/cppreference-doxygen-web.tag.xml$cpp/container/queue/empty#" title=" " alt="" coords="233,5,360,32"/>
<area shape="rect" id="node3" href="/Users/runner/work/C-Plus-Plus/C-Plus-Plus/doc/cppreference-doxygen-web.tag.xml$cpp/container/queue/front#" title=" " alt="" coords="238,56,355,83"/>
<area shape="rect" id="node4" href="/Users/runner/work/C-Plus-Plus/C-Plus-Plus/doc/cppreference-doxygen-web.tag.xml$cpp/container/queue/pop#" title=" " alt="" coords="241,107,353,133"/>
<area shape="rect" id="node5" href="/Users/runner/work/C-Plus-Plus/C-Plus-Plus/doc/cppreference-doxygen-web.tag.xml$cpp/container/queue/push#" title=" " alt="" coords="237,157,356,184"/>
</map>

View File

@@ -0,0 +1 @@
c707b2764b967d85f9846c2ce427e200

View File

@@ -0,0 +1,83 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<!-- Generated by graphviz version 2.50.0 (20211204.2007)
-->
<!-- Title: data_structures::stack_using_queue::Stack::push Pages: 1 -->
<svg width="274pt" height="142pt"
viewBox="0.00 0.00 274.00 142.00" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<g id="graph0" class="graph" transform="scale(1 1) rotate(0) translate(4 138)">
<title>data_structures::stack_using_queue::Stack::push</title>
<polygon fill="white" stroke="transparent" points="-4,4 -4,-138 270,-138 270,4 -4,4"/>
<!-- Node1 -->
<g id="node1" class="node">
<title>Node1</title>
<g id="a_node1"><a xlink:title="Inserts an element to the top of the stack.">
<polygon fill="#bfbfbf" stroke="black" points="0,-52 0,-82 135,-82 135,-52 0,-52"/>
<text text-anchor="start" x="8" y="-70" font-family="Helvetica,sans-Serif" font-size="10.00">data_structures::stack</text>
<text text-anchor="middle" x="67.5" y="-59" font-family="Helvetica,sans-Serif" font-size="10.00">_using_queue::Stack::push</text>
</a>
</g>
</g>
<!-- Node2 -->
<g id="node2" class="node">
<title>Node2</title>
<g id="a_node2"><a target="_blank" xlink:href="http://en.cppreference.com/w/cpp/container/queue/empty#" xlink:title=" ">
<polygon fill="white" stroke="black" points="171,-114.5 171,-133.5 266,-133.5 266,-114.5 171,-114.5"/>
<text text-anchor="middle" x="218.5" y="-121.5" font-family="Helvetica,sans-Serif" font-size="10.00">std::queue::empty</text>
</a>
</g>
</g>
<!-- Node1&#45;&gt;Node2 -->
<g id="edge1" class="edge">
<title>Node1&#45;&gt;Node2</title>
<path fill="none" stroke="midnightblue" d="M108.04,-82.13C131.32,-91.03 160.49,-102.19 182.87,-110.75"/>
<polygon fill="midnightblue" stroke="midnightblue" points="181.72,-114.06 192.31,-114.36 184.22,-107.52 181.72,-114.06"/>
</g>
<!-- Node3 -->
<g id="node3" class="node">
<title>Node3</title>
<g id="a_node3"><a target="_blank" xlink:href="http://en.cppreference.com/w/cpp/container/queue/front#" xlink:title=" ">
<polygon fill="white" stroke="black" points="174.5,-76.5 174.5,-95.5 262.5,-95.5 262.5,-76.5 174.5,-76.5"/>
<text text-anchor="middle" x="218.5" y="-83.5" font-family="Helvetica,sans-Serif" font-size="10.00">std::queue::front</text>
</a>
</g>
</g>
<!-- Node1&#45;&gt;Node3 -->
<g id="edge2" class="edge">
<title>Node1&#45;&gt;Node3</title>
<path fill="none" stroke="midnightblue" d="M135.16,-75.5C144.94,-76.75 154.91,-78.02 164.38,-79.23"/>
<polygon fill="midnightblue" stroke="midnightblue" points="164.06,-82.71 174.42,-80.51 164.94,-75.77 164.06,-82.71"/>
</g>
<!-- Node4 -->
<g id="node4" class="node">
<title>Node4</title>
<g id="a_node4"><a target="_blank" xlink:href="http://en.cppreference.com/w/cpp/container/queue/pop#" xlink:title=" ">
<polygon fill="white" stroke="black" points="176.5,-38.5 176.5,-57.5 260.5,-57.5 260.5,-38.5 176.5,-38.5"/>
<text text-anchor="middle" x="218.5" y="-45.5" font-family="Helvetica,sans-Serif" font-size="10.00">std::queue::pop</text>
</a>
</g>
</g>
<!-- Node1&#45;&gt;Node4 -->
<g id="edge3" class="edge">
<title>Node1&#45;&gt;Node4</title>
<path fill="none" stroke="midnightblue" d="M135.16,-58.5C145.51,-57.18 156.06,-55.83 166.01,-54.57"/>
<polygon fill="midnightblue" stroke="midnightblue" points="166.65,-58.01 176.13,-53.28 165.76,-51.07 166.65,-58.01"/>
</g>
<!-- Node5 -->
<g id="node5" class="node">
<title>Node5</title>
<g id="a_node5"><a target="_blank" xlink:href="http://en.cppreference.com/w/cpp/container/queue/push#" xlink:title=" ">
<polygon fill="white" stroke="black" points="174,-0.5 174,-19.5 263,-19.5 263,-0.5 174,-0.5"/>
<text text-anchor="middle" x="218.5" y="-7.5" font-family="Helvetica,sans-Serif" font-size="10.00">std::queue::push</text>
</a>
</g>
</g>
<!-- Node1&#45;&gt;Node5 -->
<g id="edge4" class="edge">
<title>Node1&#45;&gt;Node5</title>
<path fill="none" stroke="midnightblue" d="M108.04,-51.87C131.32,-42.97 160.49,-31.81 182.87,-23.25"/>
<polygon fill="midnightblue" stroke="midnightblue" points="184.22,-26.48 192.31,-19.64 181.72,-19.94 184.22,-26.48"/>
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 4.1 KiB

View File

@@ -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++: Member List</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">&#160;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&amp;dn=expat.txt MIT */
var searchBox = new SearchBox("searchBox", "../../search",'Search','.html');
@@ -105,7 +105,7 @@ $(document).ready(function(){initNavTree('d1/df6/class_easter_year_month_day.htm
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
<ul>
<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>

View File

@@ -0,0 +1,5 @@
<map id="math::ncr_modulo_p::NCRModuloP" name="math::ncr_modulo_p::NCRModuloP">
<area shape="rect" id="node1" title="Class which contains all methods required for calculating nCr mod p." alt="" coords="13,184,153,225"/>
<area shape="rect" id="node2" href="/Users/runner/work/C-Plus-Plus/C-Plus-Plus/doc/cppreference-doxygen-web.tag.xml$cpp/container/vector" title=" " alt="" coords="5,95,160,121"/>
<area shape="rect" id="node3" href="/Users/runner/work/C-Plus-Plus/C-Plus-Plus/doc/cppreference-doxygen-web.tag.xml$cpp/types/integer" title=" " alt="" coords="35,5,130,32"/>
</map>

Some files were not shown because too many files have changed in this diff Show More