Documentation for 0d766b0f8a

This commit is contained in:
realstealthninja
2024-11-04 12:32:06 +00:00
parent fb1d00ead7
commit 4fb6e622e9
280 changed files with 2978 additions and 4001 deletions

View File

@@ -298,7 +298,7 @@ Here is the call graph for this function:</div>
</div><!-- fragment --><p> <img src="https://raw.githubusercontent.com/TheAlgorithms/C-Plus-Plus/docs/images/machine_learning/kohonen/test1.svg" alt="Sample execution
output" style="pointer-events: none;" class="inline"/> </p>
<div class="fragment"><div class="line"><span class="lineno"> 233</span> {</div>
<div class="line"><span class="lineno"> 234</span> <span class="keywordtype">int</span> j = 0, <a class="code hl_variable" href="../../d6/d42/data__structures_2sparse__table_8cpp.html#a10f3ffb3f6f7e1b83d556b9c8de89a5d">N</a> = 500;</div>
<div class="line"><span class="lineno"> 234</span> <span class="keywordtype">int</span> j = 0, <a class="code hl_variable" href="../../d8/dab/sparse__table_8cpp.html#a10f3ffb3f6f7e1b83d556b9c8de89a5d">N</a> = 500;</div>
<div class="line"><span class="lineno"> 235</span> <span class="keywordtype">int</span> features = 2;</div>
<div class="line"><span class="lineno"> 236</span> <span class="keywordtype">int</span> num_out = 50;</div>
<div class="line"><span class="lineno"> 237</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector&lt;std::valarray&lt;double&gt;</a>&gt; X(N);</div>
@@ -327,11 +327,11 @@ Here is the call graph for this function:</div>
<div class="line"><span class="lineno"> 260</span> kohonen_som_tracer(X, &amp;W, 0.1); <span class="comment">// train the SOM</span></div>
<div class="line"><span class="lineno"> 261</span> <a class="code hl_function" href="../../d9/d66/group__machine__learning.html#gae0208548f8b393528e5db01717e88e67">save_nd_data</a>(<span class="stringliteral">&quot;w12.csv&quot;</span>, W); <span class="comment">// save the resultant weights</span></div>
<div class="line"><span class="lineno"> 262</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:48</div></div>
<div class="ttc" id="agroup__machine__learning_html_gae0208548f8b393528e5db01717e88e67"><div class="ttname"><a href="../../d9/d66/group__machine__learning.html#gae0208548f8b393528e5db01717e88e67">save_nd_data</a></div><div class="ttdeci">int save_nd_data(const char *fname, const std::vector&lt; std::valarray&lt; double &gt; &gt; &amp;X)</div><div class="ttdef"><b>Definition</b> kohonen_som_trace.cpp:58</div></div>
<div class="ttc" id="agroup__machine__learning_html_gaf5ce14f026d6d231bef29161bac2b485"><div class="ttname"><a href="../../d9/d66/group__machine__learning.html#gaf5ce14f026d6d231bef29161bac2b485">_random</a></div><div class="ttdeci">double _random(double a, double b)</div><div class="ttdef"><b>Definition</b> kohonen_som_topology.cpp:53</div></div>
<div class="ttc" id="akohonen__som__trace_8cpp_html_ae571600aa42a81bc14a4a602ea5ff00d"><div class="ttname"><a href="#ae571600aa42a81bc14a4a602ea5ff00d">test_circle</a></div><div class="ttdeci">void test_circle(std::vector&lt; std::valarray&lt; double &gt; &gt; *data)</div><div class="ttdef"><b>Definition</b> kohonen_som_trace.cpp:196</div></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="asparse__table_8cpp_html_a10f3ffb3f6f7e1b83d556b9c8de89a5d"><div class="ttname"><a href="../../d8/dab/sparse__table_8cpp.html#a10f3ffb3f6f7e1b83d556b9c8de89a5d">data_structures::sparse_table::N</a></div><div class="ttdeci">constexpr uint32_t N</div><div class="ttdoc">A struct to represent sparse table for min() as their invariant function, for the given array A....</div><div class="ttdef"><b>Definition</b> sparse_table.cpp:48</div></div>
<div class="ttc" id="avalarray_html"><div class="ttname"><a href="http://en.cppreference.com/w/cpp/numeric/valarray.html">std::valarray</a></div></div>
<div 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">
@@ -368,7 +368,7 @@ Here is the call graph for this function:</div>
</div><!-- fragment --><p> <img src="https://raw.githubusercontent.com/TheAlgorithms/C-Plus-Plus/docs/images/machine_learning/kohonen/test2.svg" alt="Sample execution
output" style="pointer-events: none;" class="inline"/> </p>
<div class="fragment"><div class="line"><span class="lineno"> 315</span> {</div>
<div class="line"><span class="lineno"> 316</span> <span class="keywordtype">int</span> j = 0, <a class="code hl_variable" href="../../d6/d42/data__structures_2sparse__table_8cpp.html#a10f3ffb3f6f7e1b83d556b9c8de89a5d">N</a> = 500;</div>
<div class="line"><span class="lineno"> 316</span> <span class="keywordtype">int</span> j = 0, <a class="code hl_variable" href="../../d8/dab/sparse__table_8cpp.html#a10f3ffb3f6f7e1b83d556b9c8de89a5d">N</a> = 500;</div>
<div class="line"><span class="lineno"> 317</span> <span class="keywordtype">int</span> features = 2;</div>
<div class="line"><span class="lineno"> 318</span> <span class="keywordtype">int</span> num_out = 20;</div>
<div class="line"><span class="lineno"> 319</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector&lt;std::valarray&lt;double&gt;</a>&gt; X(N);</div>
@@ -432,7 +432,7 @@ Here is the call graph for this function:</div>
</div><!-- fragment --><p> <img src="https://raw.githubusercontent.com/TheAlgorithms/C-Plus-Plus/docs/images/machine_learning/kohonen/test3.svg" alt="Sample execution
output" style="pointer-events: none;" class="inline"/> </p>
<div class="fragment"><div class="line"><span class="lineno"> 414</span> {</div>
<div class="line"><span class="lineno"> 415</span> <span class="keywordtype">int</span> j = 0, <a class="code hl_variable" href="../../d6/d42/data__structures_2sparse__table_8cpp.html#a10f3ffb3f6f7e1b83d556b9c8de89a5d">N</a> = 200;</div>
<div class="line"><span class="lineno"> 415</span> <span class="keywordtype">int</span> j = 0, <a class="code hl_variable" href="../../d8/dab/sparse__table_8cpp.html#a10f3ffb3f6f7e1b83d556b9c8de89a5d">N</a> = 200;</div>
<div class="line"><span class="lineno"> 416</span> <span class="keywordtype">int</span> features = 3;</div>
<div class="line"><span class="lineno"> 417</span> <span class="keywordtype">int</span> num_out = 20;</div>
<div class="line"><span class="lineno"> 418</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector&lt;std::valarray&lt;double&gt;</a>&gt; X(N);</div>
@@ -501,7 +501,7 @@ Here is the call graph for this function:</div>
</dd>
</dl>
<div class="fragment"><div class="line"><span class="lineno"> 359</span> {</div>
<div class="line"><span class="lineno"> 360</span> <span class="keyword">const</span> <span class="keywordtype">int</span> <a class="code hl_variable" href="../../d6/d42/data__structures_2sparse__table_8cpp.html#a10f3ffb3f6f7e1b83d556b9c8de89a5d">N</a> = <a class="code hl_variable" href="../../d1/df3/hash__search_8cpp.html#a6e1a77282bc65ad359d753d25df23243">data</a>-&gt;size();</div>
<div class="line"><span class="lineno"> 360</span> <span class="keyword">const</span> <span class="keywordtype">int</span> <a class="code hl_variable" href="../../d8/dab/sparse__table_8cpp.html#a10f3ffb3f6f7e1b83d556b9c8de89a5d">N</a> = <a class="code hl_variable" href="../../d1/df3/hash__search_8cpp.html#a6e1a77282bc65ad359d753d25df23243">data</a>-&gt;size();</div>
<div class="line"><span class="lineno"> 361</span> <span class="keyword">const</span> <span class="keywordtype">double</span> R = 0.1; <span class="comment">// radius of cluster</span></div>
<div class="line"><span class="lineno"> 362</span> <span class="keywordtype">int</span> i = 0;</div>
<div class="line"><span class="lineno"> 363</span> <span class="keyword">const</span> <span class="keywordtype">int</span> num_classes = 8;</div>
@@ -520,7 +520,7 @@ Here is the call graph for this function:</div>
<div class="line"><span class="lineno"> 376</span><span class="preprocessor">#ifdef _OPENMP</span></div>
<div class="line"><span class="lineno"> 377</span><span class="preprocessor">#pragma omp for</span></div>
<div class="line"><span class="lineno"> 378</span><span class="preprocessor">#endif</span></div>
<div class="line"><span class="lineno"> 379</span> <span class="keywordflow">for</span> (i = 0; 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"> 379</span> <span class="keywordflow">for</span> (i = 0; i &lt; <a class="code hl_variable" href="../../d8/dab/sparse__table_8cpp.html#a10f3ffb3f6f7e1b83d556b9c8de89a5d">N</a>; i++) {</div>
<div class="line"><span class="lineno"> 380</span> <span class="keywordtype">int</span> cls =</div>
<div class="line"><span class="lineno"> 381</span> <a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/numeric/random/rand.html">std::rand</a>() % num_classes; <span class="comment">// select a random class for the point</span></div>
<div class="line"><span class="lineno"> 382</span> </div>
@@ -575,7 +575,7 @@ y &amp;=&amp; r\sin\theta
</dd>
</dl>
<div class="fragment"><div class="line"><span class="lineno"> 196</span> {</div>
<div class="line"><span class="lineno"> 197</span> <span class="keyword">const</span> <span class="keywordtype">int</span> <a class="code hl_variable" href="../../d6/d42/data__structures_2sparse__table_8cpp.html#a10f3ffb3f6f7e1b83d556b9c8de89a5d">N</a> = <a class="code hl_variable" href="../../d1/df3/hash__search_8cpp.html#a6e1a77282bc65ad359d753d25df23243">data</a>-&gt;size();</div>
<div class="line"><span class="lineno"> 197</span> <span class="keyword">const</span> <span class="keywordtype">int</span> <a class="code hl_variable" href="../../d8/dab/sparse__table_8cpp.html#a10f3ffb3f6f7e1b83d556b9c8de89a5d">N</a> = <a class="code hl_variable" href="../../d1/df3/hash__search_8cpp.html#a6e1a77282bc65ad359d753d25df23243">data</a>-&gt;size();</div>
<div class="line"><span class="lineno"> 198</span> <span class="keyword">const</span> <span class="keywordtype">double</span> R = 0.75, dr = 0.3;</div>
<div class="line"><span class="lineno"> 199</span> <span class="keywordtype">double</span> a_t = 0., b_t = 2.f * M_PI; <span class="comment">// theta random between 0 and 2*pi</span></div>
<div class="line"><span class="lineno"> 200</span> <span class="keywordtype">double</span> a_r = R - dr, b_r = R + dr; <span class="comment">// radius random between R-dr and R+dr</span></div>
@@ -584,7 +584,7 @@ y &amp;=&amp; r\sin\theta
<div class="line"><span class="lineno"> 203</span><span class="preprocessor">#ifdef _OPENMP</span></div>
<div class="line"><span class="lineno"> 204</span><span class="preprocessor">#pragma omp for</span></div>
<div class="line"><span class="lineno"> 205</span><span class="preprocessor">#endif</span></div>
<div class="line"><span class="lineno"> 206</span> <span class="keywordflow">for</span> (i = 0; 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"> 206</span> <span class="keywordflow">for</span> (i = 0; i &lt; <a class="code hl_variable" href="../../d8/dab/sparse__table_8cpp.html#a10f3ffb3f6f7e1b83d556b9c8de89a5d">N</a>; i++) {</div>
<div class="line"><span class="lineno"> 207</span> <span class="keywordtype">double</span> r = <a class="code hl_function" href="../../d9/d66/group__machine__learning.html#gaf5ce14f026d6d231bef29161bac2b485">_random</a>(a_r, b_r); <span class="comment">// random radius</span></div>
<div class="line"><span class="lineno"> 208</span> <span class="keywordtype">double</span> theta = <a class="code hl_function" href="../../d9/d66/group__machine__learning.html#gaf5ce14f026d6d231bef29161bac2b485">_random</a>(a_t, b_t); <span class="comment">// random theta</span></div>
<div class="line"><span class="lineno"> 209</span> <a class="code hl_variable" href="../../d1/df3/hash__search_8cpp.html#a6e1a77282bc65ad359d753d25df23243">data</a>[0][i][0] = r * <a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/numeric/math/cos.html">cos</a>(theta); <span class="comment">// convert from polar to cartesian</span></div>
@@ -632,14 +632,14 @@ y &amp;=&amp; \delta y + \frac{\sin(2\theta)}{2}
</dd>
</dl>
<div class="fragment"><div class="line"><span class="lineno"> 277</span> {</div>
<div class="line"><span class="lineno"> 278</span> <span class="keyword">const</span> <span class="keywordtype">int</span> <a class="code hl_variable" href="../../d6/d42/data__structures_2sparse__table_8cpp.html#a10f3ffb3f6f7e1b83d556b9c8de89a5d">N</a> = <a class="code hl_variable" href="../../d1/df3/hash__search_8cpp.html#a6e1a77282bc65ad359d753d25df23243">data</a>-&gt;size();</div>
<div class="line"><span class="lineno"> 278</span> <span class="keyword">const</span> <span class="keywordtype">int</span> <a class="code hl_variable" href="../../d8/dab/sparse__table_8cpp.html#a10f3ffb3f6f7e1b83d556b9c8de89a5d">N</a> = <a class="code hl_variable" href="../../d1/df3/hash__search_8cpp.html#a6e1a77282bc65ad359d753d25df23243">data</a>-&gt;size();</div>
<div class="line"><span class="lineno"> 279</span> <span class="keyword">const</span> <span class="keywordtype">double</span> dr = 0.2;</div>
<div class="line"><span class="lineno"> 280</span> <span class="keywordtype">int</span> i = 0;</div>
<div class="line"><span class="lineno"> 281</span> </div>
<div class="line"><span class="lineno"> 282</span><span class="preprocessor">#ifdef _OPENMP</span></div>
<div class="line"><span class="lineno"> 283</span><span class="preprocessor">#pragma omp for</span></div>
<div class="line"><span class="lineno"> 284</span><span class="preprocessor">#endif</span></div>
<div class="line"><span class="lineno"> 285</span> <span class="keywordflow">for</span> (i = 0; 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"> 285</span> <span class="keywordflow">for</span> (i = 0; i &lt; <a class="code hl_variable" href="../../d8/dab/sparse__table_8cpp.html#a10f3ffb3f6f7e1b83d556b9c8de89a5d">N</a>; i++) {</div>
<div class="line"><span class="lineno"> 286</span> <span class="keywordtype">double</span> dx = <a class="code hl_function" href="../../d9/d66/group__machine__learning.html#gaf5ce14f026d6d231bef29161bac2b485">_random</a>(-dr, dr); <span class="comment">// random change in x</span></div>
<div class="line"><span class="lineno"> 287</span> <span class="keywordtype">double</span> dy = <a class="code hl_function" href="../../d9/d66/group__machine__learning.html#gaf5ce14f026d6d231bef29161bac2b485">_random</a>(-dr, dr); <span class="comment">// random change in y</span></div>
<div class="line"><span class="lineno"> 288</span> <span class="keywordtype">double</span> theta = <a class="code hl_function" href="../../d9/d66/group__machine__learning.html#gaf5ce14f026d6d231bef29161bac2b485">_random</a>(0, M_PI); <span class="comment">// random theta</span></div>

View File

@@ -0,0 +1,17 @@
<map id="graph/dijkstra.cpp" name="graph/dijkstra.cpp">
<area shape="rect" id="Node000001" title="[Graph Dijkstras Shortest Path Algorithm (Dijkstra&#39;s Shortest Path)] (https://en.wikipedia...." alt="" coords="237,5,361,31"/>
<area shape="rect" id="Node000002" title=" " alt="" coords="5,79,70,105"/>
<area shape="poly" id="edge1_Node000001_Node000002" title=" " alt="" coords="255,34,85,80,84,75,254,29"/>
<area shape="rect" id="Node000003" title=" " alt="" coords="94,79,165,105"/>
<area shape="poly" id="edge2_Node000001_Node000003" title=" " alt="" coords="271,34,174,75,171,70,269,29"/>
<area shape="rect" id="Node000004" title=" " alt="" coords="189,79,241,105"/>
<area shape="poly" id="edge3_Node000001_Node000004" title=" " alt="" coords="286,34,242,71,239,67,283,30"/>
<area shape="rect" id="Node000005" title=" " alt="" coords="265,79,333,105"/>
<area shape="poly" id="edge4_Node000001_Node000005" title=" " alt="" coords="302,31,302,63,296,63,296,31"/>
<area shape="rect" id="Node000006" title=" " alt="" coords="357,79,414,105"/>
<area shape="poly" id="edge5_Node000001_Node000006" title=" " alt="" coords="315,29,361,67,358,71,312,34"/>
<area shape="rect" id="Node000007" title=" " alt="" coords="438,79,490,105"/>
<area shape="poly" id="edge6_Node000001_Node000007" title=" " alt="" coords="328,29,425,71,423,76,326,34"/>
<area shape="rect" id="Node000008" title=" " alt="" coords="514,79,572,105"/>
<area shape="poly" id="edge7_Node000001_Node000008" title=" " alt="" coords="341,29,500,75,499,80,339,34"/>
</map>

View File

@@ -0,0 +1 @@
dd22792398b6735ac010a60b2f729231

View File

@@ -0,0 +1,173 @@
<?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 12.1.2 (20240928.0832)
-->
<!-- Title: graph/dijkstra.cpp Pages: 1 -->
<svg width="433pt" height="83pt"
viewBox="0.00 0.00 432.62 82.50" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<svg id="main" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve">
<style type="text/css"><![CDATA[
.node, .edge {opacity: 0.7;}
.node.selected, .edge.selected {opacity: 1;}
.edge:hover path { stroke: red; }
.edge:hover polygon { stroke: red; fill: red; }
]]></style>
<script type="application/ecmascript" xlink:href="../../svg.min.js"/>
<svg id="graph" class="graph">
<g id="graph0" class="graph" transform="scale(1 1) rotate(0) translate(4 78.5)">
<title>graph/dijkstra.cpp</title>
<!-- Node1 -->
<g id="Node000001" class="node">
<title>Node1</title>
<g id="a_Node000001"><a xlink:title="[Graph Dijkstras Shortest Path Algorithm (Dijkstra&#39;s Shortest Path)] (https://en.wikipedia....">
<polygon fill="#999999" stroke="#666666" points="266.75,-74.5 173.5,-74.5 173.5,-55.25 266.75,-55.25 266.75,-74.5"/>
<text text-anchor="middle" x="220.12" y="-61" font-family="Helvetica,sans-Serif" font-size="10.00">graph/dijkstra.cpp</text>
</a>
</g>
</g>
<!-- Node2 -->
<g id="Node000002" class="node">
<title>Node2</title>
<g id="a_Node000002"><a xlink:title=" ">
<polygon fill="#e0e0e0" stroke="#999999" points="48.25,-19.25 0,-19.25 0,0 48.25,0 48.25,-19.25"/>
<text text-anchor="middle" x="24.12" y="-5.75" font-family="Helvetica,sans-Serif" font-size="10.00">cassert</text>
</a>
</g>
</g>
<!-- Node1&#45;&gt;Node2 -->
<g id="edge1_Node000001_Node000002" class="edge">
<title>Node1&#45;&gt;Node2</title>
<g id="a_edge1_Node000001_Node000002"><a xlink:title=" ">
<path fill="none" stroke="#63b8ff" d="M186.88,-54.84C151.5,-45.23 95.74,-30.08 59.55,-20.25"/>
<polygon fill="#63b8ff" stroke="#63b8ff" points="60.56,-16.9 50,-17.65 58.73,-23.65 60.56,-16.9"/>
</a>
</g>
</g>
<!-- Node3 -->
<g id="Node000003" class="node">
<title>Node3</title>
<g id="a_Node000003"><a xlink:title=" ">
<polygon fill="#e0e0e0" stroke="#999999" points="119.88,-19.25 66.38,-19.25 66.38,0 119.88,0 119.88,-19.25"/>
<text text-anchor="middle" x="93.12" y="-5.75" font-family="Helvetica,sans-Serif" font-size="10.00">iostream</text>
</a>
</g>
</g>
<!-- Node1&#45;&gt;Node3 -->
<g id="edge2_Node000001_Node000003" class="edge">
<title>Node1&#45;&gt;Node3</title>
<g id="a_edge2_Node000001_Node000003"><a xlink:title=" ">
<path fill="none" stroke="#63b8ff" d="M198.58,-54.84C178.51,-46.43 148.32,-33.77 125.38,-24.15"/>
<polygon fill="#63b8ff" stroke="#63b8ff" points="126.75,-20.93 116.17,-20.29 124.04,-27.38 126.75,-20.93"/>
</a>
</g>
</g>
<!-- Node4 -->
<g id="Node000004" class="node">
<title>Node4</title>
<g id="a_Node000004"><a xlink:title=" ">
<polygon fill="#e0e0e0" stroke="#999999" points="176.75,-19.25 137.5,-19.25 137.5,0 176.75,0 176.75,-19.25"/>
<text text-anchor="middle" x="157.12" y="-5.75" font-family="Helvetica,sans-Serif" font-size="10.00">limits</text>
</a>
</g>
</g>
<!-- Node1&#45;&gt;Node4 -->
<g id="edge3_Node000001_Node000004" class="edge">
<title>Node1&#45;&gt;Node4</title>
<g id="a_edge3_Node000001_Node000004"><a xlink:title=" ">
<path fill="none" stroke="#63b8ff" d="M209.44,-54.84C200.42,-47.22 187.29,-36.12 176.44,-26.95"/>
<polygon fill="#63b8ff" stroke="#63b8ff" points="178.71,-24.28 168.81,-20.5 174.19,-29.63 178.71,-24.28"/>
</a>
</g>
</g>
<!-- Node5 -->
<g id="Node000005" class="node">
<title>Node5</title>
<g id="a_Node000005"><a xlink:title=" ">
<polygon fill="#e0e0e0" stroke="#999999" points="245.75,-19.25 194.5,-19.25 194.5,0 245.75,0 245.75,-19.25"/>
<text text-anchor="middle" x="220.12" y="-5.75" font-family="Helvetica,sans-Serif" font-size="10.00">memory</text>
</a>
</g>
</g>
<!-- Node1&#45;&gt;Node5 -->
<g id="edge4_Node000001_Node000005" class="edge">
<title>Node1&#45;&gt;Node5</title>
<g id="a_edge4_Node000001_Node000005"><a xlink:title=" ">
<path fill="none" stroke="#63b8ff" d="M220.12,-55.08C220.12,-48.57 220.12,-39.42 220.12,-31.12"/>
<polygon fill="#63b8ff" stroke="#63b8ff" points="223.63,-31.12 220.13,-21.12 216.63,-31.12 223.63,-31.12"/>
</a>
</g>
</g>
<!-- Node6 -->
<g id="Node000006" class="node">
<title>Node6</title>
<g id="a_Node000006"><a xlink:title=" ">
<polygon fill="#e0e0e0" stroke="#999999" points="306.25,-19.25 264,-19.25 264,0 306.25,0 306.25,-19.25"/>
<text text-anchor="middle" x="285.12" y="-5.75" font-family="Helvetica,sans-Serif" font-size="10.00">queue</text>
</a>
</g>
</g>
<!-- Node1&#45;&gt;Node6 -->
<g id="edge5_Node000001_Node000006" class="edge">
<title>Node1&#45;&gt;Node6</title>
<g id="a_edge5_Node000001_Node000006"><a xlink:title=" ">
<path fill="none" stroke="#63b8ff" d="M231.15,-54.84C240.55,-47.15 254.27,-35.9 265.53,-26.68"/>
<polygon fill="#63b8ff" stroke="#63b8ff" points="267.57,-29.53 273.09,-20.48 263.14,-24.11 267.57,-29.53"/>
</a>
</g>
</g>
<!-- Node7 -->
<g id="Node000007" class="node">
<title>Node7</title>
<g id="a_Node000007"><a xlink:title=" ">
<polygon fill="#e0e0e0" stroke="#999999" points="363.75,-19.25 324.5,-19.25 324.5,0 363.75,0 363.75,-19.25"/>
<text text-anchor="middle" x="344.12" y="-5.75" font-family="Helvetica,sans-Serif" font-size="10.00">utility</text>
</a>
</g>
</g>
<!-- Node1&#45;&gt;Node7 -->
<g id="edge6_Node000001_Node000007" class="edge">
<title>Node1&#45;&gt;Node7</title>
<g id="a_edge6_Node000001_Node000007"><a xlink:title=" ">
<path fill="none" stroke="#63b8ff" d="M241.16,-54.84C261.11,-46.27 291.31,-33.31 313.85,-23.63"/>
<polygon fill="#63b8ff" stroke="#63b8ff" points="315.02,-26.93 322.83,-19.77 312.26,-20.5 315.02,-26.93"/>
</a>
</g>
</g>
<!-- Node8 -->
<g id="Node000008" class="node">
<title>Node8</title>
<g id="a_Node000008"><a xlink:title=" ">
<polygon fill="#e0e0e0" stroke="#999999" points="424.62,-19.25 381.62,-19.25 381.62,0 424.62,0 424.62,-19.25"/>
<text text-anchor="middle" x="403.12" y="-5.75" font-family="Helvetica,sans-Serif" font-size="10.00">vector</text>
</a>
</g>
</g>
<!-- Node1&#45;&gt;Node8 -->
<g id="edge7_Node000001_Node000008" class="edge">
<title>Node1&#45;&gt;Node8</title>
<g id="a_edge7_Node000001_Node000008"><a xlink:title=" ">
<path fill="none" stroke="#63b8ff" d="M251.17,-54.84C284.33,-45.19 336.68,-29.96 370.46,-20.13"/>
<polygon fill="#63b8ff" stroke="#63b8ff" points="371.07,-23.6 379.69,-17.44 369.11,-16.88 371.07,-23.6"/>
</a>
</g>
</g>
</g>
</svg>
</svg>
<style type='text/css'>
<![CDATA[
[data-mouse-over-selected='false'] { opacity: 0.7; }
[data-mouse-over-selected='true'] { opacity: 1.0; }
]]>
</style>
<script type="application/ecmascript"><![CDATA[
document.addEventListener('DOMContentLoaded', (event) => {
highlightEdges();
highlightAdjacentNodes();
});
]]></script>
</svg>

After

Width:  |  Height:  |  Size: 6.8 KiB

View File

@@ -0,0 +1,147 @@
<?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 12.1.2 (20240928.0832)
-->
<!-- Title: graph/dijkstra.cpp Pages: 1 -->
<svg width="433pt" height="83pt"
viewBox="0.00 0.00 432.62 82.50" 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 78.5)">
<title>graph/dijkstra.cpp</title>
<!-- Node1 -->
<g id="Node000001" class="node">
<title>Node1</title>
<g id="a_Node000001"><a xlink:title="[Graph Dijkstras Shortest Path Algorithm (Dijkstra&#39;s Shortest Path)] (https://en.wikipedia....">
<polygon fill="#999999" stroke="#666666" points="266.75,-74.5 173.5,-74.5 173.5,-55.25 266.75,-55.25 266.75,-74.5"/>
<text text-anchor="middle" x="220.12" y="-61" font-family="Helvetica,sans-Serif" font-size="10.00">graph/dijkstra.cpp</text>
</a>
</g>
</g>
<!-- Node2 -->
<g id="Node000002" class="node">
<title>Node2</title>
<g id="a_Node000002"><a xlink:title=" ">
<polygon fill="#e0e0e0" stroke="#999999" points="48.25,-19.25 0,-19.25 0,0 48.25,0 48.25,-19.25"/>
<text text-anchor="middle" x="24.12" y="-5.75" font-family="Helvetica,sans-Serif" font-size="10.00">cassert</text>
</a>
</g>
</g>
<!-- Node1&#45;&gt;Node2 -->
<g id="edge1_Node000001_Node000002" class="edge">
<title>Node1&#45;&gt;Node2</title>
<g id="a_edge1_Node000001_Node000002"><a xlink:title=" ">
<path fill="none" stroke="#63b8ff" d="M186.88,-54.84C151.5,-45.23 95.74,-30.08 59.55,-20.25"/>
<polygon fill="#63b8ff" stroke="#63b8ff" points="60.56,-16.9 50,-17.65 58.73,-23.65 60.56,-16.9"/>
</a>
</g>
</g>
<!-- Node3 -->
<g id="Node000003" class="node">
<title>Node3</title>
<g id="a_Node000003"><a xlink:title=" ">
<polygon fill="#e0e0e0" stroke="#999999" points="119.88,-19.25 66.38,-19.25 66.38,0 119.88,0 119.88,-19.25"/>
<text text-anchor="middle" x="93.12" y="-5.75" font-family="Helvetica,sans-Serif" font-size="10.00">iostream</text>
</a>
</g>
</g>
<!-- Node1&#45;&gt;Node3 -->
<g id="edge2_Node000001_Node000003" class="edge">
<title>Node1&#45;&gt;Node3</title>
<g id="a_edge2_Node000001_Node000003"><a xlink:title=" ">
<path fill="none" stroke="#63b8ff" d="M198.58,-54.84C178.51,-46.43 148.32,-33.77 125.38,-24.15"/>
<polygon fill="#63b8ff" stroke="#63b8ff" points="126.75,-20.93 116.17,-20.29 124.04,-27.38 126.75,-20.93"/>
</a>
</g>
</g>
<!-- Node4 -->
<g id="Node000004" class="node">
<title>Node4</title>
<g id="a_Node000004"><a xlink:title=" ">
<polygon fill="#e0e0e0" stroke="#999999" points="176.75,-19.25 137.5,-19.25 137.5,0 176.75,0 176.75,-19.25"/>
<text text-anchor="middle" x="157.12" y="-5.75" font-family="Helvetica,sans-Serif" font-size="10.00">limits</text>
</a>
</g>
</g>
<!-- Node1&#45;&gt;Node4 -->
<g id="edge3_Node000001_Node000004" class="edge">
<title>Node1&#45;&gt;Node4</title>
<g id="a_edge3_Node000001_Node000004"><a xlink:title=" ">
<path fill="none" stroke="#63b8ff" d="M209.44,-54.84C200.42,-47.22 187.29,-36.12 176.44,-26.95"/>
<polygon fill="#63b8ff" stroke="#63b8ff" points="178.71,-24.28 168.81,-20.5 174.19,-29.63 178.71,-24.28"/>
</a>
</g>
</g>
<!-- Node5 -->
<g id="Node000005" class="node">
<title>Node5</title>
<g id="a_Node000005"><a xlink:title=" ">
<polygon fill="#e0e0e0" stroke="#999999" points="245.75,-19.25 194.5,-19.25 194.5,0 245.75,0 245.75,-19.25"/>
<text text-anchor="middle" x="220.12" y="-5.75" font-family="Helvetica,sans-Serif" font-size="10.00">memory</text>
</a>
</g>
</g>
<!-- Node1&#45;&gt;Node5 -->
<g id="edge4_Node000001_Node000005" class="edge">
<title>Node1&#45;&gt;Node5</title>
<g id="a_edge4_Node000001_Node000005"><a xlink:title=" ">
<path fill="none" stroke="#63b8ff" d="M220.12,-55.08C220.12,-48.57 220.12,-39.42 220.12,-31.12"/>
<polygon fill="#63b8ff" stroke="#63b8ff" points="223.63,-31.12 220.13,-21.12 216.63,-31.12 223.63,-31.12"/>
</a>
</g>
</g>
<!-- Node6 -->
<g id="Node000006" class="node">
<title>Node6</title>
<g id="a_Node000006"><a xlink:title=" ">
<polygon fill="#e0e0e0" stroke="#999999" points="306.25,-19.25 264,-19.25 264,0 306.25,0 306.25,-19.25"/>
<text text-anchor="middle" x="285.12" y="-5.75" font-family="Helvetica,sans-Serif" font-size="10.00">queue</text>
</a>
</g>
</g>
<!-- Node1&#45;&gt;Node6 -->
<g id="edge5_Node000001_Node000006" class="edge">
<title>Node1&#45;&gt;Node6</title>
<g id="a_edge5_Node000001_Node000006"><a xlink:title=" ">
<path fill="none" stroke="#63b8ff" d="M231.15,-54.84C240.55,-47.15 254.27,-35.9 265.53,-26.68"/>
<polygon fill="#63b8ff" stroke="#63b8ff" points="267.57,-29.53 273.09,-20.48 263.14,-24.11 267.57,-29.53"/>
</a>
</g>
</g>
<!-- Node7 -->
<g id="Node000007" class="node">
<title>Node7</title>
<g id="a_Node000007"><a xlink:title=" ">
<polygon fill="#e0e0e0" stroke="#999999" points="363.75,-19.25 324.5,-19.25 324.5,0 363.75,0 363.75,-19.25"/>
<text text-anchor="middle" x="344.12" y="-5.75" font-family="Helvetica,sans-Serif" font-size="10.00">utility</text>
</a>
</g>
</g>
<!-- Node1&#45;&gt;Node7 -->
<g id="edge6_Node000001_Node000007" class="edge">
<title>Node1&#45;&gt;Node7</title>
<g id="a_edge6_Node000001_Node000007"><a xlink:title=" ">
<path fill="none" stroke="#63b8ff" d="M241.16,-54.84C261.11,-46.27 291.31,-33.31 313.85,-23.63"/>
<polygon fill="#63b8ff" stroke="#63b8ff" points="315.02,-26.93 322.83,-19.77 312.26,-20.5 315.02,-26.93"/>
</a>
</g>
</g>
<!-- Node8 -->
<g id="Node000008" class="node">
<title>Node8</title>
<g id="a_Node000008"><a xlink:title=" ">
<polygon fill="#e0e0e0" stroke="#999999" points="424.62,-19.25 381.62,-19.25 381.62,0 424.62,0 424.62,-19.25"/>
<text text-anchor="middle" x="403.12" y="-5.75" font-family="Helvetica,sans-Serif" font-size="10.00">vector</text>
</a>
</g>
</g>
<!-- Node1&#45;&gt;Node8 -->
<g id="edge7_Node000001_Node000008" class="edge">
<title>Node1&#45;&gt;Node8</title>
<g id="a_edge7_Node000001_Node000008"><a xlink:title=" ">
<path fill="none" stroke="#63b8ff" d="M251.17,-54.84C284.33,-45.19 336.68,-29.96 370.46,-20.13"/>
<polygon fill="#63b8ff" stroke="#63b8ff" points="371.07,-23.6 379.69,-17.44 369.11,-16.88 371.07,-23.6"/>
</a>
</g>
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 6.0 KiB

View File

@@ -113,10 +113,10 @@ $(function(){initNavTree('d9/dec/unbounded__0__1__knapsack_8cpp.html','../../');
<p>Implementation of the Unbounded 0/1 <a class="el" href="../../d7/daf/namespace_knapsack.html" title="Implementation of 0-1 Knapsack problem.">Knapsack</a> Problem.
<a href="#details">More...</a></p>
<div class="textblock"><code>#include &lt;iostream&gt;</code><br />
<code>#include &lt;vector&gt;</code><br />
<code>#include &lt;cassert&gt;</code><br />
<div class="textblock"><code>#include &lt;cassert&gt;</code><br />
<code>#include &lt;cstdint&gt;</code><br />
<code>#include &lt;iostream&gt;</code><br />
<code>#include &lt;vector&gt;</code><br />
</div><div class="textblock"><div class="dynheader">
Include dependency graph for unbounded_0_1_knapsack.cpp:</div>
<div class="dyncontent">
@@ -216,26 +216,31 @@ Algorithm</h3>
</dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>The maximum value that can be obtained for the given index and capacity. </dd></dl>
<div class="fragment"><div class="line"><span class="lineno"> 60</span> {</div>
<div class="line"><span class="lineno"> 61</span> <span class="keywordflow">if</span> (i == 0) {</div>
<div class="line"><span class="lineno"> 62</span> <span class="keywordflow">if</span> (wt[0] &lt;= W) {</div>
<div class="line"><span class="lineno"> 63</span> <span class="keywordflow">return</span> (W / wt[0]) * val[0]; <span class="comment">// Take as many of the first item as possible</span></div>
<div class="line"><span class="lineno"> 64</span> } <span class="keywordflow">else</span> {</div>
<div class="line"><span class="lineno"> 65</span> <span class="keywordflow">return</span> 0; <span class="comment">// Can&#39;t take the first item</span></div>
<div class="line"><span class="lineno"> 66</span> }</div>
<div class="line"><span class="lineno"> 67</span> }</div>
<div class="line"><span class="lineno"> 68</span> <span class="keywordflow">if</span> (<a class="code hl_namespace" href="../../df/d88/namespacedp.html">dp</a>[i][W] != -1) <span class="keywordflow">return</span> <a class="code hl_namespace" href="../../df/d88/namespacedp.html">dp</a>[i][W]; <span class="comment">// Return result if available</span></div>
<div class="line"><span class="lineno"> 69</span> </div>
<div class="line"><span class="lineno"> 70</span> <span class="keywordtype">int</span> nottake = <a class="code hl_function" href="#afe447a5979582174908695952c8a079c">KnapSackFilling</a>(i - 1, W, val, wt, <a class="code hl_namespace" href="../../df/d88/namespacedp.html">dp</a>); <span class="comment">// Value without taking item i</span></div>
<div class="line"><span class="lineno"> 71</span> <span class="keywordtype">int</span> take = 0;</div>
<div class="line"><span class="lineno"> 72</span> <span class="keywordflow">if</span> (W &gt;= wt[i]) {</div>
<div class="line"><span class="lineno"> 73</span> take = val[i] + <a class="code hl_function" href="#afe447a5979582174908695952c8a079c">KnapSackFilling</a>(i, W - wt[i], val, wt, <a class="code hl_namespace" href="../../df/d88/namespacedp.html">dp</a>); <span class="comment">// Value taking item i</span></div>
<div class="line"><span class="lineno"> 74</span> }</div>
<div class="line"><span class="lineno"> 75</span> <span class="keywordflow">return</span> <a class="code hl_namespace" href="../../df/d88/namespacedp.html">dp</a>[i][W] = <a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/algorithm/max.html">std::max</a>(take, nottake); <span class="comment">// Store and return the maximum value</span></div>
<div class="line"><span class="lineno"> 76</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> (i == 0) {</div>
<div class="line"><span class="lineno"> 63</span> <span class="keywordflow">if</span> (wt[0] &lt;= W) {</div>
<div class="line"><span class="lineno"> 64</span> <span class="keywordflow">return</span> (W / wt[0]) *</div>
<div class="line"><span class="lineno"> 65</span> val[0]; <span class="comment">// Take as many of the first item as possible</span></div>
<div class="line"><span class="lineno"> 66</span> } <span class="keywordflow">else</span> {</div>
<div class="line"><span class="lineno"> 67</span> <span class="keywordflow">return</span> 0; <span class="comment">// Can&#39;t take the first item</span></div>
<div class="line"><span class="lineno"> 68</span> }</div>
<div class="line"><span class="lineno"> 69</span> }</div>
<div class="line"><span class="lineno"> 70</span> <span class="keywordflow">if</span> (<a class="code hl_namespace" href="../../df/d88/namespacedp.html">dp</a>[i][W] != -1)</div>
<div class="line"><span class="lineno"> 71</span> <span class="keywordflow">return</span> <a class="code hl_namespace" href="../../df/d88/namespacedp.html">dp</a>[i][W]; <span class="comment">// Return result if available</span></div>
<div class="line"><span class="lineno"> 72</span> </div>
<div class="line"><span class="lineno"> 73</span> <span class="keywordtype">int</span> nottake =</div>
<div class="line"><span class="lineno"> 74</span> <a class="code hl_function" href="#afe447a5979582174908695952c8a079c">KnapSackFilling</a>(i - 1, W, val, wt, <a class="code hl_namespace" href="../../df/d88/namespacedp.html">dp</a>); <span class="comment">// Value without taking item i</span></div>
<div class="line"><span class="lineno"> 75</span> <span class="keywordtype">int</span> take = 0;</div>
<div class="line"><span class="lineno"> 76</span> <span class="keywordflow">if</span> (W &gt;= wt[i]) {</div>
<div class="line"><span class="lineno"> 77</span> take = val[i] + <a class="code hl_function" href="#afe447a5979582174908695952c8a079c">KnapSackFilling</a>(i, W - wt[i], val, wt,</div>
<div class="line"><span class="lineno"> 78</span> <a class="code hl_namespace" href="../../df/d88/namespacedp.html">dp</a>); <span class="comment">// Value taking item i</span></div>
<div class="line"><span class="lineno"> 79</span> }</div>
<div class="line"><span class="lineno"> 80</span> <span class="keywordflow">return</span> <a class="code hl_namespace" href="../../df/d88/namespacedp.html">dp</a>[i][W] =</div>
<div class="line"><span class="lineno"> 81</span> <a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/algorithm/max.html">std::max</a>(take, nottake); <span class="comment">// Store and return the maximum value</span></div>
<div class="line"><span class="lineno"> 82</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="anamespacedp_html"><div class="ttname"><a href="../../df/d88/namespacedp.html">dp</a></div><div class="ttdoc">for std::vector</div><div class="ttdef"><b>Definition</b> partition_problem.cpp:39</div></div>
<div class="ttc" id="aunbounded__0__1__knapsack_8cpp_html_afe447a5979582174908695952c8a079c"><div class="ttname"><a href="#afe447a5979582174908695952c8a079c">dynamic_programming::unbounded_knapsack::KnapSackFilling</a></div><div class="ttdeci">std::uint16_t KnapSackFilling(std::uint16_t i, std::uint16_t W, const std::vector&lt; std::uint16_t &gt; &amp;val, const std::vector&lt; std::uint16_t &gt; &amp;wt, std::vector&lt; std::vector&lt; int &gt; &gt; &amp;dp)</div><div class="ttdoc">Recursive function to calculate the maximum value obtainable using an unbounded knapsack approach.</div><div class="ttdef"><b>Definition</b> unbounded_0_1_knapsack.cpp:57</div></div>
<div class="ttc" id="aunbounded__0__1__knapsack_8cpp_html_afe447a5979582174908695952c8a079c"><div class="ttname"><a href="#afe447a5979582174908695952c8a079c">dynamic_programming::unbounded_knapsack::KnapSackFilling</a></div><div class="ttdeci">std::uint16_t KnapSackFilling(std::uint16_t i, std::uint16_t W, const std::vector&lt; std::uint16_t &gt; &amp;val, const std::vector&lt; std::uint16_t &gt; &amp;wt, std::vector&lt; std::vector&lt; int &gt; &gt; &amp;dp)</div><div class="ttdoc">Recursive function to calculate the maximum value obtainable using an unbounded knapsack approach.</div><div class="ttdef"><b>Definition</b> unbounded_0_1_knapsack.cpp:58</div></div>
</div><!-- fragment --><div class="dynheader">
Here is the call graph for this function:</div>
<div class="dyncontent">
@@ -261,11 +266,11 @@ Here is the call graph for this function:</div>
<p>main function </p>
<dl class="section return"><dt>Returns</dt><dd>0 on successful exit </dd></dl>
<div class="fragment"><div class="line"><span class="lineno"> 147</span> {</div>
<div class="line"><span class="lineno"> 148</span> <a class="code hl_function" href="#a483bb8ccf42aaf7375a83e91490eda1e">tests</a>(); <span class="comment">// Run self test implementation </span></div>
<div class="line"><span class="lineno"> 149</span> <span class="keywordflow">return</span> 0;</div>
<div class="line"><span class="lineno"> 150</span>}</div>
<div class="ttc" id="aunbounded__0__1__knapsack_8cpp_html_a483bb8ccf42aaf7375a83e91490eda1e"><div class="ttname"><a href="#a483bb8ccf42aaf7375a83e91490eda1e">tests</a></div><div class="ttdeci">static void tests()</div><div class="ttdoc">self test implementation</div><div class="ttdef"><b>Definition</b> unbounded_0_1_knapsack.cpp:103</div></div>
<div class="fragment"><div class="line"><span class="lineno"> 170</span> {</div>
<div class="line"><span class="lineno"> 171</span> <a class="code hl_function" href="#a483bb8ccf42aaf7375a83e91490eda1e">tests</a>(); <span class="comment">// Run self test implementation</span></div>
<div class="line"><span class="lineno"> 172</span> <span class="keywordflow">return</span> 0;</div>
<div class="line"><span class="lineno"> 173</span>}</div>
<div class="ttc" id="aunbounded__0__1__knapsack_8cpp_html_a483bb8ccf42aaf7375a83e91490eda1e"><div class="ttname"><a href="#a483bb8ccf42aaf7375a83e91490eda1e">tests</a></div><div class="ttdeci">static void tests()</div><div class="ttdoc">self test implementation</div><div class="ttdef"><b>Definition</b> unbounded_0_1_knapsack.cpp:111</div></div>
</div><!-- fragment --><div class="dynheader">
Here is the call graph for this function:</div>
<div class="dyncontent">
@@ -299,49 +304,64 @@ Here is the call graph for this function:</div>
<p>self test implementation </p>
<dl class="section return"><dt>Returns</dt><dd>void </dd></dl>
<div class="fragment"><div class="line"><span class="lineno"> 103</span> {</div>
<div class="line"><span class="lineno"> 104</span> <span class="comment">// Test Case 1</span></div>
<div class="line"><span class="lineno"> 105</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/types/integer.html">std::uint16_t</a> N1 = 4; <span class="comment">// Number of items</span></div>
<div class="line"><span class="lineno"> 106</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector&lt;std::uint16_t&gt;</a> wt1 = {1, 3, 4, 5}; <span class="comment">// Weights of the items</span></div>
<div class="line"><span class="lineno"> 107</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector&lt;std::uint16_t&gt;</a> val1 = {6, 1, 7, 7}; <span class="comment">// Values of the items</span></div>
<div class="line"><span class="lineno"> 108</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/types/integer.html">std::uint16_t</a> W1 = 8; <span class="comment">// Maximum capacity of the knapsack</span></div>
<div class="line"><span class="lineno"> 109</span> <span class="comment">// Test the function and assert the expected output</span></div>
<div class="line"><span class="lineno"> 110</span> assert(<a class="code hl_function" href="#a1bcff7f76de48fa7f629480f8f18b5ef">unboundedKnapsack</a>(N1, W1, val1, wt1) == 48);</div>
<div class="line"><span class="lineno"> 111</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 &quot;</span> &lt;&lt; <a class="code hl_function" href="#a1bcff7f76de48fa7f629480f8f18b5ef">unboundedKnapsack</a>(N1, W1, val1, wt1) &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"> 112</span> </div>
<div class="line"><span class="lineno"> 113</span> <span class="comment">// Test Case 2</span></div>
<div class="line"><span class="lineno"> 114</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/types/integer.html">std::uint16_t</a> N2 = 3; <span class="comment">// Number of items</span></div>
<div class="line"><span class="lineno"> 115</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector&lt;std::uint16_t&gt;</a> wt2 = {10, 20, 30}; <span class="comment">// Weights of the items</span></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;std::uint16_t&gt;</a> val2 = {60, 100, 120}; <span class="comment">// Values of the items</span></div>
<div class="line"><span class="lineno"> 117</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/types/integer.html">std::uint16_t</a> W2 = 5; <span class="comment">// Maximum capacity of the knapsack</span></div>
<div class="line"><span class="lineno"> 118</span> <span class="comment">// Test the function and assert the expected output</span></div>
<div class="line"><span class="lineno"> 119</span> assert(<a class="code hl_function" href="#a1bcff7f76de48fa7f629480f8f18b5ef">unboundedKnapsack</a>(N2, W2, val2, wt2) == 0);</div>
<div class="line"><span class="lineno"> 120</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 &quot;</span> &lt;&lt; <a class="code hl_function" href="#a1bcff7f76de48fa7f629480f8f18b5ef">unboundedKnapsack</a>(N2, W2, val2, wt2) &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"> 121</span> </div>
<div class="line"><span class="lineno"> 122</span> <span class="comment">// Test Case 3</span></div>
<div class="line"><span class="lineno"> 123</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/types/integer.html">std::uint16_t</a> N3 = 3; <span class="comment">// Number of items</span></div>
<div class="line"><span class="lineno"> 124</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector&lt;std::uint16_t&gt;</a> wt3 = {2, 4, 6}; <span class="comment">// Weights of the items</span></div>
<div class="line"><span class="lineno"> 125</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector&lt;std::uint16_t&gt;</a> val3 = {5, 11, 13};<span class="comment">// Values of the items </span></div>
<div class="line"><span class="lineno"> 126</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/types/integer.html">std::uint16_t</a> W3 = 27;<span class="comment">// Maximum capacity of the knapsack </span></div>
<div class="line"><span class="lineno"> 127</span> <span class="comment">// Test the function and assert the expected output</span></div>
<div class="line"><span class="lineno"> 128</span> assert(<a class="code hl_function" href="#a1bcff7f76de48fa7f629480f8f18b5ef">unboundedKnapsack</a>(N3, W3, val3, wt3) == 27);</div>
<div class="line"><span class="lineno"> 129</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 &quot;</span> &lt;&lt; <a class="code hl_function" href="#a1bcff7f76de48fa7f629480f8f18b5ef">unboundedKnapsack</a>(N3, W3, val3, wt3) &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"> 130</span> </div>
<div class="line"><span class="lineno"> 131</span> <span class="comment">// Test Case 4</span></div>
<div class="line"><span class="lineno"> 132</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/types/integer.html">std::uint16_t</a> N4 = 0; <span class="comment">// Number of items</span></div>
<div class="line"><span class="lineno"> 133</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector&lt;std::uint16_t&gt;</a> wt4 = {}; <span class="comment">// Weights of the items</span></div>
<div class="line"><span class="lineno"> 134</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector&lt;std::uint16_t&gt;</a> val4 = {}; <span class="comment">// Values of the items </span></div>
<div class="line"><span class="lineno"> 135</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/types/integer.html">std::uint16_t</a> W4 = 10; <span class="comment">// Maximum capacity of the knapsack</span></div>
<div class="line"><span class="lineno"> 136</span> assert(<a class="code hl_function" href="#a1bcff7f76de48fa7f629480f8f18b5ef">unboundedKnapsack</a>(N4, W4, val4, wt4) == 0); </div>
<div class="line"><span class="lineno"> 137</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 for empty arrays: &quot;</span> &lt;&lt; <a class="code hl_function" href="#a1bcff7f76de48fa7f629480f8f18b5ef">unboundedKnapsack</a>(N4, W4, val4, wt4) &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"> 138</span> </div>
<div class="line"><span class="lineno"> 139</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;All test cases 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"> 140</span> </div>
<div class="line"><span class="lineno"> 141</span>}</div>
<div class="fragment"><div class="line"><span class="lineno"> 111</span> {</div>
<div class="line"><span class="lineno"> 112</span> <span class="comment">// Test Case 1</span></div>
<div class="line"><span class="lineno"> 113</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/types/integer.html">std::uint16_t</a> N1 = 4; <span class="comment">// Number of items</span></div>
<div class="line"><span class="lineno"> 114</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector&lt;std::uint16_t&gt;</a> wt1 = {1, 3, 4, 5}; <span class="comment">// Weights of the items</span></div>
<div class="line"><span class="lineno"> 115</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector&lt;std::uint16_t&gt;</a> val1 = {6, 1, 7, 7}; <span class="comment">// Values of the items</span></div>
<div class="line"><span class="lineno"> 116</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/types/integer.html">std::uint16_t</a> W1 = 8; <span class="comment">// Maximum capacity of the knapsack</span></div>
<div class="line"><span class="lineno"> 117</span> <span class="comment">// Test the function and assert the expected output</span></div>
<div class="line"><span class="lineno"> 118</span> assert(dynamic_programming::unbounded_knapsack::unboundedKnapsack(</div>
<div class="line"><span class="lineno"> 119</span> N1, W1, val1, wt1) == 48);</div>
<div class="line"><span class="lineno"> 120</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 &quot;</span></div>
<div class="line"><span class="lineno"> 121</span> &lt;&lt; <a class="code hl_function" href="#a1bcff7f76de48fa7f629480f8f18b5ef">dynamic_programming::unbounded_knapsack::unboundedKnapsack</a>(</div>
<div class="line"><span class="lineno"> 122</span> N1, W1, val1, wt1)</div>
<div class="line"><span class="lineno"> 123</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"> 124</span> </div>
<div class="line"><span class="lineno"> 125</span> <span class="comment">// Test Case 2</span></div>
<div class="line"><span class="lineno"> 126</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/types/integer.html">std::uint16_t</a> N2 = 3; <span class="comment">// Number of items</span></div>
<div class="line"><span class="lineno"> 127</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector&lt;std::uint16_t&gt;</a> wt2 = {10, 20, 30}; <span class="comment">// Weights of the items</span></div>
<div class="line"><span class="lineno"> 128</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector&lt;std::uint16_t&gt;</a> val2 = {60, 100, 120}; <span class="comment">// Values of the items</span></div>
<div class="line"><span class="lineno"> 129</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/types/integer.html">std::uint16_t</a> W2 = 5; <span class="comment">// Maximum capacity of the knapsack</span></div>
<div class="line"><span class="lineno"> 130</span> <span class="comment">// Test the function and assert the expected output</span></div>
<div class="line"><span class="lineno"> 131</span> assert(dynamic_programming::unbounded_knapsack::unboundedKnapsack(</div>
<div class="line"><span class="lineno"> 132</span> N2, W2, val2, wt2) == 0);</div>
<div class="line"><span class="lineno"> 133</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 &quot;</span></div>
<div class="line"><span class="lineno"> 134</span> &lt;&lt; <a class="code hl_function" href="#a1bcff7f76de48fa7f629480f8f18b5ef">dynamic_programming::unbounded_knapsack::unboundedKnapsack</a>(</div>
<div class="line"><span class="lineno"> 135</span> N2, W2, val2, wt2)</div>
<div class="line"><span class="lineno"> 136</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"> 137</span> </div>
<div class="line"><span class="lineno"> 138</span> <span class="comment">// Test Case 3</span></div>
<div class="line"><span class="lineno"> 139</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/types/integer.html">std::uint16_t</a> N3 = 3; <span class="comment">// Number of items</span></div>
<div class="line"><span class="lineno"> 140</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector&lt;std::uint16_t&gt;</a> wt3 = {2, 4, 6}; <span class="comment">// Weights of the items</span></div>
<div class="line"><span class="lineno"> 141</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector&lt;std::uint16_t&gt;</a> val3 = {5, 11, 13}; <span class="comment">// Values of the items</span></div>
<div class="line"><span class="lineno"> 142</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/types/integer.html">std::uint16_t</a> W3 = 27; <span class="comment">// Maximum capacity of the knapsack</span></div>
<div class="line"><span class="lineno"> 143</span> <span class="comment">// Test the function and assert the expected output</span></div>
<div class="line"><span class="lineno"> 144</span> assert(dynamic_programming::unbounded_knapsack::unboundedKnapsack(</div>
<div class="line"><span class="lineno"> 145</span> N3, W3, val3, wt3) == 27);</div>
<div class="line"><span class="lineno"> 146</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 &quot;</span></div>
<div class="line"><span class="lineno"> 147</span> &lt;&lt; <a class="code hl_function" href="#a1bcff7f76de48fa7f629480f8f18b5ef">dynamic_programming::unbounded_knapsack::unboundedKnapsack</a>(</div>
<div class="line"><span class="lineno"> 148</span> N3, W3, val3, wt3)</div>
<div class="line"><span class="lineno"> 149</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"> 150</span> </div>
<div class="line"><span class="lineno"> 151</span> <span class="comment">// Test Case 4</span></div>
<div class="line"><span class="lineno"> 152</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/types/integer.html">std::uint16_t</a> N4 = 0; <span class="comment">// Number of items</span></div>
<div class="line"><span class="lineno"> 153</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector&lt;std::uint16_t&gt;</a> wt4 = {}; <span class="comment">// Weights of the items</span></div>
<div class="line"><span class="lineno"> 154</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector&lt;std::uint16_t&gt;</a> val4 = {}; <span class="comment">// Values of the items</span></div>
<div class="line"><span class="lineno"> 155</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/types/integer.html">std::uint16_t</a> W4 = 10; <span class="comment">// Maximum capacity of the knapsack</span></div>
<div class="line"><span class="lineno"> 156</span> assert(dynamic_programming::unbounded_knapsack::unboundedKnapsack(</div>
<div class="line"><span class="lineno"> 157</span> N4, W4, val4, wt4) == 0);</div>
<div class="line"><span class="lineno"> 158</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 for empty arrays: &quot;</span></div>
<div class="line"><span class="lineno"> 159</span> &lt;&lt; <a class="code hl_function" href="#a1bcff7f76de48fa7f629480f8f18b5ef">dynamic_programming::unbounded_knapsack::unboundedKnapsack</a>(</div>
<div class="line"><span class="lineno"> 160</span> N4, W4, val4, wt4)</div>
<div class="line"><span class="lineno"> 161</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"> 162</span> </div>
<div class="line"><span class="lineno"> 163</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/basic_ostream.html">std::cout</a> &lt;&lt; <span class="stringliteral">&quot;All test cases 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"> 164</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="ainteger_html"><div class="ttname"><a href="http://en.cppreference.com/w/cpp/types/integer.html">std::uint16_t</a></div></div>
<div class="ttc" id="aunbounded__0__1__knapsack_8cpp_html_a1bcff7f76de48fa7f629480f8f18b5ef"><div class="ttname"><a href="#a1bcff7f76de48fa7f629480f8f18b5ef">dynamic_programming::unbounded_knapsack::unboundedKnapsack</a></div><div class="ttdeci">std::uint16_t unboundedKnapsack(std::uint16_t N, std::uint16_t W, const std::vector&lt; std::uint16_t &gt; &amp;val, const std::vector&lt; std::uint16_t &gt; &amp;wt)</div><div class="ttdoc">Wrapper function to initiate the unbounded knapsack calculation.</div><div class="ttdef"><b>Definition</b> unbounded_0_1_knapsack.cpp:87</div></div>
<div class="ttc" id="aunbounded__0__1__knapsack_8cpp_html_a1bcff7f76de48fa7f629480f8f18b5ef"><div class="ttname"><a href="#a1bcff7f76de48fa7f629480f8f18b5ef">dynamic_programming::unbounded_knapsack::unboundedKnapsack</a></div><div class="ttdeci">std::uint16_t unboundedKnapsack(std::uint16_t N, std::uint16_t W, const std::vector&lt; std::uint16_t &gt; &amp;val, const std::vector&lt; std::uint16_t &gt; &amp;wt)</div><div class="ttdoc">Wrapper function to initiate the unbounded knapsack calculation.</div><div class="ttdef"><b>Definition</b> unbounded_0_1_knapsack.cpp:93</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">
Here is the call graph for this function:</div>
@@ -391,11 +411,13 @@ Here is the call graph for this function:</div>
</dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>The maximum value that can be obtained for the given capacity. </dd></dl>
<div class="fragment"><div class="line"><span class="lineno"> 89</span> {</div>
<div class="line"><span class="lineno"> 90</span> <span class="keywordflow">if</span>(N==0)<span class="keywordflow">return</span> 0; <span class="comment">// Expect 0 since no items</span></div>
<div class="line"><span class="lineno"> 91</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; <a class="code hl_namespace" href="../../df/d88/namespacedp.html">dp</a>(N, <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector&lt;int&gt;</a>(W + 1, -1)); <span class="comment">// Initialize memoization table</span></div>
<div class="line"><span class="lineno"> 92</span> <span class="keywordflow">return</span> <a class="code hl_function" href="#afe447a5979582174908695952c8a079c">KnapSackFilling</a>(N - 1, W, val, wt, <a class="code hl_namespace" href="../../df/d88/namespacedp.html">dp</a>); <span class="comment">// Start the calculation</span></div>
<div class="line"><span class="lineno"> 93</span>}</div>
<div class="fragment"><div class="line"><span class="lineno"> 95</span> {</div>
<div class="line"><span class="lineno"> 96</span> <span class="keywordflow">if</span> (N == 0)</div>
<div class="line"><span class="lineno"> 97</span> <span class="keywordflow">return</span> 0; <span class="comment">// Expect 0 since no items</span></div>
<div class="line"><span class="lineno"> 98</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; <a class="code hl_namespace" href="../../df/d88/namespacedp.html">dp</a>(</div>
<div class="line"><span class="lineno"> 99</span> N, <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector&lt;int&gt;</a>(W + 1, -1)); <span class="comment">// Initialize memoization table</span></div>
<div class="line"><span class="lineno"> 100</span> <span class="keywordflow">return</span> <a class="code hl_function" href="#afe447a5979582174908695952c8a079c">KnapSackFilling</a>(N - 1, W, val, wt, <a class="code hl_namespace" href="../../df/d88/namespacedp.html">dp</a>); <span class="comment">// Start the calculation</span></div>
<div class="line"><span class="lineno"> 101</span>}</div>
</div><!-- fragment --><div class="dynheader">
Here is the call graph for this function:</div>
<div class="dyncontent">

View File

@@ -147,7 +147,7 @@ Functions</h2></td></tr>
<div class="fragment"><div class="line"><span class="lineno"> 11</span> {</div>
<div class="line"><span class="lineno"> 12</span> <span class="comment">// variable to indicate sign of input integer</span></div>
<div class="line"><span class="lineno"> 13</span> <span class="keywordtype">bool</span> negative = <span class="keyword">false</span>;</div>
<div class="line"><span class="lineno"> 14</span> <span class="keyword">register</span> <span class="keywordtype">int</span> c;</div>
<div class="line"><span class="lineno"> 14</span> <span class="keywordtype">int</span> c;</div>
<div class="line"><span class="lineno"> 15</span> *number = 0;</div>
<div class="line"><span class="lineno"> 16</span> </div>
<div class="line"><span class="lineno"> 17</span> <span class="comment">// extract current character from buffer</span></div>