Documentation for 341ed50da8

This commit is contained in:
github-actions
2021-09-03 19:56:17 +00:00
parent 52d0c55145
commit 08e8eb037e
3432 changed files with 71392 additions and 72953 deletions

View File

@@ -2,8 +2,8 @@
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.9.1"/>
<meta http-equiv="X-UA-Compatible" content="IE=11"/>
<meta name="generator" content="Doxygen 1.9.2"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>Algorithms_in_C++: ciphers::HillCipher Class Reference</title>
<link href="../../tabs.css" rel="stylesheet" type="text/css"/>
@@ -17,9 +17,9 @@
<script type="text/javascript" src="../../search/searchdata.js"></script>
<script type="text/javascript" src="../../search/search.js"></script>
<script type="text/x-mathjax-config">
MathJax.Hub.Config({
extensions: ["tex2jax.js", "TeX/AMSmath.js", "TeX/AMSsymbols.js"],
jax: ["input/TeX","output/HTML-CSS"],
MathJax.Hub.Config({
extensions: ["tex2jax.js", "TeX/AMSmath.js", "TeX/AMSsymbols.js"],
jax: ["input/TeX","output/HTML-CSS"],
});
</script>
<script type="text/javascript" async="async" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.7/MathJax.js?config=TeX-MML-AM_CHTML/MathJax.js"></script>
@@ -32,8 +32,7 @@
<tbody>
<tr style="height: 56px;">
<td id="projectalign" style="padding-left: 0.5em;">
<div id="projectname">Algorithms_in_C++
&#160;<span id="projectnumber">1.0.0</span>
<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>
</td>
@@ -42,21 +41,22 @@
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.9.1 -->
<!-- Generated by Doxygen 1.9.2 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
var searchBox = new SearchBox("searchBox", "../../search",false,'Search','.html');
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
var searchBox = new SearchBox("searchBox", "../../search",'Search','.html');
/* @license-end */
</script>
<script type="text/javascript" src="../../menudata.js"></script>
<script type="text/javascript" src="../../menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(function() {
initMenu('../../',true,false,'search.php','Search');
$(document).ready(function() { init_search(); });
});
/* @license-end */</script>
/* @license-end */
</script>
<div id="main-nav"></div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
@@ -70,7 +70,7 @@ $(function() {
</div>
</div>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(document).ready(function(){initNavTree('d6/d26/classciphers_1_1_hill_cipher.html','../../'); initResizable(); });
/* @license-end */
</script>
@@ -94,25 +94,24 @@ $(document).ready(function(){initNavTree('d6/d26/classciphers_1_1_hill_cipher.ht
<a href="#pub-static-methods">Static Public Member Functions</a> &#124;
<a href="#pri-static-methods">Static Private Member Functions</a> &#124;
<a href="../../d0/dd5/classciphers_1_1_hill_cipher-members.html">List of all members</a> </div>
<div class="headertitle">
<div class="title">ciphers::HillCipher Class Reference</div> </div>
<div class="headertitle"><div class="title">ciphers::HillCipher Class Reference</div></div>
</div><!--header-->
<div class="contents">
<p>Implementation of <a href="https://en.wikipedia.org/wiki/Hill_cipher">Hill Cipher</a> algorithm.
<p>Implementation of <a href="https://en.wikipedia.org/wiki/Hill_cipher" target="_blank">Hill Cipher</a> algorithm.
<a href="../../d6/d26/classciphers_1_1_hill_cipher.html#details">More...</a></p>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="pub-static-methods"></a>
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="pub-static-methods" name="pub-static-methods"></a>
Static Public Member Functions</h2></td></tr>
<tr class="memitem:a7ca10cd1a0e8e3732391e0427d2d0213"><td class="memItemLeft" align="right" valign="top">static <a class="el" href="../../d1/dbe/lu__decomposition_8h.html#aed8766713ee9b561a4acdcdff5f90ea5">matrix</a>&lt; int &gt;&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../d6/d26/classciphers_1_1_hill_cipher.html#a7ca10cd1a0e8e3732391e0427d2d0213">generate_encryption_key</a> (size_t size, int limit1=0, int limit2=10)</td></tr>
<tr class="memdesc:a7ca10cd1a0e8e3732391e0427d2d0213"><td class="mdescLeft">&#160;</td><td class="mdescRight">Generate encryption matrix of a given size. Larger size matrices are difficult to generate but provide more security. Important conditions are: <a href="../../d6/d26/classciphers_1_1_hill_cipher.html#a7ca10cd1a0e8e3732391e0427d2d0213">More...</a><br /></td></tr>
<tr class="separator:a7ca10cd1a0e8e3732391e0427d2d0213"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:abb2c4dc2b8a59d3dfe0fa22c2adc086b"><td class="memItemLeft" align="right" valign="top">static <a class="el" href="../../d1/dbe/lu__decomposition_8h.html#aed8766713ee9b561a4acdcdff5f90ea5">matrix</a>&lt; int &gt;&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../d6/d26/classciphers_1_1_hill_cipher.html#abb2c4dc2b8a59d3dfe0fa22c2adc086b">generate_decryption_key</a> (<a class="el" href="../../d1/dbe/lu__decomposition_8h.html#aed8766713ee9b561a4acdcdff5f90ea5">matrix</a>&lt; int &gt; const &amp;encrypt_key)</td></tr>
<tr class="memdesc:abb2c4dc2b8a59d3dfe0fa22c2adc086b"><td class="mdescLeft">&#160;</td><td class="mdescRight">Generate decryption matrix from an encryption matrix key. <a href="../../d6/d26/classciphers_1_1_hill_cipher.html#abb2c4dc2b8a59d3dfe0fa22c2adc086b">More...</a><br /></td></tr>
<tr class="separator:abb2c4dc2b8a59d3dfe0fa22c2adc086b"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a14bfcd14af6cd853130cbacd32e35c13"><td class="memItemLeft" align="right" valign="top">static <a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/utility/pair.html">std::pair</a>&lt; <a class="el" href="../../d1/dbe/lu__decomposition_8h.html#aed8766713ee9b561a4acdcdff5f90ea5">matrix</a>&lt; int &gt;, <a class="el" href="../../d1/dbe/lu__decomposition_8h.html#aed8766713ee9b561a4acdcdff5f90ea5">matrix</a>&lt; int &gt; &gt;&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../d6/d26/classciphers_1_1_hill_cipher.html#a14bfcd14af6cd853130cbacd32e35c13">generate_keys</a> (size_t size, int limit1=0, int limit2=10)</td></tr>
<tr class="memdesc:a14bfcd14af6cd853130cbacd32e35c13"><td class="mdescLeft">&#160;</td><td class="mdescRight">Generate encryption and decryption key pair. <a href="../../d6/d26/classciphers_1_1_hill_cipher.html#a14bfcd14af6cd853130cbacd32e35c13">More...</a><br /></td></tr>
<tr class="separator:a14bfcd14af6cd853130cbacd32e35c13"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a642f70fb54cb50b00fb6df7c3f2b120e"><td class="memItemLeft" align="right" valign="top">static <a class="el" href="../../d1/dbe/lu__decomposition_8h.html#aed8766713ee9b561a4acdcdff5f90ea5">matrix</a>&lt; int &gt;&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../d6/d26/classciphers_1_1_hill_cipher.html#a642f70fb54cb50b00fb6df7c3f2b120e">generate_encryption_key</a> (size_t size, int limit1=0, int limit2=10)</td></tr>
<tr class="memdesc:a642f70fb54cb50b00fb6df7c3f2b120e"><td class="mdescLeft">&#160;</td><td class="mdescRight">Generate encryption matrix of a given size. Larger size matrices are difficult to generate but provide more security. Important conditions are: <a href="../../d6/d26/classciphers_1_1_hill_cipher.html#a642f70fb54cb50b00fb6df7c3f2b120e">More...</a><br /></td></tr>
<tr class="separator:a642f70fb54cb50b00fb6df7c3f2b120e"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ab02c7563889bf1e363deb8e21967b706"><td class="memItemLeft" align="right" valign="top">static <a class="el" href="../../d1/dbe/lu__decomposition_8h.html#aed8766713ee9b561a4acdcdff5f90ea5">matrix</a>&lt; int &gt;&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../d6/d26/classciphers_1_1_hill_cipher.html#ab02c7563889bf1e363deb8e21967b706">generate_decryption_key</a> (<a class="el" href="../../d1/dbe/lu__decomposition_8h.html#aed8766713ee9b561a4acdcdff5f90ea5">matrix</a>&lt; int &gt; const &amp;encrypt_key)</td></tr>
<tr class="memdesc:ab02c7563889bf1e363deb8e21967b706"><td class="mdescLeft">&#160;</td><td class="mdescRight">Generate decryption matrix from an encryption matrix key. <a href="../../d6/d26/classciphers_1_1_hill_cipher.html#ab02c7563889bf1e363deb8e21967b706">More...</a><br /></td></tr>
<tr class="separator:ab02c7563889bf1e363deb8e21967b706"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a405b0a28d66a61239d3565d5256f9cb5"><td class="memItemLeft" align="right" valign="top">static <a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/utility/pair.html">std::pair</a>&lt; <a class="el" href="../../d1/dbe/lu__decomposition_8h.html#aed8766713ee9b561a4acdcdff5f90ea5">matrix</a>&lt; int &gt;, <a class="el" href="../../d1/dbe/lu__decomposition_8h.html#aed8766713ee9b561a4acdcdff5f90ea5">matrix</a>&lt; int &gt; &gt;&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../d6/d26/classciphers_1_1_hill_cipher.html#a405b0a28d66a61239d3565d5256f9cb5">generate_keys</a> (size_t size, int limit1=0, int limit2=10)</td></tr>
<tr class="memdesc:a405b0a28d66a61239d3565d5256f9cb5"><td class="mdescLeft">&#160;</td><td class="mdescRight">Generate encryption and decryption key pair. <a href="../../d6/d26/classciphers_1_1_hill_cipher.html#a405b0a28d66a61239d3565d5256f9cb5">More...</a><br /></td></tr>
<tr class="separator:a405b0a28d66a61239d3565d5256f9cb5"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:aa8bbb6e4a5749f6008b06602d5103917"><td class="memItemLeft" align="right" valign="top">static const <a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/string/basic_string.html">std::string</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../d6/d26/classciphers_1_1_hill_cipher.html#aa8bbb6e4a5749f6008b06602d5103917">encrypt_text</a> (const <a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/string/basic_string.html">std::string</a> &amp;text, const <a class="el" href="../../d1/dbe/lu__decomposition_8h.html#aed8766713ee9b561a4acdcdff5f90ea5">matrix</a>&lt; int &gt; &amp;encrypt_key)</td></tr>
<tr class="memdesc:aa8bbb6e4a5749f6008b06602d5103917"><td class="mdescLeft">&#160;</td><td class="mdescRight">Encrypt a given text using a given key. <a href="../../d6/d26/classciphers_1_1_hill_cipher.html#aa8bbb6e4a5749f6008b06602d5103917">More...</a><br /></td></tr>
<tr class="separator:aa8bbb6e4a5749f6008b06602d5103917"><td class="memSeparator" colspan="2">&#160;</td></tr>
@@ -120,7 +119,7 @@ Static Public Member Functions</h2></td></tr>
<tr class="memdesc:a427acfac1dbff3f48a2b071d449d965b"><td class="mdescLeft">&#160;</td><td class="mdescRight">Decrypt a given text using a given key. <a href="../../d6/d26/classciphers_1_1_hill_cipher.html#a427acfac1dbff3f48a2b071d449d965b">More...</a><br /></td></tr>
<tr class="separator:a427acfac1dbff3f48a2b071d449d965b"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="pri-static-methods"></a>
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="pri-static-methods" name="pri-static-methods"></a>
Static Private Member Functions</h2></td></tr>
<tr class="memitem:a629be41c1ab78850963e4ce14e1d11d9"><td class="memTemplParams" colspan="2">template&lt;typename T1 , typename T2 &gt; </td></tr>
<tr class="memitem:a629be41c1ab78850963e4ce14e1d11d9"><td class="memTemplItemLeft" align="right" valign="top">static const T2&#160;</td><td class="memTemplItemRight" valign="bottom"><a class="el" href="../../d6/d26/classciphers_1_1_hill_cipher.html#a629be41c1ab78850963e4ce14e1d11d9">rand_range</a> (T1 a, T1 b)</td></tr>
@@ -132,11 +131,11 @@ Static Private Member Functions</h2></td></tr>
<tr class="separator:a716d0313141499d16f57c0c107f04395"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a7760f3665651a0a37937c79c62f219c0"><td class="memTemplParams" colspan="2">template&lt;typename T &gt; </td></tr>
<tr class="memitem:a7760f3665651a0a37937c79c62f219c0"><td class="memTemplItemLeft" align="right" valign="top">static const T&#160;</td><td class="memTemplItemRight" valign="bottom"><a class="el" href="../../d6/d26/classciphers_1_1_hill_cipher.html#a7760f3665651a0a37937c79c62f219c0">gcd</a> (T a, T b)</td></tr>
<tr class="memdesc:a7760f3665651a0a37937c79c62f219c0"><td class="mdescLeft">&#160;</td><td class="mdescRight">Compute <a href="https://en.wikipedia.org/wiki/Greatest_common_divisor">GCD</a> of two integers using Euler's algorithm. <a href="../../d6/d26/classciphers_1_1_hill_cipher.html#a7760f3665651a0a37937c79c62f219c0">More...</a><br /></td></tr>
<tr class="memdesc:a7760f3665651a0a37937c79c62f219c0"><td class="mdescLeft">&#160;</td><td class="mdescRight">Compute <a href="https://en.wikipedia.org/wiki/Greatest_common_divisor" target="_blank">GCD</a> of two integers using Euler's algorithm. <a href="../../d6/d26/classciphers_1_1_hill_cipher.html#a7760f3665651a0a37937c79c62f219c0">More...</a><br /></td></tr>
<tr class="separator:a7760f3665651a0a37937c79c62f219c0"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a40efd842a5cc44c233641ac2df13b0c0"><td class="memItemLeft" align="right" valign="top">static const <a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/numeric/valarray.html">std::valarray</a>&lt; uint8_t &gt;&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../d6/d26/classciphers_1_1_hill_cipher.html#a40efd842a5cc44c233641ac2df13b0c0">mat_mul</a> (const <a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/numeric/valarray.html">std::valarray</a>&lt; uint8_t &gt; &amp;vector, const <a class="el" href="../../d1/dbe/lu__decomposition_8h.html#aed8766713ee9b561a4acdcdff5f90ea5">matrix</a>&lt; int &gt; &amp;key)</td></tr>
<tr class="memdesc:a40efd842a5cc44c233641ac2df13b0c0"><td class="mdescLeft">&#160;</td><td class="mdescRight">helper function to perform vector multiplication with encryption or decryption matrix <a href="../../d6/d26/classciphers_1_1_hill_cipher.html#a40efd842a5cc44c233641ac2df13b0c0">More...</a><br /></td></tr>
<tr class="separator:a40efd842a5cc44c233641ac2df13b0c0"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ad36cbcc7a458b3f3a2af0c4aa1126590"><td class="memItemLeft" align="right" valign="top">static const <a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/numeric/valarray.html">std::valarray</a>&lt; uint8_t &gt;&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../d6/d26/classciphers_1_1_hill_cipher.html#ad36cbcc7a458b3f3a2af0c4aa1126590">mat_mul</a> (const <a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/numeric/valarray.html">std::valarray</a>&lt; uint8_t &gt; &amp;vector, const <a class="el" href="../../d1/dbe/lu__decomposition_8h.html#aed8766713ee9b561a4acdcdff5f90ea5">matrix</a>&lt; int &gt; &amp;key)</td></tr>
<tr class="memdesc:ad36cbcc7a458b3f3a2af0c4aa1126590"><td class="mdescLeft">&#160;</td><td class="mdescRight">helper function to perform vector multiplication with encryption or decryption matrix <a href="../../d6/d26/classciphers_1_1_hill_cipher.html#ad36cbcc7a458b3f3a2af0c4aa1126590">More...</a><br /></td></tr>
<tr class="separator:ad36cbcc7a458b3f3a2af0c4aa1126590"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a12f727cca9e21f9539cd74b6603adf0c"><td class="memItemLeft" align="right" valign="top">static char&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../d6/d26/classciphers_1_1_hill_cipher.html#a12f727cca9e21f9539cd74b6603adf0c">get_idx_char</a> (const uint8_t idx)</td></tr>
<tr class="memdesc:a12f727cca9e21f9539cd74b6603adf0c"><td class="mdescLeft">&#160;</td><td class="mdescRight">Get the character at a given index in the <a class="el" href="../../d6/d4e/namespaceciphers.html#ab9aec0ccf4b6809f652bb540be87c216">STRKEY</a>. <a href="../../d6/d26/classciphers_1_1_hill_cipher.html#a12f727cca9e21f9539cd74b6603adf0c">More...</a><br /></td></tr>
<tr class="separator:a12f727cca9e21f9539cd74b6603adf0c"><td class="memSeparator" colspan="2">&#160;</td></tr>
@@ -146,17 +145,16 @@ Static Private Member Functions</h2></td></tr>
<tr class="memitem:ad667fa0860977f6d6d443fa1dbcd80aa"><td class="memItemLeft" align="right" valign="top">static const <a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/string/basic_string.html">std::string</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../d6/d26/classciphers_1_1_hill_cipher.html#ad667fa0860977f6d6d443fa1dbcd80aa">codec</a> (const <a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/string/basic_string.html">std::string</a> &amp;text, const <a class="el" href="../../d1/dbe/lu__decomposition_8h.html#aed8766713ee9b561a4acdcdff5f90ea5">matrix</a>&lt; int &gt; &amp;key)</td></tr>
<tr class="memdesc:ad667fa0860977f6d6d443fa1dbcd80aa"><td class="mdescLeft">&#160;</td><td class="mdescRight">Convenience function to perform block cipher operations. The operations are identical for both encryption and decryption. <a href="../../d6/d26/classciphers_1_1_hill_cipher.html#ad667fa0860977f6d6d443fa1dbcd80aa">More...</a><br /></td></tr>
<tr class="separator:ad667fa0860977f6d6d443fa1dbcd80aa"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a5a4cdbd4d4dad9efe2ed309bd466dd4b"><td class="memTemplParams" colspan="2">template&lt;typename T &gt; </td></tr>
<tr class="memitem:a5a4cdbd4d4dad9efe2ed309bd466dd4b"><td class="memTemplItemLeft" align="right" valign="top">static <a class="el" href="../../d1/dbe/lu__decomposition_8h.html#aed8766713ee9b561a4acdcdff5f90ea5">matrix</a>&lt; double &gt;&#160;</td><td class="memTemplItemRight" valign="bottom"><a class="el" href="../../d6/d26/classciphers_1_1_hill_cipher.html#a5a4cdbd4d4dad9efe2ed309bd466dd4b">get_inverse</a> (<a class="el" href="../../d1/dbe/lu__decomposition_8h.html#aed8766713ee9b561a4acdcdff5f90ea5">matrix</a>&lt; T &gt; const &amp;A)</td></tr>
<tr class="separator:a5a4cdbd4d4dad9efe2ed309bd466dd4b"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a63e7b8e92dff8b9260d6d21c31ecebd0"><td class="memItemLeft" align="right" valign="top"><a id="a63e7b8e92dff8b9260d6d21c31ecebd0"></a>
static int&#160;</td><td class="memItemRight" valign="bottom"><b>modulo</b> (int a, int b)</td></tr>
<tr class="memitem:a2eb58750b978a93ac5e6eb29e3e570b7"><td class="memTemplParams" colspan="2">template&lt;typename T &gt; </td></tr>
<tr class="memitem:a2eb58750b978a93ac5e6eb29e3e570b7"><td class="memTemplItemLeft" align="right" valign="top">static <a class="el" href="../../d1/dbe/lu__decomposition_8h.html#aed8766713ee9b561a4acdcdff5f90ea5">matrix</a>&lt; double &gt;&#160;</td><td class="memTemplItemRight" valign="bottom"><a class="el" href="../../d6/d26/classciphers_1_1_hill_cipher.html#a2eb58750b978a93ac5e6eb29e3e570b7">get_inverse</a> (<a class="el" href="../../d1/dbe/lu__decomposition_8h.html#aed8766713ee9b561a4acdcdff5f90ea5">matrix</a>&lt; T &gt; const &amp;A)</td></tr>
<tr class="separator:a2eb58750b978a93ac5e6eb29e3e570b7"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a63e7b8e92dff8b9260d6d21c31ecebd0"><td class="memItemLeft" align="right" valign="top">static int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../d6/d26/classciphers_1_1_hill_cipher.html#a63e7b8e92dff8b9260d6d21c31ecebd0">modulo</a> (int a, int b)</td></tr>
<tr class="separator:a63e7b8e92dff8b9260d6d21c31ecebd0"><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/Hill_cipher">Hill Cipher</a> algorithm. </p>
<div class="textblock"><p >Implementation of <a href="https://en.wikipedia.org/wiki/Hill_cipher" target="_blank">Hill Cipher</a> algorithm. </p>
</div><h2 class="groupheader">Member Function Documentation</h2>
<a id="ad667fa0860977f6d6d443fa1dbcd80aa"></a>
<a id="ad667fa0860977f6d6d443fa1dbcd80aa" name="ad667fa0860977f6d6d443fa1dbcd80aa"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ad667fa0860977f6d6d443fa1dbcd80aa">&#9670;&nbsp;</a></span>codec()</h2>
<div class="memitem">
@@ -199,40 +197,40 @@ static int&#160;</td><td class="memItemRight" valign="bottom"><b>modulo</b> (int
</dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>encrypted/decrypted output </dd></dl>
<div class="fragment"><div class="line"><a name="l00211"></a><span class="lineno"> 211</span>&#160; {</div>
<div class="line"><a name="l00212"></a><span class="lineno"> 212</span>&#160; <span class="keywordtype">size_t</span> text_len = text.<a class="codeRef" target="_blank" href="http://en.cppreference.com/w/cpp/string/basic_string/size.html">length</a>();</div>
<div class="line"><a name="l00213"></a><span class="lineno"> 213</span>&#160; <span class="keywordtype">size_t</span> key_len = key.<a class="codeRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector/size.html">size</a>();</div>
<div class="line"><a name="l00214"></a><span class="lineno"> 214</span>&#160; </div>
<div class="line"><a name="l00215"></a><span class="lineno"> 215</span>&#160; <span class="comment">// length of output string must be a multiple of key_len</span></div>
<div class="line"><a name="l00216"></a><span class="lineno"> 216</span>&#160; <span class="comment">// create output string and initialize with &#39;\0&#39; character</span></div>
<div class="line"><a name="l00217"></a><span class="lineno"> 217</span>&#160; <span class="keywordtype">size_t</span> L2 = text_len % key_len == 0</div>
<div class="line"><a name="l00218"></a><span class="lineno"> 218</span>&#160; ? text_len</div>
<div class="line"><a name="l00219"></a><span class="lineno"> 219</span>&#160; : text_len + key_len - (text_len % key_len);</div>
<div class="line"><a name="l00220"></a><span class="lineno"> 220</span>&#160; <a class="codeRef" target="_blank" href="http://en.cppreference.com/w/cpp/string/basic_string.html">std::string</a> coded_text(L2, <span class="charliteral">&#39;\0&#39;</span>);</div>
<div class="line"><a name="l00221"></a><span class="lineno"> 221</span>&#160; </div>
<div class="line"><a name="l00222"></a><span class="lineno"> 222</span>&#160; <span class="comment">// temporary array for batch processing</span></div>
<div class="line"><a name="l00223"></a><span class="lineno"> 223</span>&#160; <span class="keywordtype">int</span> i;</div>
<div class="line"><a name="l00224"></a><span class="lineno"> 224</span>&#160;<span class="preprocessor">#ifdef _OPENMP</span></div>
<div class="line"><a name="l00225"></a><span class="lineno"> 225</span>&#160;<span class="preprocessor">#pragma parallel omp for private(i)</span></div>
<div class="line"><a name="l00226"></a><span class="lineno"> 226</span>&#160;<span class="preprocessor">#endif</span></div>
<div class="line"><a name="l00227"></a><span class="lineno"> 227</span>&#160; <span class="keywordflow">for</span> (i = 0; i &lt; L2 - key_len + 1; i += key_len) {</div>
<div class="line"><a name="l00228"></a><span class="lineno"> 228</span>&#160; <a class="codeRef" target="_blank" href="http://en.cppreference.com/w/cpp/numeric/valarray.html">std::valarray&lt;uint8_t&gt;</a> batch_int(key_len);</div>
<div class="line"><a name="l00229"></a><span class="lineno"> 229</span>&#160; <span class="keywordflow">for</span> (<span class="keywordtype">size_t</span> j = 0; j &lt; key_len; j++) {</div>
<div class="line"><a name="l00230"></a><span class="lineno"> 230</span>&#160; batch_int[j] = <a class="code" href="../../d6/d26/classciphers_1_1_hill_cipher.html#ae77cad522fa44b8c985779a7188d2f41">get_char_idx</a>(text[i + j]);</div>
<div class="line"><a name="l00231"></a><span class="lineno"> 231</span>&#160; }</div>
<div class="line"><a name="l00232"></a><span class="lineno"> 232</span>&#160; </div>
<div class="line"><a name="l00233"></a><span class="lineno"> 233</span>&#160; batch_int = <a class="code" href="../../d6/d26/classciphers_1_1_hill_cipher.html#a40efd842a5cc44c233641ac2df13b0c0">mat_mul</a>(batch_int, key);</div>
<div class="line"><a name="l00234"></a><span class="lineno"> 234</span>&#160; </div>
<div class="line"><a name="l00235"></a><span class="lineno"> 235</span>&#160; <span class="keywordflow">for</span> (<span class="keywordtype">size_t</span> j = 0; j &lt; key_len; j++) {</div>
<div class="line"><a name="l00236"></a><span class="lineno"> 236</span>&#160; coded_text[i + j] =</div>
<div class="line"><a name="l00237"></a><span class="lineno"> 237</span>&#160; <a class="code" href="../../d6/d4e/namespaceciphers.html#ab9aec0ccf4b6809f652bb540be87c216">STRKEY</a>[batch_int[j]]; <span class="comment">// get character at key</span></div>
<div class="line"><a name="l00238"></a><span class="lineno"> 238</span>&#160; }</div>
<div class="line"><a name="l00239"></a><span class="lineno"> 239</span>&#160; }</div>
<div class="line"><a name="l00240"></a><span class="lineno"> 240</span>&#160; </div>
<div class="line"><a name="l00241"></a><span class="lineno"> 241</span>&#160; <span class="keywordflow">return</span> coded_text;</div>
<div class="line"><a name="l00242"></a><span class="lineno"> 242</span>&#160; }</div>
<div class="fragment"><div class="line"><a id="l00211" name="l00211"></a><span class="lineno"> 211</span> {</div>
<div class="line"><a id="l00212" name="l00212"></a><span class="lineno"> 212</span> <span class="keywordtype">size_t</span> text_len = text.<a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/string/basic_string/size.html">length</a>();</div>
<div class="line"><a id="l00213" name="l00213"></a><span class="lineno"> 213</span> <span class="keywordtype">size_t</span> key_len = key.<a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector/size.html">size</a>();</div>
<div class="line"><a id="l00214" name="l00214"></a><span class="lineno"> 214</span> </div>
<div class="line"><a id="l00215" name="l00215"></a><span class="lineno"> 215</span> <span class="comment">// length of output string must be a multiple of key_len</span></div>
<div class="line"><a id="l00216" name="l00216"></a><span class="lineno"> 216</span> <span class="comment">// create output string and initialize with &#39;\0&#39; character</span></div>
<div class="line"><a id="l00217" name="l00217"></a><span class="lineno"> 217</span> <span class="keywordtype">size_t</span> L2 = text_len % key_len == 0</div>
<div class="line"><a id="l00218" name="l00218"></a><span class="lineno"> 218</span> ? text_len</div>
<div class="line"><a id="l00219" name="l00219"></a><span class="lineno"> 219</span> : text_len + key_len - (text_len % key_len);</div>
<div class="line"><a id="l00220" name="l00220"></a><span class="lineno"> 220</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/string/basic_string.html">std::string</a> coded_text(L2, <span class="charliteral">&#39;\0&#39;</span>);</div>
<div class="line"><a id="l00221" name="l00221"></a><span class="lineno"> 221</span> </div>
<div class="line"><a id="l00222" name="l00222"></a><span class="lineno"> 222</span> <span class="comment">// temporary array for batch processing</span></div>
<div class="line"><a id="l00223" name="l00223"></a><span class="lineno"> 223</span> <span class="keywordtype">int</span> i;</div>
<div class="line"><a id="l00224" name="l00224"></a><span class="lineno"> 224</span><span class="preprocessor">#ifdef _OPENMP</span></div>
<div class="line"><a id="l00225" name="l00225"></a><span class="lineno"> 225</span><span class="preprocessor">#pragma parallel omp for private(i)</span></div>
<div class="line"><a id="l00226" name="l00226"></a><span class="lineno"> 226</span><span class="preprocessor">#endif</span></div>
<div class="line"><a id="l00227" name="l00227"></a><span class="lineno"> 227</span> <span class="keywordflow">for</span> (i = 0; i &lt; L2 - key_len + 1; i += key_len) {</div>
<div class="line"><a id="l00228" name="l00228"></a><span class="lineno"> 228</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/numeric/valarray.html">std::valarray&lt;uint8_t&gt;</a> batch_int(key_len);</div>
<div class="line"><a id="l00229" name="l00229"></a><span class="lineno"> 229</span> <span class="keywordflow">for</span> (<span class="keywordtype">size_t</span> j = 0; j &lt; key_len; j++) {</div>
<div class="line"><a id="l00230" name="l00230"></a><span class="lineno"> 230</span> batch_int[j] = <a class="code hl_function" href="../../d6/d26/classciphers_1_1_hill_cipher.html#ae77cad522fa44b8c985779a7188d2f41">get_char_idx</a>(text[i + j]);</div>
<div class="line"><a id="l00231" name="l00231"></a><span class="lineno"> 231</span> }</div>
<div class="line"><a id="l00232" name="l00232"></a><span class="lineno"> 232</span> </div>
<div class="line"><a id="l00233" name="l00233"></a><span class="lineno"> 233</span> batch_int = <a class="code hl_function" href="../../d6/d26/classciphers_1_1_hill_cipher.html#ad36cbcc7a458b3f3a2af0c4aa1126590">mat_mul</a>(batch_int, key);</div>
<div class="line"><a id="l00234" name="l00234"></a><span class="lineno"> 234</span> </div>
<div class="line"><a id="l00235" name="l00235"></a><span class="lineno"> 235</span> <span class="keywordflow">for</span> (<span class="keywordtype">size_t</span> j = 0; j &lt; key_len; j++) {</div>
<div class="line"><a id="l00236" name="l00236"></a><span class="lineno"> 236</span> coded_text[i + j] =</div>
<div class="line"><a id="l00237" name="l00237"></a><span class="lineno"> 237</span> <a class="code hl_variable" href="../../d6/d4e/namespaceciphers.html#ab9aec0ccf4b6809f652bb540be87c216">STRKEY</a>[batch_int[j]]; <span class="comment">// get character at key</span></div>
<div class="line"><a id="l00238" name="l00238"></a><span class="lineno"> 238</span> }</div>
<div class="line"><a id="l00239" name="l00239"></a><span class="lineno"> 239</span> }</div>
<div class="line"><a id="l00240" name="l00240"></a><span class="lineno"> 240</span> </div>
<div class="line"><a id="l00241" name="l00241"></a><span class="lineno"> 241</span> <span class="keywordflow">return</span> coded_text;</div>
<div class="line"><a id="l00242" name="l00242"></a><span class="lineno"> 242</span> }</div>
<div class="ttc" id="abasic_string_html"><div class="ttname"><a href="http://en.cppreference.com/w/cpp/string/basic_string.html">std::string</a></div></div>
<div class="ttc" id="aclassciphers_1_1_hill_cipher_html_a40efd842a5cc44c233641ac2df13b0c0"><div class="ttname"><a href="../../d6/d26/classciphers_1_1_hill_cipher.html#a40efd842a5cc44c233641ac2df13b0c0">ciphers::HillCipher::mat_mul</a></div><div class="ttdeci">static const std::valarray&lt; uint8_t &gt; mat_mul(const std::valarray&lt; uint8_t &gt; &amp;vector, const matrix&lt; int &gt; &amp;key)</div><div class="ttdoc">helper function to perform vector multiplication with encryption or decryption matrix</div><div class="ttdef"><b>Definition:</b> hill_cipher.cpp:159</div></div>
<div class="ttc" id="aclassciphers_1_1_hill_cipher_html_ad36cbcc7a458b3f3a2af0c4aa1126590"><div class="ttname"><a href="../../d6/d26/classciphers_1_1_hill_cipher.html#ad36cbcc7a458b3f3a2af0c4aa1126590">ciphers::HillCipher::mat_mul</a></div><div class="ttdeci">static const std::valarray&lt; uint8_t &gt; mat_mul(const std::valarray&lt; uint8_t &gt; &amp;vector, const matrix&lt; int &gt; &amp;key)</div><div class="ttdoc">helper function to perform vector multiplication with encryption or decryption matrix</div><div class="ttdef"><b>Definition:</b> hill_cipher.cpp:159</div></div>
<div class="ttc" id="aclassciphers_1_1_hill_cipher_html_ae77cad522fa44b8c985779a7188d2f41"><div class="ttname"><a href="../../d6/d26/classciphers_1_1_hill_cipher.html#ae77cad522fa44b8c985779a7188d2f41">ciphers::HillCipher::get_char_idx</a></div><div class="ttdeci">static uint8_t get_char_idx(const char ch)</div><div class="ttdoc">Get the index of a character in the STRKEY.</div><div class="ttdef"><b>Definition:</b> hill_cipher.cpp:190</div></div>
<div class="ttc" id="anamespaceciphers_html_ab9aec0ccf4b6809f652bb540be87c216"><div class="ttname"><a href="../../d6/d4e/namespaceciphers.html#ab9aec0ccf4b6809f652bb540be87c216">ciphers::STRKEY</a></div><div class="ttdeci">static const char * STRKEY</div><div class="ttdef"><b>Definition:</b> hill_cipher.cpp:73</div></div>
<div class="ttc" id="asize_html"><div class="ttname"><a href="http://en.cppreference.com/w/cpp/string/basic_string/size.html">std::string::length</a></div><div class="ttdeci">T length(T... args)</div></div>
@@ -246,7 +244,7 @@ Here is the call graph for this function:</div>
</div>
</div>
<a id="a427acfac1dbff3f48a2b071d449d965b"></a>
<a id="a427acfac1dbff3f48a2b071d449d965b" name="a427acfac1dbff3f48a2b071d449d965b"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a427acfac1dbff3f48a2b071d449d965b">&#9670;&nbsp;</a></span>decrypt_text()</h2>
<div class="memitem">
@@ -289,9 +287,9 @@ Here is the call graph for this function:</div>
</dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>decrypted text </dd></dl>
<div class="fragment"><div class="line"><a name="l00458"></a><span class="lineno"> 458</span>&#160; {</div>
<div class="line"><a name="l00459"></a><span class="lineno"> 459</span>&#160; <span class="keywordflow">return</span> <a class="code" href="../../d6/d26/classciphers_1_1_hill_cipher.html#ad667fa0860977f6d6d443fa1dbcd80aa">codec</a>(text, decrypt_key);</div>
<div class="line"><a name="l00460"></a><span class="lineno"> 460</span>&#160; }</div>
<div class="fragment"><div class="line"><a id="l00458" name="l00458"></a><span class="lineno"> 458</span> {</div>
<div class="line"><a id="l00459" name="l00459"></a><span class="lineno"> 459</span> <span class="keywordflow">return</span> <a class="code hl_function" href="../../d6/d26/classciphers_1_1_hill_cipher.html#ad667fa0860977f6d6d443fa1dbcd80aa">codec</a>(text, decrypt_key);</div>
<div class="line"><a id="l00460" name="l00460"></a><span class="lineno"> 460</span> }</div>
<div class="ttc" id="aclassciphers_1_1_hill_cipher_html_ad667fa0860977f6d6d443fa1dbcd80aa"><div class="ttname"><a href="../../d6/d26/classciphers_1_1_hill_cipher.html#ad667fa0860977f6d6d443fa1dbcd80aa">ciphers::HillCipher::codec</a></div><div class="ttdeci">static const std::string codec(const std::string &amp;text, const matrix&lt; int &gt; &amp;key)</div><div class="ttdoc">Convenience function to perform block cipher operations. The operations are identical for both encryp...</div><div class="ttdef"><b>Definition:</b> hill_cipher.cpp:210</div></div>
</div><!-- fragment --><div class="dynheader">
Here is the call graph for this function:</div>
@@ -302,7 +300,7 @@ Here is the call graph for this function:</div>
</div>
</div>
<a id="aa8bbb6e4a5749f6008b06602d5103917"></a>
<a id="aa8bbb6e4a5749f6008b06602d5103917" name="aa8bbb6e4a5749f6008b06602d5103917"></a>
<h2 class="memtitle"><span class="permalink"><a href="#aa8bbb6e4a5749f6008b06602d5103917">&#9670;&nbsp;</a></span>encrypt_text()</h2>
<div class="memitem">
@@ -345,9 +343,9 @@ Here is the call graph for this function:</div>
</dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>encrypted text </dd></dl>
<div class="fragment"><div class="line"><a name="l00446"></a><span class="lineno"> 446</span>&#160; {</div>
<div class="line"><a name="l00447"></a><span class="lineno"> 447</span>&#160; <span class="keywordflow">return</span> <a class="code" href="../../d6/d26/classciphers_1_1_hill_cipher.html#ad667fa0860977f6d6d443fa1dbcd80aa">codec</a>(text, encrypt_key);</div>
<div class="line"><a name="l00448"></a><span class="lineno"> 448</span>&#160; }</div>
<div class="fragment"><div class="line"><a id="l00446" name="l00446"></a><span class="lineno"> 446</span> {</div>
<div class="line"><a id="l00447" name="l00447"></a><span class="lineno"> 447</span> <span class="keywordflow">return</span> <a class="code hl_function" href="../../d6/d26/classciphers_1_1_hill_cipher.html#ad667fa0860977f6d6d443fa1dbcd80aa">codec</a>(text, encrypt_key);</div>
<div class="line"><a id="l00448" name="l00448"></a><span class="lineno"> 448</span> }</div>
</div><!-- fragment --><div class="dynheader">
Here is the call graph for this function:</div>
<div class="dyncontent">
@@ -357,7 +355,7 @@ Here is the call graph for this function:</div>
</div>
</div>
<a id="a7760f3665651a0a37937c79c62f219c0"></a>
<a id="a7760f3665651a0a37937c79c62f219c0" name="a7760f3665651a0a37937c79c62f219c0"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a7760f3665651a0a37937c79c62f219c0">&#9670;&nbsp;</a></span>gcd()</h2>
<div class="memitem">
@@ -393,7 +391,7 @@ template&lt;typename T &gt; </div>
</table>
</div><div class="memdoc">
<p>Compute <a href="https://en.wikipedia.org/wiki/Greatest_common_divisor">GCD</a> of two integers using Euler's algorithm. </p>
<p>Compute <a href="https://en.wikipedia.org/wiki/Greatest_common_divisor" target="_blank">GCD</a> of two integers using Euler's algorithm. </p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">a</td><td>first number </td></tr>
@@ -402,18 +400,18 @@ template&lt;typename T &gt; </div>
</dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>GCD of \(a\) and \(b\) </dd></dl>
<div class="fragment"><div class="line"><a name="l00138"></a><span class="lineno"> 138</span>&#160; {</div>
<div class="line"><a name="l00139"></a><span class="lineno"> 139</span>&#160; <span class="keywordflow">if</span> (b &gt; a) <span class="comment">// ensure always a &lt; b</span></div>
<div class="line"><a name="l00140"></a><span class="lineno"> 140</span>&#160; <a class="codeRef" target="_blank" href="http://en.cppreference.com/w/cpp/algorithm/swap.html">std::swap</a>(a, b);</div>
<div class="line"><a name="l00141"></a><span class="lineno"> 141</span>&#160; </div>
<div class="line"><a name="l00142"></a><span class="lineno"> 142</span>&#160; <span class="keywordflow">while</span> (b != 0) {</div>
<div class="line"><a name="l00143"></a><span class="lineno"> 143</span>&#160; T tmp = b;</div>
<div class="line"><a name="l00144"></a><span class="lineno"> 144</span>&#160; b = a % b;</div>
<div class="line"><a name="l00145"></a><span class="lineno"> 145</span>&#160; a = tmp;</div>
<div class="line"><a name="l00146"></a><span class="lineno"> 146</span>&#160; }</div>
<div class="line"><a name="l00147"></a><span class="lineno"> 147</span>&#160; </div>
<div class="line"><a name="l00148"></a><span class="lineno"> 148</span>&#160; <span class="keywordflow">return</span> a;</div>
<div class="line"><a name="l00149"></a><span class="lineno"> 149</span>&#160; }</div>
<div class="fragment"><div class="line"><a id="l00138" name="l00138"></a><span class="lineno"> 138</span> {</div>
<div class="line"><a id="l00139" name="l00139"></a><span class="lineno"> 139</span> <span class="keywordflow">if</span> (b &gt; a) <span class="comment">// ensure always a &lt; b</span></div>
<div class="line"><a id="l00140" name="l00140"></a><span class="lineno"> 140</span> <a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/algorithm/swap.html">std::swap</a>(a, b);</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> <span class="keywordflow">while</span> (b != 0) {</div>
<div class="line"><a id="l00143" name="l00143"></a><span class="lineno"> 143</span> T tmp = b;</div>
<div class="line"><a id="l00144" name="l00144"></a><span class="lineno"> 144</span> b = a % b;</div>
<div class="line"><a id="l00145" name="l00145"></a><span class="lineno"> 145</span> a = tmp;</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> </div>
<div class="line"><a id="l00148" name="l00148"></a><span class="lineno"> 148</span> <span class="keywordflow">return</span> a;</div>
<div class="line"><a id="l00149" name="l00149"></a><span class="lineno"> 149</span> }</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">
Here is the call graph for this function:</div>
@@ -424,8 +422,8 @@ Here is the call graph for this function:</div>
</div>
</div>
<a id="abb2c4dc2b8a59d3dfe0fa22c2adc086b"></a>
<h2 class="memtitle"><span class="permalink"><a href="#abb2c4dc2b8a59d3dfe0fa22c2adc086b">&#9670;&nbsp;</a></span>generate_decryption_key()</h2>
<a id="ab02c7563889bf1e363deb8e21967b706" name="ab02c7563889bf1e363deb8e21967b706"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ab02c7563889bf1e363deb8e21967b706">&#9670;&nbsp;</a></span>generate_decryption_key()</h2>
<div class="memitem">
<div class="memproto">
@@ -434,7 +432,7 @@ Here is the call graph for this function:</div>
<td class="mlabels-left">
<table class="memname">
<tr>
<td class="memname">static <a class="el" href="../../d1/dbe/lu__decomposition_8h.html#aed8766713ee9b561a4acdcdff5f90ea5">matrix</a>&lt;int&gt; ciphers::HillCipher::generate_decryption_key </td>
<td class="memname">static <a class="el" href="../../d1/dbe/lu__decomposition_8h.html#aed8766713ee9b561a4acdcdff5f90ea5">matrix</a>&lt; int &gt; ciphers::HillCipher::generate_decryption_key </td>
<td>(</td>
<td class="paramtype"><a class="el" href="../../d1/dbe/lu__decomposition_8h.html#aed8766713ee9b561a4acdcdff5f90ea5">matrix</a>&lt; int &gt; const &amp;&#160;</td>
<td class="paramname"><em>encrypt_key</em></td><td>)</td>
@@ -456,49 +454,49 @@ Here is the call graph for this function:</div>
</dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>Decryption martix </dd></dl>
<div class="fragment"><div class="line"><a name="l00371"></a><span class="lineno"> 371</span>&#160; {</div>
<div class="line"><a name="l00372"></a><span class="lineno"> 372</span>&#160; <span class="keywordtype">size_t</span> size = encrypt_key.<a class="codeRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector/size.html">size</a>();</div>
<div class="line"><a name="l00373"></a><span class="lineno"> 373</span>&#160; <span class="keywordtype">int</span> L = <a class="codeRef" target="_blank" href="http://en.cppreference.com/w/cpp/string/byte/strlen.html">std::strlen</a>(<a class="code" href="../../d6/d4e/namespaceciphers.html#ab9aec0ccf4b6809f652bb540be87c216">STRKEY</a>);</div>
<div class="line"><a name="l00374"></a><span class="lineno"> 374</span>&#160; </div>
<div class="line"><a name="l00375"></a><span class="lineno"> 375</span>&#160; <a class="codeRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">matrix&lt;int&gt;</a> decrypt_key(size, <a class="codeRef" target="_blank" href="http://en.cppreference.com/w/cpp/numeric/valarray.html">std::valarray&lt;int&gt;</a>(size));</div>
<div class="line"><a name="l00376"></a><span class="lineno"> 376</span>&#160; <span class="keywordtype">int</span> det_encrypt = <span class="keyword">static_cast&lt;</span><span class="keywordtype">int</span><span class="keyword">&gt;</span>(<a class="code" href="../../d1/dbe/lu__decomposition_8h.html#a3108d43bd32c6fb3b3c158476c51ba7f">determinant_lu</a>(encrypt_key));</div>
<div class="line"><a name="l00377"></a><span class="lineno"> 377</span>&#160; </div>
<div class="line"><a name="l00378"></a><span class="lineno"> 378</span>&#160; <span class="keywordtype">int</span> mat_determinant = det_encrypt &lt; 0 ? det_encrypt % L : det_encrypt;</div>
<div class="line"><a name="l00379"></a><span class="lineno"> 379</span>&#160; </div>
<div class="line"><a name="l00380"></a><span class="lineno"> 380</span>&#160; <a class="codeRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">matrix&lt;double&gt;</a> tmp_inverse = <a class="code" href="../../d6/d26/classciphers_1_1_hill_cipher.html#a5a4cdbd4d4dad9efe2ed309bd466dd4b">get_inverse</a>(encrypt_key);</div>
<div class="line"><a name="l00381"></a><span class="lineno"> 381</span>&#160; <span class="keywordtype">double</span> d2 = <a class="code" href="../../d1/dbe/lu__decomposition_8h.html#a3108d43bd32c6fb3b3c158476c51ba7f">determinant_lu</a>(decrypt_key);</div>
<div class="line"><a name="l00382"></a><span class="lineno"> 382</span>&#160; </div>
<div class="line"><a name="l00383"></a><span class="lineno"> 383</span>&#160; <span class="comment">// find co-prime factor for inversion</span></div>
<div class="line"><a name="l00384"></a><span class="lineno"> 384</span>&#160; <span class="keywordtype">int</span> det_inv = -1;</div>
<div class="line"><a name="l00385"></a><span class="lineno"> 385</span>&#160; <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i &lt; L; i++) {</div>
<div class="line"><a name="l00386"></a><span class="lineno"> 386</span>&#160; <span class="keywordflow">if</span> (modulo(mat_determinant * i, L) == 1) {</div>
<div class="line"><a name="l00387"></a><span class="lineno"> 387</span>&#160; det_inv = i;</div>
<div class="line"><a name="l00388"></a><span class="lineno"> 388</span>&#160; <span class="keywordflow">break</span>;</div>
<div class="line"><a name="l00389"></a><span class="lineno"> 389</span>&#160; }</div>
<div class="line"><a name="l00390"></a><span class="lineno"> 390</span>&#160; }</div>
<div class="line"><a name="l00391"></a><span class="lineno"> 391</span>&#160; </div>
<div class="line"><a name="l00392"></a><span class="lineno"> 392</span>&#160; <span class="keywordflow">if</span> (det_inv == -1) {</div>
<div class="line"><a name="l00393"></a><span class="lineno"> 393</span>&#160; <a class="codeRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/basic_ostream.html">std::cerr</a> &lt;&lt; <span class="stringliteral">&quot;Could not find a co-prime for inversion\n&quot;</span>;</div>
<div class="line"><a name="l00394"></a><span class="lineno"> 394</span>&#160; <a class="codeRef" target="_blank" href="http://en.cppreference.com/w/cpp/utility/program/exit.html">std::exit</a>(EXIT_FAILURE);</div>
<div class="line"><a name="l00395"></a><span class="lineno"> 395</span>&#160; }</div>
<div class="line"><a name="l00396"></a><span class="lineno"> 396</span>&#160; </div>
<div class="line"><a name="l00397"></a><span class="lineno"> 397</span>&#160; mat_determinant = det_inv * det_encrypt;</div>
<div class="line"><a name="l00398"></a><span class="lineno"> 398</span>&#160; </div>
<div class="line"><a name="l00399"></a><span class="lineno"> 399</span>&#160; <span class="comment">// perform modular inverse of encryption matrix</span></div>
<div class="line"><a name="l00400"></a><span class="lineno"> 400</span>&#160; <span class="keywordtype">int</span> i;</div>
<div class="line"><a name="l00401"></a><span class="lineno"> 401</span>&#160;<span class="preprocessor">#ifdef _OPENMP</span></div>
<div class="line"><a name="l00402"></a><span class="lineno"> 402</span>&#160;<span class="preprocessor">#pragma parallel omp for private(i)</span></div>
<div class="line"><a name="l00403"></a><span class="lineno"> 403</span>&#160;<span class="preprocessor">#endif</span></div>
<div class="line"><a name="l00404"></a><span class="lineno"> 404</span>&#160; <span class="keywordflow">for</span> (i = 0; i &lt; size; i++) {</div>
<div class="line"><a name="l00405"></a><span class="lineno"> 405</span>&#160; <span class="keywordflow">for</span> (<span class="keywordtype">int</span> j = 0; j &lt; size; j++) {</div>
<div class="line"><a name="l00406"></a><span class="lineno"> 406</span>&#160; <span class="keywordtype">int</span> temp = <a class="codeRef" target="_blank" href="http://en.cppreference.com/w/cpp/numeric/math/round.html">std::round</a>(tmp_inverse[i][j] * mat_determinant);</div>
<div class="line"><a name="l00407"></a><span class="lineno"> 407</span>&#160; decrypt_key[i][j] = modulo(temp, L);</div>
<div class="line"><a name="l00408"></a><span class="lineno"> 408</span>&#160; }</div>
<div class="line"><a name="l00409"></a><span class="lineno"> 409</span>&#160; }</div>
<div class="line"><a name="l00410"></a><span class="lineno"> 410</span>&#160; <span class="keywordflow">return</span> decrypt_key;</div>
<div class="line"><a name="l00411"></a><span class="lineno"> 411</span>&#160; }</div>
<div class="fragment"><div class="line"><a id="l00371" name="l00371"></a><span class="lineno"> 371</span> {</div>
<div class="line"><a id="l00372" name="l00372"></a><span class="lineno"> 372</span> <span class="keywordtype">size_t</span> size = encrypt_key.<a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector/size.html">size</a>();</div>
<div class="line"><a id="l00373" name="l00373"></a><span class="lineno"> 373</span> <span class="keywordtype">int</span> L = <a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/string/byte/strlen.html">std::strlen</a>(<a class="code hl_variable" href="../../d6/d4e/namespaceciphers.html#ab9aec0ccf4b6809f652bb540be87c216">STRKEY</a>);</div>
<div class="line"><a id="l00374" name="l00374"></a><span class="lineno"> 374</span> </div>
<div class="line"><a id="l00375" name="l00375"></a><span class="lineno"> 375</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">matrix&lt;int&gt;</a> decrypt_key(size, <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/numeric/valarray.html">std::valarray&lt;int&gt;</a>(size));</div>
<div class="line"><a id="l00376" name="l00376"></a><span class="lineno"> 376</span> <span class="keywordtype">int</span> det_encrypt = <span class="keyword">static_cast&lt;</span><span class="keywordtype">int</span><span class="keyword">&gt;</span>(<a class="code hl_function" href="../../d1/dbe/lu__decomposition_8h.html#a3108d43bd32c6fb3b3c158476c51ba7f">determinant_lu</a>(encrypt_key));</div>
<div class="line"><a id="l00377" name="l00377"></a><span class="lineno"> 377</span> </div>
<div class="line"><a id="l00378" name="l00378"></a><span class="lineno"> 378</span> <span class="keywordtype">int</span> mat_determinant = det_encrypt &lt; 0 ? det_encrypt % L : det_encrypt;</div>
<div class="line"><a id="l00379" name="l00379"></a><span class="lineno"> 379</span> </div>
<div class="line"><a id="l00380" name="l00380"></a><span class="lineno"> 380</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">matrix&lt;double&gt;</a> tmp_inverse = <a class="code hl_function" href="../../d6/d26/classciphers_1_1_hill_cipher.html#a2eb58750b978a93ac5e6eb29e3e570b7">get_inverse</a>(encrypt_key);</div>
<div class="line"><a id="l00381" name="l00381"></a><span class="lineno"> 381</span> <span class="keywordtype">double</span> d2 = <a class="code hl_function" href="../../d1/dbe/lu__decomposition_8h.html#a3108d43bd32c6fb3b3c158476c51ba7f">determinant_lu</a>(decrypt_key);</div>
<div class="line"><a id="l00382" name="l00382"></a><span class="lineno"> 382</span> </div>
<div class="line"><a id="l00383" name="l00383"></a><span class="lineno"> 383</span> <span class="comment">// find co-prime factor for inversion</span></div>
<div class="line"><a id="l00384" name="l00384"></a><span class="lineno"> 384</span> <span class="keywordtype">int</span> det_inv = -1;</div>
<div class="line"><a id="l00385" name="l00385"></a><span class="lineno"> 385</span> <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i &lt; L; i++) {</div>
<div class="line"><a id="l00386" name="l00386"></a><span class="lineno"> 386</span> <span class="keywordflow">if</span> (modulo(mat_determinant * i, L) == 1) {</div>
<div class="line"><a id="l00387" name="l00387"></a><span class="lineno"> 387</span> det_inv = i;</div>
<div class="line"><a id="l00388" name="l00388"></a><span class="lineno"> 388</span> <span class="keywordflow">break</span>;</div>
<div class="line"><a id="l00389" name="l00389"></a><span class="lineno"> 389</span> }</div>
<div class="line"><a id="l00390" name="l00390"></a><span class="lineno"> 390</span> }</div>
<div class="line"><a id="l00391" name="l00391"></a><span class="lineno"> 391</span> </div>
<div class="line"><a id="l00392" name="l00392"></a><span class="lineno"> 392</span> <span class="keywordflow">if</span> (det_inv == -1) {</div>
<div class="line"><a id="l00393" name="l00393"></a><span class="lineno"> 393</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;Could not find a co-prime for inversion\n&quot;</span>;</div>
<div class="line"><a id="l00394" name="l00394"></a><span class="lineno"> 394</span> <a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/utility/program/exit.html">std::exit</a>(EXIT_FAILURE);</div>
<div class="line"><a id="l00395" name="l00395"></a><span class="lineno"> 395</span> }</div>
<div class="line"><a id="l00396" name="l00396"></a><span class="lineno"> 396</span> </div>
<div class="line"><a id="l00397" name="l00397"></a><span class="lineno"> 397</span> mat_determinant = det_inv * det_encrypt;</div>
<div class="line"><a id="l00398" name="l00398"></a><span class="lineno"> 398</span> </div>
<div class="line"><a id="l00399" name="l00399"></a><span class="lineno"> 399</span> <span class="comment">// perform modular inverse of encryption matrix</span></div>
<div class="line"><a id="l00400" name="l00400"></a><span class="lineno"> 400</span> <span class="keywordtype">int</span> i;</div>
<div class="line"><a id="l00401" name="l00401"></a><span class="lineno"> 401</span><span class="preprocessor">#ifdef _OPENMP</span></div>
<div class="line"><a id="l00402" name="l00402"></a><span class="lineno"> 402</span><span class="preprocessor">#pragma parallel omp for private(i)</span></div>
<div class="line"><a id="l00403" name="l00403"></a><span class="lineno"> 403</span><span class="preprocessor">#endif</span></div>
<div class="line"><a id="l00404" name="l00404"></a><span class="lineno"> 404</span> <span class="keywordflow">for</span> (i = 0; i &lt; size; i++) {</div>
<div class="line"><a id="l00405" name="l00405"></a><span class="lineno"> 405</span> <span class="keywordflow">for</span> (<span class="keywordtype">int</span> j = 0; j &lt; size; j++) {</div>
<div class="line"><a id="l00406" name="l00406"></a><span class="lineno"> 406</span> <span class="keywordtype">int</span> temp = <a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/numeric/math/round.html">std::round</a>(tmp_inverse[i][j] * mat_determinant);</div>
<div class="line"><a id="l00407" name="l00407"></a><span class="lineno"> 407</span> decrypt_key[i][j] = modulo(temp, L);</div>
<div class="line"><a id="l00408" name="l00408"></a><span class="lineno"> 408</span> }</div>
<div class="line"><a id="l00409" name="l00409"></a><span class="lineno"> 409</span> }</div>
<div class="line"><a id="l00410" name="l00410"></a><span class="lineno"> 410</span> <span class="keywordflow">return</span> decrypt_key;</div>
<div class="line"><a id="l00411" name="l00411"></a><span class="lineno"> 411</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="aclassciphers_1_1_hill_cipher_html_a5a4cdbd4d4dad9efe2ed309bd466dd4b"><div class="ttname"><a href="../../d6/d26/classciphers_1_1_hill_cipher.html#a5a4cdbd4d4dad9efe2ed309bd466dd4b">ciphers::HillCipher::get_inverse</a></div><div class="ttdeci">static matrix&lt; double &gt; get_inverse(matrix&lt; T &gt; const &amp;A)</div><div class="ttdef"><b>Definition:</b> hill_cipher.cpp:250</div></div>
<div class="ttc" id="aclassciphers_1_1_hill_cipher_html_a2eb58750b978a93ac5e6eb29e3e570b7"><div class="ttname"><a href="../../d6/d26/classciphers_1_1_hill_cipher.html#a2eb58750b978a93ac5e6eb29e3e570b7">ciphers::HillCipher::get_inverse</a></div><div class="ttdeci">static matrix&lt; double &gt; get_inverse(matrix&lt; T &gt; const &amp;A)</div><div class="ttdef"><b>Definition:</b> hill_cipher.cpp:250</div></div>
<div class="ttc" id="aexit_html"><div class="ttname"><a href="http://en.cppreference.com/w/cpp/utility/program/exit.html">std::exit</a></div><div class="ttdeci">T exit(T... args)</div></div>
<div class="ttc" id="alu__decomposition_8h_html_a3108d43bd32c6fb3b3c158476c51ba7f"><div class="ttname"><a href="../../d1/dbe/lu__decomposition_8h.html#a3108d43bd32c6fb3b3c158476c51ba7f">determinant_lu</a></div><div class="ttdeci">double determinant_lu(const matrix&lt; T &gt; &amp;A)</div><div class="ttdef"><b>Definition:</b> lu_decomposition.h:90</div></div>
<div class="ttc" id="around_html"><div class="ttname"><a href="http://en.cppreference.com/w/cpp/numeric/math/round.html">std::round</a></div><div class="ttdeci">T round(T... args)</div></div>
@@ -507,8 +505,8 @@ Here is the call graph for this function:</div>
</div><!-- fragment -->
</div>
</div>
<a id="a7ca10cd1a0e8e3732391e0427d2d0213"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a7ca10cd1a0e8e3732391e0427d2d0213">&#9670;&nbsp;</a></span>generate_encryption_key()</h2>
<a id="a642f70fb54cb50b00fb6df7c3f2b120e" name="a642f70fb54cb50b00fb6df7c3f2b120e"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a642f70fb54cb50b00fb6df7c3f2b120e">&#9670;&nbsp;</a></span>generate_encryption_key()</h2>
<div class="memitem">
<div class="memproto">
@@ -517,7 +515,7 @@ Here is the call graph for this function:</div>
<td class="mlabels-left">
<table class="memname">
<tr>
<td class="memname">static <a class="el" href="../../d1/dbe/lu__decomposition_8h.html#aed8766713ee9b561a4acdcdff5f90ea5">matrix</a>&lt;int&gt; ciphers::HillCipher::generate_encryption_key </td>
<td class="memname">static <a class="el" href="../../d1/dbe/lu__decomposition_8h.html#aed8766713ee9b561a4acdcdff5f90ea5">matrix</a>&lt; int &gt; ciphers::HillCipher::generate_encryption_key </td>
<td>(</td>
<td class="paramtype">size_t&#160;</td>
<td class="paramname"><em>size</em>, </td>
@@ -561,38 +559,38 @@ Here is the call graph for this function:</div>
</dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>Encryption martix </dd></dl>
<div class="fragment"><div class="line"><a name="l00340"></a><span class="lineno"> 340</span>&#160; {</div>
<div class="line"><a name="l00341"></a><span class="lineno"> 341</span>&#160; <a class="codeRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">matrix&lt;int&gt;</a> encrypt_key(size, <a class="codeRef" target="_blank" href="http://en.cppreference.com/w/cpp/numeric/valarray.html">std::valarray&lt;int&gt;</a>(size));</div>
<div class="line"><a name="l00342"></a><span class="lineno"> 342</span>&#160; <a class="codeRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">matrix&lt;int&gt;</a> min_mat = encrypt_key;</div>
<div class="line"><a name="l00343"></a><span class="lineno"> 343</span>&#160; <span class="keywordtype">int</span> mat_determinant = -1; <span class="comment">// because matrix has only ints, the</span></div>
<div class="line"><a name="l00344"></a><span class="lineno"> 344</span>&#160; <span class="comment">// determinant will also be an int</span></div>
<div class="line"><a name="l00345"></a><span class="lineno"> 345</span>&#160; <span class="keywordtype">int</span> L = <a class="codeRef" target="_blank" href="http://en.cppreference.com/w/cpp/string/byte/strlen.html">std::strlen</a>(<a class="code" href="../../d6/d4e/namespaceciphers.html#ab9aec0ccf4b6809f652bb540be87c216">STRKEY</a>);</div>
<div class="line"><a name="l00346"></a><span class="lineno"> 346</span>&#160; </div>
<div class="line"><a name="l00347"></a><span class="lineno"> 347</span>&#160; <span class="keywordtype">double</span> dd;</div>
<div class="line"><a name="l00348"></a><span class="lineno"> 348</span>&#160; <span class="keywordflow">do</span> {</div>
<div class="line"><a name="l00349"></a><span class="lineno"> 349</span>&#160; <span class="comment">// keeping the random number range smaller generates better</span></div>
<div class="line"><a name="l00350"></a><span class="lineno"> 350</span>&#160; <span class="comment">// defined matrices with more ease of cracking</span></div>
<div class="line"><a name="l00351"></a><span class="lineno"> 351</span>&#160; dd = <a class="code" href="../../d6/d26/classciphers_1_1_hill_cipher.html#a629be41c1ab78850963e4ce14e1d11d9">rand_range</a>(&amp;encrypt_key, limit1, limit2);</div>
<div class="line"><a name="l00352"></a><span class="lineno"> 352</span>&#160; mat_determinant = <span class="keyword">static_cast&lt;</span><span class="keywordtype">int</span><span class="keyword">&gt;</span>(dd);</div>
<div class="line"><a name="l00353"></a><span class="lineno"> 353</span>&#160; </div>
<div class="line"><a name="l00354"></a><span class="lineno"> 354</span>&#160; <span class="keywordflow">if</span> (mat_determinant &lt; 0)</div>
<div class="line"><a name="l00355"></a><span class="lineno"> 355</span>&#160; mat_determinant = (mat_determinant % L);</div>
<div class="line"><a name="l00356"></a><span class="lineno"> 356</span>&#160; } <span class="keywordflow">while</span> (std::abs(dd) &gt; 1e3 || <span class="comment">// while ill-defined</span></div>
<div class="line"><a name="l00357"></a><span class="lineno"> 357</span>&#160; dd &lt; 0.1 || <span class="comment">// while singular or negative determinant</span></div>
<div class="line"><a name="l00358"></a><span class="lineno"> 358</span>&#160; !<a class="codeRef" target="_blank" href="http://en.cppreference.com/w/cpp/numeric/math/isfinite.html">std::isfinite</a>(dd) || <span class="comment">// while determinant is not finite</span></div>
<div class="line"><a name="l00359"></a><span class="lineno"> 359</span>&#160; <a class="code" href="../../d6/d26/classciphers_1_1_hill_cipher.html#a7760f3665651a0a37937c79c62f219c0">gcd</a>(mat_determinant, L) != 1); <span class="comment">// while no common factors</span></div>
<div class="line"><a name="l00360"></a><span class="lineno"> 360</span>&#160; <span class="comment">// std::cout &lt;&lt;</span></div>
<div class="line"><a name="l00361"></a><span class="lineno"> 361</span>&#160; </div>
<div class="line"><a name="l00362"></a><span class="lineno"> 362</span>&#160; <span class="keywordflow">return</span> encrypt_key;</div>
<div class="line"><a name="l00363"></a><span class="lineno"> 363</span>&#160; }</div>
<div class="fragment"><div class="line"><a id="l00340" name="l00340"></a><span class="lineno"> 340</span> {</div>
<div class="line"><a id="l00341" name="l00341"></a><span class="lineno"> 341</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">matrix&lt;int&gt;</a> encrypt_key(size, <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/numeric/valarray.html">std::valarray&lt;int&gt;</a>(size));</div>
<div class="line"><a id="l00342" name="l00342"></a><span class="lineno"> 342</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">matrix&lt;int&gt;</a> min_mat = encrypt_key;</div>
<div class="line"><a id="l00343" name="l00343"></a><span class="lineno"> 343</span> <span class="keywordtype">int</span> mat_determinant = -1; <span class="comment">// because matrix has only ints, the</span></div>
<div class="line"><a id="l00344" name="l00344"></a><span class="lineno"> 344</span> <span class="comment">// determinant will also be an int</span></div>
<div class="line"><a id="l00345" name="l00345"></a><span class="lineno"> 345</span> <span class="keywordtype">int</span> L = <a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/string/byte/strlen.html">std::strlen</a>(<a class="code hl_variable" href="../../d6/d4e/namespaceciphers.html#ab9aec0ccf4b6809f652bb540be87c216">STRKEY</a>);</div>
<div class="line"><a id="l00346" name="l00346"></a><span class="lineno"> 346</span> </div>
<div class="line"><a id="l00347" name="l00347"></a><span class="lineno"> 347</span> <span class="keywordtype">double</span> dd;</div>
<div class="line"><a id="l00348" name="l00348"></a><span class="lineno"> 348</span> <span class="keywordflow">do</span> {</div>
<div class="line"><a id="l00349" name="l00349"></a><span class="lineno"> 349</span> <span class="comment">// keeping the random number range smaller generates better</span></div>
<div class="line"><a id="l00350" name="l00350"></a><span class="lineno"> 350</span> <span class="comment">// defined matrices with more ease of cracking</span></div>
<div class="line"><a id="l00351" name="l00351"></a><span class="lineno"> 351</span> dd = <a class="code hl_function" href="../../d6/d26/classciphers_1_1_hill_cipher.html#a629be41c1ab78850963e4ce14e1d11d9">rand_range</a>(&amp;encrypt_key, limit1, limit2);</div>
<div class="line"><a id="l00352" name="l00352"></a><span class="lineno"> 352</span> mat_determinant = <span class="keyword">static_cast&lt;</span><span class="keywordtype">int</span><span class="keyword">&gt;</span>(dd);</div>
<div class="line"><a id="l00353" name="l00353"></a><span class="lineno"> 353</span> </div>
<div class="line"><a id="l00354" name="l00354"></a><span class="lineno"> 354</span> <span class="keywordflow">if</span> (mat_determinant &lt; 0)</div>
<div class="line"><a id="l00355" name="l00355"></a><span class="lineno"> 355</span> mat_determinant = (mat_determinant % L);</div>
<div class="line"><a id="l00356" name="l00356"></a><span class="lineno"> 356</span> } <span class="keywordflow">while</span> (std::abs(dd) &gt; 1e3 || <span class="comment">// while ill-defined</span></div>
<div class="line"><a id="l00357" name="l00357"></a><span class="lineno"> 357</span> dd &lt; 0.1 || <span class="comment">// while singular or negative determinant</span></div>
<div class="line"><a id="l00358" name="l00358"></a><span class="lineno"> 358</span> !<a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/numeric/math/isfinite.html">std::isfinite</a>(dd) || <span class="comment">// while determinant is not finite</span></div>
<div class="line"><a id="l00359" name="l00359"></a><span class="lineno"> 359</span> <a class="code hl_function" href="../../d6/d26/classciphers_1_1_hill_cipher.html#a7760f3665651a0a37937c79c62f219c0">gcd</a>(mat_determinant, L) != 1); <span class="comment">// while no common factors</span></div>
<div class="line"><a id="l00360" name="l00360"></a><span class="lineno"> 360</span> <span class="comment">// std::cout &lt;&lt;</span></div>
<div class="line"><a id="l00361" name="l00361"></a><span class="lineno"> 361</span> </div>
<div class="line"><a id="l00362" name="l00362"></a><span class="lineno"> 362</span> <span class="keywordflow">return</span> encrypt_key;</div>
<div class="line"><a id="l00363" name="l00363"></a><span class="lineno"> 363</span> }</div>
<div class="ttc" id="aclassciphers_1_1_hill_cipher_html_a629be41c1ab78850963e4ce14e1d11d9"><div class="ttname"><a href="../../d6/d26/classciphers_1_1_hill_cipher.html#a629be41c1ab78850963e4ce14e1d11d9">ciphers::HillCipher::rand_range</a></div><div class="ttdeci">static const T2 rand_range(T1 a, T1 b)</div><div class="ttdoc">Function to generate a random integer in a given interval.</div><div class="ttdef"><b>Definition:</b> hill_cipher.cpp:92</div></div>
<div class="ttc" id="aclassciphers_1_1_hill_cipher_html_a7760f3665651a0a37937c79c62f219c0"><div class="ttname"><a href="../../d6/d26/classciphers_1_1_hill_cipher.html#a7760f3665651a0a37937c79c62f219c0">ciphers::HillCipher::gcd</a></div><div class="ttdeci">static const T gcd(T a, T b)</div><div class="ttdoc">Compute GCD of two integers using Euler's algorithm.</div><div class="ttdef"><b>Definition:</b> hill_cipher.cpp:138</div></div>
<div class="ttc" id="aisfinite_html"><div class="ttname"><a href="http://en.cppreference.com/w/cpp/numeric/math/isfinite.html">std::isfinite</a></div><div class="ttdeci">T isfinite(T... args)</div></div>
</div><!-- fragment -->
</div>
</div>
<a id="a14bfcd14af6cd853130cbacd32e35c13"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a14bfcd14af6cd853130cbacd32e35c13">&#9670;&nbsp;</a></span>generate_keys()</h2>
<a id="a405b0a28d66a61239d3565d5256f9cb5" name="a405b0a28d66a61239d3565d5256f9cb5"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a405b0a28d66a61239d3565d5256f9cb5">&#9670;&nbsp;</a></span>generate_keys()</h2>
<div class="memitem">
<div class="memproto">
@@ -601,7 +599,7 @@ Here is the call graph for this function:</div>
<td class="mlabels-left">
<table class="memname">
<tr>
<td class="memname">static <a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/utility/pair.html">std::pair</a>&lt;<a class="el" href="../../d1/dbe/lu__decomposition_8h.html#aed8766713ee9b561a4acdcdff5f90ea5">matrix</a>&lt;int&gt;, <a class="el" href="../../d1/dbe/lu__decomposition_8h.html#aed8766713ee9b561a4acdcdff5f90ea5">matrix</a>&lt;int&gt; &gt; ciphers::HillCipher::generate_keys </td>
<td class="memname">static <a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/utility/pair.html">std::pair</a>&lt; <a class="el" href="../../d1/dbe/lu__decomposition_8h.html#aed8766713ee9b561a4acdcdff5f90ea5">matrix</a>&lt; int &gt;, <a class="el" href="../../d1/dbe/lu__decomposition_8h.html#aed8766713ee9b561a4acdcdff5f90ea5">matrix</a>&lt; int &gt; &gt; ciphers::HillCipher::generate_keys </td>
<td>(</td>
<td class="paramtype">size_t&#160;</td>
<td class="paramname"><em>size</em>, </td>
@@ -642,24 +640,24 @@ Here is the call graph for this function:</div>
</dl>
<dl class="section return"><dt>Returns</dt><dd><a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/utility/pair.html">std::pair</a>&lt;matrix&lt;int&gt;, matrix&lt;int&gt;&gt; encryption and decryption keys as a pair</dd></dl>
<dl class="section see"><dt>See also</dt><dd>::generate_encryption_key </dd></dl>
<div class="fragment"><div class="line"><a name="l00426"></a><span class="lineno"> 426</span>&#160; {</div>
<div class="line"><a name="l00427"></a><span class="lineno"> 427</span>&#160; <a class="codeRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">matrix&lt;int&gt;</a> encrypt_key = <a class="code" href="../../d6/d26/classciphers_1_1_hill_cipher.html#a7ca10cd1a0e8e3732391e0427d2d0213">generate_encryption_key</a>(size);</div>
<div class="line"><a name="l00428"></a><span class="lineno"> 428</span>&#160; <a class="codeRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">matrix&lt;int&gt;</a> decrypt_key = <a class="code" href="../../d6/d26/classciphers_1_1_hill_cipher.html#abb2c4dc2b8a59d3dfe0fa22c2adc086b">generate_decryption_key</a>(encrypt_key);</div>
<div class="line"><a name="l00429"></a><span class="lineno"> 429</span>&#160; <span class="keywordtype">double</span> det2 = <a class="code" href="../../d1/dbe/lu__decomposition_8h.html#a3108d43bd32c6fb3b3c158476c51ba7f">determinant_lu</a>(decrypt_key);</div>
<div class="line"><a name="l00430"></a><span class="lineno"> 430</span>&#160; <span class="keywordflow">while</span> (std::abs(det2) &lt; 0.1 || std::abs(det2) &gt; 1e3) {</div>
<div class="line"><a name="l00431"></a><span class="lineno"> 431</span>&#160; encrypt_key = <a class="code" href="../../d6/d26/classciphers_1_1_hill_cipher.html#a7ca10cd1a0e8e3732391e0427d2d0213">generate_encryption_key</a>(size, limit1, limit2);</div>
<div class="line"><a name="l00432"></a><span class="lineno"> 432</span>&#160; decrypt_key = <a class="code" href="../../d6/d26/classciphers_1_1_hill_cipher.html#abb2c4dc2b8a59d3dfe0fa22c2adc086b">generate_decryption_key</a>(encrypt_key);</div>
<div class="line"><a name="l00433"></a><span class="lineno"> 433</span>&#160; det2 = <a class="code" href="../../d1/dbe/lu__decomposition_8h.html#a3108d43bd32c6fb3b3c158476c51ba7f">determinant_lu</a>(decrypt_key);</div>
<div class="line"><a name="l00434"></a><span class="lineno"> 434</span>&#160; }</div>
<div class="line"><a name="l00435"></a><span class="lineno"> 435</span>&#160; <span class="keywordflow">return</span> <a class="codeRef" target="_blank" href="http://en.cppreference.com/w/cpp/utility/pair/make_pair.html">std::make_pair</a>(encrypt_key, decrypt_key);</div>
<div class="line"><a name="l00436"></a><span class="lineno"> 436</span>&#160; }</div>
<div class="ttc" id="aclassciphers_1_1_hill_cipher_html_a7ca10cd1a0e8e3732391e0427d2d0213"><div class="ttname"><a href="../../d6/d26/classciphers_1_1_hill_cipher.html#a7ca10cd1a0e8e3732391e0427d2d0213">ciphers::HillCipher::generate_encryption_key</a></div><div class="ttdeci">static matrix&lt; int &gt; generate_encryption_key(size_t size, int limit1=0, int limit2=10)</div><div class="ttdoc">Generate encryption matrix of a given size. Larger size matrices are difficult to generate but provid...</div><div class="ttdef"><b>Definition:</b> hill_cipher.cpp:339</div></div>
<div class="ttc" id="aclassciphers_1_1_hill_cipher_html_abb2c4dc2b8a59d3dfe0fa22c2adc086b"><div class="ttname"><a href="../../d6/d26/classciphers_1_1_hill_cipher.html#abb2c4dc2b8a59d3dfe0fa22c2adc086b">ciphers::HillCipher::generate_decryption_key</a></div><div class="ttdeci">static matrix&lt; int &gt; generate_decryption_key(matrix&lt; int &gt; const &amp;encrypt_key)</div><div class="ttdoc">Generate decryption matrix from an encryption matrix key.</div><div class="ttdef"><b>Definition:</b> hill_cipher.cpp:371</div></div>
<div class="fragment"><div class="line"><a id="l00426" name="l00426"></a><span class="lineno"> 426</span> {</div>
<div class="line"><a id="l00427" name="l00427"></a><span class="lineno"> 427</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">matrix&lt;int&gt;</a> encrypt_key = <a class="code hl_function" href="../../d6/d26/classciphers_1_1_hill_cipher.html#a642f70fb54cb50b00fb6df7c3f2b120e">generate_encryption_key</a>(size);</div>
<div class="line"><a id="l00428" name="l00428"></a><span class="lineno"> 428</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">matrix&lt;int&gt;</a> decrypt_key = <a class="code hl_function" href="../../d6/d26/classciphers_1_1_hill_cipher.html#ab02c7563889bf1e363deb8e21967b706">generate_decryption_key</a>(encrypt_key);</div>
<div class="line"><a id="l00429" name="l00429"></a><span class="lineno"> 429</span> <span class="keywordtype">double</span> det2 = <a class="code hl_function" href="../../d1/dbe/lu__decomposition_8h.html#a3108d43bd32c6fb3b3c158476c51ba7f">determinant_lu</a>(decrypt_key);</div>
<div class="line"><a id="l00430" name="l00430"></a><span class="lineno"> 430</span> <span class="keywordflow">while</span> (std::abs(det2) &lt; 0.1 || std::abs(det2) &gt; 1e3) {</div>
<div class="line"><a id="l00431" name="l00431"></a><span class="lineno"> 431</span> encrypt_key = <a class="code hl_function" href="../../d6/d26/classciphers_1_1_hill_cipher.html#a642f70fb54cb50b00fb6df7c3f2b120e">generate_encryption_key</a>(size, limit1, limit2);</div>
<div class="line"><a id="l00432" name="l00432"></a><span class="lineno"> 432</span> decrypt_key = <a class="code hl_function" href="../../d6/d26/classciphers_1_1_hill_cipher.html#ab02c7563889bf1e363deb8e21967b706">generate_decryption_key</a>(encrypt_key);</div>
<div class="line"><a id="l00433" name="l00433"></a><span class="lineno"> 433</span> det2 = <a class="code hl_function" href="../../d1/dbe/lu__decomposition_8h.html#a3108d43bd32c6fb3b3c158476c51ba7f">determinant_lu</a>(decrypt_key);</div>
<div class="line"><a id="l00434" name="l00434"></a><span class="lineno"> 434</span> }</div>
<div class="line"><a id="l00435" name="l00435"></a><span class="lineno"> 435</span> <span class="keywordflow">return</span> <a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/utility/pair/make_pair.html">std::make_pair</a>(encrypt_key, decrypt_key);</div>
<div class="line"><a id="l00436" name="l00436"></a><span class="lineno"> 436</span> }</div>
<div class="ttc" id="aclassciphers_1_1_hill_cipher_html_a642f70fb54cb50b00fb6df7c3f2b120e"><div class="ttname"><a href="../../d6/d26/classciphers_1_1_hill_cipher.html#a642f70fb54cb50b00fb6df7c3f2b120e">ciphers::HillCipher::generate_encryption_key</a></div><div class="ttdeci">static matrix&lt; int &gt; generate_encryption_key(size_t size, int limit1=0, int limit2=10)</div><div class="ttdoc">Generate encryption matrix of a given size. Larger size matrices are difficult to generate but provid...</div><div class="ttdef"><b>Definition:</b> hill_cipher.cpp:339</div></div>
<div class="ttc" id="aclassciphers_1_1_hill_cipher_html_ab02c7563889bf1e363deb8e21967b706"><div class="ttname"><a href="../../d6/d26/classciphers_1_1_hill_cipher.html#ab02c7563889bf1e363deb8e21967b706">ciphers::HillCipher::generate_decryption_key</a></div><div class="ttdeci">static matrix&lt; int &gt; generate_decryption_key(matrix&lt; int &gt; const &amp;encrypt_key)</div><div class="ttdoc">Generate decryption matrix from an encryption matrix key.</div><div class="ttdef"><b>Definition:</b> hill_cipher.cpp:371</div></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><!-- fragment -->
</div>
</div>
<a id="ae77cad522fa44b8c985779a7188d2f41"></a>
<a id="ae77cad522fa44b8c985779a7188d2f41" name="ae77cad522fa44b8c985779a7188d2f41"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ae77cad522fa44b8c985779a7188d2f41">&#9670;&nbsp;</a></span>get_char_idx()</h2>
<div class="memitem">
@@ -691,17 +689,17 @@ Here is the call graph for this function:</div>
</dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>index of character </dd></dl>
<div class="fragment"><div class="line"><a name="l00190"></a><span class="lineno"> 190</span>&#160; {</div>
<div class="line"><a name="l00191"></a><span class="lineno"> 191</span>&#160; <span class="keywordtype">size_t</span> L = <a class="codeRef" target="_blank" href="http://en.cppreference.com/w/cpp/string/byte/strlen.html">std::strlen</a>(<a class="code" href="../../d6/d4e/namespaceciphers.html#ab9aec0ccf4b6809f652bb540be87c216">STRKEY</a>);</div>
<div class="line"><a name="l00192"></a><span class="lineno"> 192</span>&#160; </div>
<div class="line"><a name="l00193"></a><span class="lineno"> 193</span>&#160; <span class="keywordflow">for</span> (<span class="keywordtype">size_t</span> idx = 0; idx &lt;= L; idx++)</div>
<div class="line"><a name="l00194"></a><span class="lineno"> 194</span>&#160; <span class="keywordflow">if</span> (<a class="code" href="../../d6/d4e/namespaceciphers.html#ab9aec0ccf4b6809f652bb540be87c216">STRKEY</a>[idx] == ch)</div>
<div class="line"><a name="l00195"></a><span class="lineno"> 195</span>&#160; <span class="keywordflow">return</span> idx;</div>
<div class="line"><a name="l00196"></a><span class="lineno"> 196</span>&#160; </div>
<div class="line"><a name="l00197"></a><span class="lineno"> 197</span>&#160; <a class="codeRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/basic_ostream.html">std::cerr</a> &lt;&lt; __func__ &lt;&lt; <span class="stringliteral">&quot;:&quot;</span> &lt;&lt; __LINE__ &lt;&lt; <span class="stringliteral">&quot;: (&quot;</span> &lt;&lt; ch</div>
<div class="line"><a name="l00198"></a><span class="lineno"> 198</span>&#160; &lt;&lt; <span class="stringliteral">&quot;) Should not reach here!\n&quot;</span>;</div>
<div class="line"><a name="l00199"></a><span class="lineno"> 199</span>&#160; <span class="keywordflow">return</span> 0;</div>
<div class="line"><a name="l00200"></a><span class="lineno"> 200</span>&#160; }</div>
<div class="fragment"><div class="line"><a id="l00190" name="l00190"></a><span class="lineno"> 190</span> {</div>
<div class="line"><a id="l00191" name="l00191"></a><span class="lineno"> 191</span> <span class="keywordtype">size_t</span> L = <a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/string/byte/strlen.html">std::strlen</a>(<a class="code hl_variable" href="../../d6/d4e/namespaceciphers.html#ab9aec0ccf4b6809f652bb540be87c216">STRKEY</a>);</div>
<div class="line"><a id="l00192" name="l00192"></a><span class="lineno"> 192</span> </div>
<div class="line"><a id="l00193" name="l00193"></a><span class="lineno"> 193</span> <span class="keywordflow">for</span> (<span class="keywordtype">size_t</span> idx = 0; idx &lt;= L; idx++)</div>
<div class="line"><a id="l00194" name="l00194"></a><span class="lineno"> 194</span> <span class="keywordflow">if</span> (<a class="code hl_variable" href="../../d6/d4e/namespaceciphers.html#ab9aec0ccf4b6809f652bb540be87c216">STRKEY</a>[idx] == ch)</div>
<div class="line"><a id="l00195" name="l00195"></a><span class="lineno"> 195</span> <span class="keywordflow">return</span> idx;</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::cerr</a> &lt;&lt; __func__ &lt;&lt; <span class="stringliteral">&quot;:&quot;</span> &lt;&lt; __LINE__ &lt;&lt; <span class="stringliteral">&quot;: (&quot;</span> &lt;&lt; ch</div>
<div class="line"><a id="l00198" name="l00198"></a><span class="lineno"> 198</span> &lt;&lt; <span class="stringliteral">&quot;) Should not reach here!\n&quot;</span>;</div>
<div class="line"><a id="l00199" name="l00199"></a><span class="lineno"> 199</span> <span class="keywordflow">return</span> 0;</div>
<div class="line"><a id="l00200" name="l00200"></a><span class="lineno"> 200</span> }</div>
</div><!-- fragment --><div class="dynheader">
Here is the call graph for this function:</div>
<div class="dyncontent">
@@ -711,7 +709,7 @@ Here is the call graph for this function:</div>
</div>
</div>
<a id="a12f727cca9e21f9539cd74b6603adf0c"></a>
<a id="a12f727cca9e21f9539cd74b6603adf0c" name="a12f727cca9e21f9539cd74b6603adf0c"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a12f727cca9e21f9539cd74b6603adf0c">&#9670;&nbsp;</a></span>get_idx_char()</h2>
<div class="memitem">
@@ -743,12 +741,12 @@ Here is the call graph for this function:</div>
</dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>character at the index </dd></dl>
<div class="fragment"><div class="line"><a name="l00182"></a><span class="lineno"> 182</span>&#160;{ <span class="keywordflow">return</span> <a class="code" href="../../d6/d4e/namespaceciphers.html#ab9aec0ccf4b6809f652bb540be87c216">STRKEY</a>[idx]; }</div>
<div class="fragment"><div class="line"><a id="l00182" name="l00182"></a><span class="lineno"> 182</span>{ <span class="keywordflow">return</span> <a class="code hl_variable" href="../../d6/d4e/namespaceciphers.html#ab9aec0ccf4b6809f652bb540be87c216">STRKEY</a>[idx]; }</div>
</div><!-- fragment -->
</div>
</div>
<a id="a5a4cdbd4d4dad9efe2ed309bd466dd4b"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a5a4cdbd4d4dad9efe2ed309bd466dd4b">&#9670;&nbsp;</a></span>get_inverse()</h2>
<a id="a2eb58750b978a93ac5e6eb29e3e570b7" name="a2eb58750b978a93ac5e6eb29e3e570b7"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a2eb58750b978a93ac5e6eb29e3e570b7">&#9670;&nbsp;</a></span>get_inverse()</h2>
<div class="memitem">
<div class="memproto">
@@ -759,7 +757,7 @@ template&lt;typename T &gt; </div>
<td class="mlabels-left">
<table class="memname">
<tr>
<td class="memname">static <a class="el" href="../../d1/dbe/lu__decomposition_8h.html#aed8766713ee9b561a4acdcdff5f90ea5">matrix</a>&lt;double&gt; ciphers::HillCipher::get_inverse </td>
<td class="memname">static <a class="el" href="../../d1/dbe/lu__decomposition_8h.html#aed8766713ee9b561a4acdcdff5f90ea5">matrix</a>&lt; double &gt; ciphers::HillCipher::get_inverse </td>
<td>(</td>
<td class="paramtype"><a class="el" href="../../d1/dbe/lu__decomposition_8h.html#aed8766713ee9b561a4acdcdff5f90ea5">matrix</a>&lt; T &gt; const &amp;&#160;</td>
<td class="paramname"><em>A</em></td><td>)</td>
@@ -772,83 +770,83 @@ template&lt;typename T &gt; </div>
</tr>
</table>
</div><div class="memdoc">
<p>Get matrix inverse using Row-transformations. Given matrix must be a square and non-singular. </p><dl class="section return"><dt>Returns</dt><dd>inverse matrix </dd></dl>
<div class="fragment"><div class="line"><a name="l00250"></a><span class="lineno"> 250</span>&#160; {</div>
<div class="line"><a name="l00251"></a><span class="lineno"> 251</span>&#160; <span class="comment">// Assuming A is square matrix</span></div>
<div class="line"><a name="l00252"></a><span class="lineno"> 252</span>&#160; <span class="keywordtype">size_t</span> <a class="code" href="../../d6/d42/data__structures_2sparse__table_8cpp.html#a10f3ffb3f6f7e1b83d556b9c8de89a5d">N</a> = A.<a class="codeRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector/size.html">size</a>();</div>
<div class="line"><a name="l00253"></a><span class="lineno"> 253</span>&#160; </div>
<div class="line"><a name="l00254"></a><span class="lineno"> 254</span>&#160; <a class="codeRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">matrix&lt;double&gt;</a> inverse(N, <a class="codeRef" target="_blank" href="http://en.cppreference.com/w/cpp/numeric/valarray.html">std::valarray&lt;double&gt;</a>(N));</div>
<div class="line"><a name="l00255"></a><span class="lineno"> 255</span>&#160; <span class="keywordflow">for</span> (<span class="keywordtype">size_t</span> row = 0; row &lt; <a class="code" href="../../d6/d42/data__structures_2sparse__table_8cpp.html#a10f3ffb3f6f7e1b83d556b9c8de89a5d">N</a>; row++) {</div>
<div class="line"><a name="l00256"></a><span class="lineno"> 256</span>&#160; <span class="keywordflow">for</span> (<span class="keywordtype">size_t</span> col = 0; col &lt; <a class="code" href="../../d6/d42/data__structures_2sparse__table_8cpp.html#a10f3ffb3f6f7e1b83d556b9c8de89a5d">N</a>; col++) {</div>
<div class="line"><a name="l00257"></a><span class="lineno"> 257</span>&#160; <span class="comment">// create identity matrix</span></div>
<div class="line"><a name="l00258"></a><span class="lineno"> 258</span>&#160; inverse[row][col] = (row == col) ? 1.f : 0.f;</div>
<div class="line"><a name="l00259"></a><span class="lineno"> 259</span>&#160; }</div>
<div class="line"><a name="l00260"></a><span class="lineno"> 260</span>&#160; }</div>
<div class="line"><a name="l00261"></a><span class="lineno"> 261</span>&#160; </div>
<div class="line"><a name="l00262"></a><span class="lineno"> 262</span>&#160; <span class="keywordflow">if</span> (A.<a class="codeRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector/size.html">size</a>() != A[0].<a class="codeRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector/size.html">size</a>()) {</div>
<div class="line"><a name="l00263"></a><span class="lineno"> 263</span>&#160; <a class="codeRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/basic_ostream.html">std::cerr</a> &lt;&lt; <span class="stringliteral">&quot;A must be a square matrix!&quot;</span> &lt;&lt; <a class="codeRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/manip/endl.html">std::endl</a>;</div>
<div class="line"><a name="l00264"></a><span class="lineno"> 264</span>&#160; <span class="keywordflow">return</span> inverse;</div>
<div class="line"><a name="l00265"></a><span class="lineno"> 265</span>&#160; }</div>
<div class="line"><a name="l00266"></a><span class="lineno"> 266</span>&#160; </div>
<div class="line"><a name="l00267"></a><span class="lineno"> 267</span>&#160; <span class="comment">// preallocate a temporary matrix identical to A</span></div>
<div class="line"><a name="l00268"></a><span class="lineno"> 268</span>&#160; <a class="codeRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">matrix&lt;double&gt;</a> temp(N, <a class="codeRef" target="_blank" href="http://en.cppreference.com/w/cpp/numeric/valarray.html">std::valarray&lt;double&gt;</a>(N));</div>
<div class="line"><a name="l00269"></a><span class="lineno"> 269</span>&#160; <span class="keywordflow">for</span> (<span class="keywordtype">size_t</span> row = 0; row &lt; <a class="code" href="../../d6/d42/data__structures_2sparse__table_8cpp.html#a10f3ffb3f6f7e1b83d556b9c8de89a5d">N</a>; row++) {</div>
<div class="line"><a name="l00270"></a><span class="lineno"> 270</span>&#160; <span class="keywordflow">for</span> (<span class="keywordtype">size_t</span> col = 0; col &lt; <a class="code" href="../../d6/d42/data__structures_2sparse__table_8cpp.html#a10f3ffb3f6f7e1b83d556b9c8de89a5d">N</a>; col++)</div>
<div class="line"><a name="l00271"></a><span class="lineno"> 271</span>&#160; temp[row][col] = <span class="keyword">static_cast&lt;</span><span class="keywordtype">double</span><span class="keyword">&gt;</span>(A[row][col]);</div>
<div class="line"><a name="l00272"></a><span class="lineno"> 272</span>&#160; }</div>
<div class="line"><a name="l00273"></a><span class="lineno"> 273</span>&#160; </div>
<div class="line"><a name="l00274"></a><span class="lineno"> 274</span>&#160; <span class="comment">// start transformations</span></div>
<div class="line"><a name="l00275"></a><span class="lineno"> 275</span>&#160; <span class="keywordflow">for</span> (<span class="keywordtype">size_t</span> row = 0; row &lt; <a class="code" href="../../d6/d42/data__structures_2sparse__table_8cpp.html#a10f3ffb3f6f7e1b83d556b9c8de89a5d">N</a>; row++) {</div>
<div class="line"><a name="l00276"></a><span class="lineno"> 276</span>&#160; <span class="keywordflow">for</span> (<span class="keywordtype">size_t</span> row2 = row; row2 &lt; <a class="code" href="../../d6/d42/data__structures_2sparse__table_8cpp.html#a10f3ffb3f6f7e1b83d556b9c8de89a5d">N</a> &amp;&amp; temp[row][row] == 0; row2++) {</div>
<div class="line"><a name="l00277"></a><span class="lineno"> 277</span>&#160; <span class="comment">// this to ensure diagonal elements are not 0</span></div>
<div class="line"><a name="l00278"></a><span class="lineno"> 278</span>&#160; temp[row] = temp[row] + temp[row2];</div>
<div class="line"><a name="l00279"></a><span class="lineno"> 279</span>&#160; inverse[row] = inverse[row] + inverse[row2];</div>
<div class="line"><a name="l00280"></a><span class="lineno"> 280</span>&#160; }</div>
<div class="line"><a name="l00281"></a><span class="lineno"> 281</span>&#160; </div>
<div class="line"><a name="l00282"></a><span class="lineno"> 282</span>&#160; <span class="keywordflow">for</span> (<span class="keywordtype">size_t</span> col2 = row; col2 &lt; <a class="code" href="../../d6/d42/data__structures_2sparse__table_8cpp.html#a10f3ffb3f6f7e1b83d556b9c8de89a5d">N</a> &amp;&amp; temp[row][row] == 0; col2++) {</div>
<div class="line"><a name="l00283"></a><span class="lineno"> 283</span>&#160; <span class="comment">// this to further ensure diagonal elements are not 0</span></div>
<div class="line"><a name="l00284"></a><span class="lineno"> 284</span>&#160; <span class="keywordflow">for</span> (<span class="keywordtype">size_t</span> row2 = 0; row2 &lt; <a class="code" href="../../d6/d42/data__structures_2sparse__table_8cpp.html#a10f3ffb3f6f7e1b83d556b9c8de89a5d">N</a>; row2++) {</div>
<div class="line"><a name="l00285"></a><span class="lineno"> 285</span>&#160; temp[row2][row] = temp[row2][row] + temp[row2][col2];</div>
<div class="line"><a name="l00286"></a><span class="lineno"> 286</span>&#160; inverse[row2][row] =</div>
<div class="line"><a name="l00287"></a><span class="lineno"> 287</span>&#160; inverse[row2][row] + inverse[row2][col2];</div>
<div class="line"><a name="l00288"></a><span class="lineno"> 288</span>&#160; }</div>
<div class="line"><a name="l00289"></a><span class="lineno"> 289</span>&#160; }</div>
<div class="line"><a name="l00290"></a><span class="lineno"> 290</span>&#160; </div>
<div class="line"><a name="l00291"></a><span class="lineno"> 291</span>&#160; <span class="keywordflow">if</span> (temp[row][row] == 0) {</div>
<div class="line"><a name="l00292"></a><span class="lineno"> 292</span>&#160; <span class="comment">// Probably a low-rank matrix and hence singular</span></div>
<div class="line"><a name="l00293"></a><span class="lineno"> 293</span>&#160; <a class="codeRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/basic_ostream.html">std::cerr</a> &lt;&lt; <span class="stringliteral">&quot;Low-rank matrix, no inverse!&quot;</span> &lt;&lt; <a class="codeRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/manip/endl.html">std::endl</a>;</div>
<div class="line"><a name="l00294"></a><span class="lineno"> 294</span>&#160; <span class="keywordflow">return</span> inverse;</div>
<div class="line"><a name="l00295"></a><span class="lineno"> 295</span>&#160; }</div>
<div class="line"><a name="l00296"></a><span class="lineno"> 296</span>&#160; </div>
<div class="line"><a name="l00297"></a><span class="lineno"> 297</span>&#160; <span class="comment">// set diagonal to 1</span></div>
<div class="line"><a name="l00298"></a><span class="lineno"> 298</span>&#160; <span class="keywordtype">double</span> divisor = temp[row][row];</div>
<div class="line"><a name="l00299"></a><span class="lineno"> 299</span>&#160; temp[row] = temp[row] / divisor;</div>
<div class="line"><a name="l00300"></a><span class="lineno"> 300</span>&#160; inverse[row] = inverse[row] / divisor;</div>
<div class="line"><a name="l00301"></a><span class="lineno"> 301</span>&#160; <span class="comment">// Row transformations</span></div>
<div class="line"><a name="l00302"></a><span class="lineno"> 302</span>&#160; <span class="keywordflow">for</span> (<span class="keywordtype">size_t</span> row2 = 0; row2 &lt; <a class="code" href="../../d6/d42/data__structures_2sparse__table_8cpp.html#a10f3ffb3f6f7e1b83d556b9c8de89a5d">N</a>; row2++) {</div>
<div class="line"><a name="l00303"></a><span class="lineno"> 303</span>&#160; <span class="keywordflow">if</span> (row2 == row)</div>
<div class="line"><a name="l00304"></a><span class="lineno"> 304</span>&#160; <span class="keywordflow">continue</span>;</div>
<div class="line"><a name="l00305"></a><span class="lineno"> 305</span>&#160; <span class="keywordtype">double</span> factor = temp[row2][row];</div>
<div class="line"><a name="l00306"></a><span class="lineno"> 306</span>&#160; temp[row2] = temp[row2] - factor * temp[row];</div>
<div class="line"><a name="l00307"></a><span class="lineno"> 307</span>&#160; inverse[row2] = inverse[row2] - factor * inverse[row];</div>
<div class="line"><a name="l00308"></a><span class="lineno"> 308</span>&#160; }</div>
<div class="line"><a name="l00309"></a><span class="lineno"> 309</span>&#160; }</div>
<div class="line"><a name="l00310"></a><span class="lineno"> 310</span>&#160; </div>
<div class="line"><a name="l00311"></a><span class="lineno"> 311</span>&#160; <span class="keywordflow">return</span> inverse;</div>
<div class="line"><a name="l00312"></a><span class="lineno"> 312</span>&#160; }</div>
<p >Get matrix inverse using Row-transformations. Given matrix must be a square and non-singular. </p><dl class="section return"><dt>Returns</dt><dd>inverse matrix </dd></dl>
<div class="fragment"><div class="line"><a id="l00250" name="l00250"></a><span class="lineno"> 250</span> {</div>
<div class="line"><a id="l00251" name="l00251"></a><span class="lineno"> 251</span> <span class="comment">// Assuming A is square matrix</span></div>
<div class="line"><a id="l00252" name="l00252"></a><span class="lineno"> 252</span> <span class="keywordtype">size_t</span> <a class="code hl_variable" href="../../d6/d42/data__structures_2sparse__table_8cpp.html#a10f3ffb3f6f7e1b83d556b9c8de89a5d">N</a> = A.<a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector/size.html">size</a>();</div>
<div class="line"><a id="l00253" name="l00253"></a><span class="lineno"> 253</span> </div>
<div class="line"><a id="l00254" name="l00254"></a><span class="lineno"> 254</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">matrix&lt;double&gt;</a> inverse(N, <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/numeric/valarray.html">std::valarray&lt;double&gt;</a>(N));</div>
<div class="line"><a id="l00255" name="l00255"></a><span class="lineno"> 255</span> <span class="keywordflow">for</span> (<span class="keywordtype">size_t</span> row = 0; row &lt; <a class="code hl_variable" href="../../d6/d42/data__structures_2sparse__table_8cpp.html#a10f3ffb3f6f7e1b83d556b9c8de89a5d">N</a>; row++) {</div>
<div class="line"><a id="l00256" name="l00256"></a><span class="lineno"> 256</span> <span class="keywordflow">for</span> (<span class="keywordtype">size_t</span> col = 0; col &lt; <a class="code hl_variable" href="../../d6/d42/data__structures_2sparse__table_8cpp.html#a10f3ffb3f6f7e1b83d556b9c8de89a5d">N</a>; col++) {</div>
<div class="line"><a id="l00257" name="l00257"></a><span class="lineno"> 257</span> <span class="comment">// create identity matrix</span></div>
<div class="line"><a id="l00258" name="l00258"></a><span class="lineno"> 258</span> inverse[row][col] = (row == col) ? 1.f : 0.f;</div>
<div class="line"><a id="l00259" name="l00259"></a><span class="lineno"> 259</span> }</div>
<div class="line"><a id="l00260" name="l00260"></a><span class="lineno"> 260</span> }</div>
<div class="line"><a id="l00261" name="l00261"></a><span class="lineno"> 261</span> </div>
<div class="line"><a id="l00262" name="l00262"></a><span class="lineno"> 262</span> <span class="keywordflow">if</span> (A.<a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector/size.html">size</a>() != A[0].<a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector/size.html">size</a>()) {</div>
<div class="line"><a id="l00263" name="l00263"></a><span class="lineno"> 263</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;A must be a square matrix!&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="l00264" name="l00264"></a><span class="lineno"> 264</span> <span class="keywordflow">return</span> inverse;</div>
<div class="line"><a id="l00265" name="l00265"></a><span class="lineno"> 265</span> }</div>
<div class="line"><a id="l00266" name="l00266"></a><span class="lineno"> 266</span> </div>
<div class="line"><a id="l00267" name="l00267"></a><span class="lineno"> 267</span> <span class="comment">// preallocate a temporary matrix identical to A</span></div>
<div class="line"><a id="l00268" name="l00268"></a><span class="lineno"> 268</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">matrix&lt;double&gt;</a> temp(N, <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/numeric/valarray.html">std::valarray&lt;double&gt;</a>(N));</div>
<div class="line"><a id="l00269" name="l00269"></a><span class="lineno"> 269</span> <span class="keywordflow">for</span> (<span class="keywordtype">size_t</span> row = 0; row &lt; <a class="code hl_variable" href="../../d6/d42/data__structures_2sparse__table_8cpp.html#a10f3ffb3f6f7e1b83d556b9c8de89a5d">N</a>; row++) {</div>
<div class="line"><a id="l00270" name="l00270"></a><span class="lineno"> 270</span> <span class="keywordflow">for</span> (<span class="keywordtype">size_t</span> col = 0; col &lt; <a class="code hl_variable" href="../../d6/d42/data__structures_2sparse__table_8cpp.html#a10f3ffb3f6f7e1b83d556b9c8de89a5d">N</a>; col++)</div>
<div class="line"><a id="l00271" name="l00271"></a><span class="lineno"> 271</span> temp[row][col] = <span class="keyword">static_cast&lt;</span><span class="keywordtype">double</span><span class="keyword">&gt;</span>(A[row][col]);</div>
<div class="line"><a id="l00272" name="l00272"></a><span class="lineno"> 272</span> }</div>
<div class="line"><a id="l00273" name="l00273"></a><span class="lineno"> 273</span> </div>
<div class="line"><a id="l00274" name="l00274"></a><span class="lineno"> 274</span> <span class="comment">// start transformations</span></div>
<div class="line"><a id="l00275" name="l00275"></a><span class="lineno"> 275</span> <span class="keywordflow">for</span> (<span class="keywordtype">size_t</span> row = 0; row &lt; <a class="code hl_variable" href="../../d6/d42/data__structures_2sparse__table_8cpp.html#a10f3ffb3f6f7e1b83d556b9c8de89a5d">N</a>; row++) {</div>
<div class="line"><a id="l00276" name="l00276"></a><span class="lineno"> 276</span> <span class="keywordflow">for</span> (<span class="keywordtype">size_t</span> row2 = row; row2 &lt; <a class="code hl_variable" href="../../d6/d42/data__structures_2sparse__table_8cpp.html#a10f3ffb3f6f7e1b83d556b9c8de89a5d">N</a> &amp;&amp; temp[row][row] == 0; row2++) {</div>
<div class="line"><a id="l00277" name="l00277"></a><span class="lineno"> 277</span> <span class="comment">// this to ensure diagonal elements are not 0</span></div>
<div class="line"><a id="l00278" name="l00278"></a><span class="lineno"> 278</span> temp[row] = temp[row] + temp[row2];</div>
<div class="line"><a id="l00279" name="l00279"></a><span class="lineno"> 279</span> inverse[row] = inverse[row] + inverse[row2];</div>
<div class="line"><a id="l00280" name="l00280"></a><span class="lineno"> 280</span> }</div>
<div class="line"><a id="l00281" name="l00281"></a><span class="lineno"> 281</span> </div>
<div class="line"><a id="l00282" name="l00282"></a><span class="lineno"> 282</span> <span class="keywordflow">for</span> (<span class="keywordtype">size_t</span> col2 = row; col2 &lt; <a class="code hl_variable" href="../../d6/d42/data__structures_2sparse__table_8cpp.html#a10f3ffb3f6f7e1b83d556b9c8de89a5d">N</a> &amp;&amp; temp[row][row] == 0; col2++) {</div>
<div class="line"><a id="l00283" name="l00283"></a><span class="lineno"> 283</span> <span class="comment">// this to further ensure diagonal elements are not 0</span></div>
<div class="line"><a id="l00284" name="l00284"></a><span class="lineno"> 284</span> <span class="keywordflow">for</span> (<span class="keywordtype">size_t</span> row2 = 0; row2 &lt; <a class="code hl_variable" href="../../d6/d42/data__structures_2sparse__table_8cpp.html#a10f3ffb3f6f7e1b83d556b9c8de89a5d">N</a>; row2++) {</div>
<div class="line"><a id="l00285" name="l00285"></a><span class="lineno"> 285</span> temp[row2][row] = temp[row2][row] + temp[row2][col2];</div>
<div class="line"><a id="l00286" name="l00286"></a><span class="lineno"> 286</span> inverse[row2][row] =</div>
<div class="line"><a id="l00287" name="l00287"></a><span class="lineno"> 287</span> inverse[row2][row] + inverse[row2][col2];</div>
<div class="line"><a id="l00288" name="l00288"></a><span class="lineno"> 288</span> }</div>
<div class="line"><a id="l00289" name="l00289"></a><span class="lineno"> 289</span> }</div>
<div class="line"><a id="l00290" name="l00290"></a><span class="lineno"> 290</span> </div>
<div class="line"><a id="l00291" name="l00291"></a><span class="lineno"> 291</span> <span class="keywordflow">if</span> (temp[row][row] == 0) {</div>
<div class="line"><a id="l00292" name="l00292"></a><span class="lineno"> 292</span> <span class="comment">// Probably a low-rank matrix and hence singular</span></div>
<div class="line"><a id="l00293" name="l00293"></a><span class="lineno"> 293</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;Low-rank matrix, no inverse!&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="l00294" name="l00294"></a><span class="lineno"> 294</span> <span class="keywordflow">return</span> inverse;</div>
<div class="line"><a id="l00295" name="l00295"></a><span class="lineno"> 295</span> }</div>
<div class="line"><a id="l00296" name="l00296"></a><span class="lineno"> 296</span> </div>
<div class="line"><a id="l00297" name="l00297"></a><span class="lineno"> 297</span> <span class="comment">// set diagonal to 1</span></div>
<div class="line"><a id="l00298" name="l00298"></a><span class="lineno"> 298</span> <span class="keywordtype">double</span> divisor = temp[row][row];</div>
<div class="line"><a id="l00299" name="l00299"></a><span class="lineno"> 299</span> temp[row] = temp[row] / divisor;</div>
<div class="line"><a id="l00300" name="l00300"></a><span class="lineno"> 300</span> inverse[row] = inverse[row] / divisor;</div>
<div class="line"><a id="l00301" name="l00301"></a><span class="lineno"> 301</span> <span class="comment">// Row transformations</span></div>
<div class="line"><a id="l00302" name="l00302"></a><span class="lineno"> 302</span> <span class="keywordflow">for</span> (<span class="keywordtype">size_t</span> row2 = 0; row2 &lt; <a class="code hl_variable" href="../../d6/d42/data__structures_2sparse__table_8cpp.html#a10f3ffb3f6f7e1b83d556b9c8de89a5d">N</a>; row2++) {</div>
<div class="line"><a id="l00303" name="l00303"></a><span class="lineno"> 303</span> <span class="keywordflow">if</span> (row2 == row)</div>
<div class="line"><a id="l00304" name="l00304"></a><span class="lineno"> 304</span> <span class="keywordflow">continue</span>;</div>
<div class="line"><a id="l00305" name="l00305"></a><span class="lineno"> 305</span> <span class="keywordtype">double</span> factor = temp[row2][row];</div>
<div class="line"><a id="l00306" name="l00306"></a><span class="lineno"> 306</span> temp[row2] = temp[row2] - factor * temp[row];</div>
<div class="line"><a id="l00307" name="l00307"></a><span class="lineno"> 307</span> inverse[row2] = inverse[row2] - factor * inverse[row];</div>
<div class="line"><a id="l00308" name="l00308"></a><span class="lineno"> 308</span> }</div>
<div class="line"><a id="l00309" name="l00309"></a><span class="lineno"> 309</span> }</div>
<div class="line"><a id="l00310" name="l00310"></a><span class="lineno"> 310</span> </div>
<div class="line"><a id="l00311" name="l00311"></a><span class="lineno"> 311</span> <span class="keywordflow">return</span> inverse;</div>
<div class="line"><a id="l00312" name="l00312"></a><span class="lineno"> 312</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="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">
Here is the call graph for this function:</div>
<div class="dyncontent">
<div class="center"><iframe scrolling="no" frameborder="0" src="../../d6/d26/classciphers_1_1_hill_cipher_a5a4cdbd4d4dad9efe2ed309bd466dd4b_cgraph.svg" width="304" height="88"><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="../../d6/d26/classciphers_1_1_hill_cipher_a2eb58750b978a93ac5e6eb29e3e570b7_cgraph.svg" width="304" 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="a40efd842a5cc44c233641ac2df13b0c0"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a40efd842a5cc44c233641ac2df13b0c0">&#9670;&nbsp;</a></span>mat_mul()</h2>
<a id="ad36cbcc7a458b3f3a2af0c4aa1126590" name="ad36cbcc7a458b3f3a2af0c4aa1126590"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ad36cbcc7a458b3f3a2af0c4aa1126590">&#9670;&nbsp;</a></span>mat_mul()</h2>
<div class="memitem">
<div class="memproto">
@@ -857,7 +855,7 @@ Here is the call graph for this function:</div>
<td class="mlabels-left">
<table class="memname">
<tr>
<td class="memname">static const <a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/numeric/valarray.html">std::valarray</a>&lt;uint8_t&gt; ciphers::HillCipher::mat_mul </td>
<td class="memname">static const <a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/numeric/valarray.html">std::valarray</a>&lt; uint8_t &gt; ciphers::HillCipher::mat_mul </td>
<td>(</td>
<td class="paramtype">const <a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/numeric/valarray.html">std::valarray</a>&lt; uint8_t &gt; &amp;&#160;</td>
<td class="paramname"><em>vector</em>, </td>
@@ -890,31 +888,73 @@ Here is the call graph for this function:</div>
</dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>corresponding encrypted or decrypted text </dd></dl>
<div class="fragment"><div class="line"><a name="l00160"></a><span class="lineno"> 160</span>&#160; {</div>
<div class="line"><a name="l00161"></a><span class="lineno"> 161</span>&#160; <a class="codeRef" target="_blank" href="http://en.cppreference.com/w/cpp/numeric/valarray.html">std::valarray&lt;uint8_t&gt;</a> out(vector); <span class="comment">// make a copy</span></div>
<div class="line"><a name="l00162"></a><span class="lineno"> 162</span>&#160; </div>
<div class="line"><a name="l00163"></a><span class="lineno"> 163</span>&#160; <span class="keywordtype">size_t</span> L = <a class="codeRef" target="_blank" href="http://en.cppreference.com/w/cpp/string/byte/strlen.html">std::strlen</a>(<a class="code" href="../../d6/d4e/namespaceciphers.html#ab9aec0ccf4b6809f652bb540be87c216">STRKEY</a>);</div>
<div class="line"><a name="l00164"></a><span class="lineno"> 164</span>&#160; </div>
<div class="line"><a name="l00165"></a><span class="lineno"> 165</span>&#160; <span class="keywordflow">for</span> (<span class="keywordtype">size_t</span> i = 0; i &lt; key.<a class="codeRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector/size.html">size</a>(); i++) {</div>
<div class="line"><a name="l00166"></a><span class="lineno"> 166</span>&#160; <span class="keywordtype">int</span> tmp = 0;</div>
<div class="line"><a name="l00167"></a><span class="lineno"> 167</span>&#160; <span class="keywordflow">for</span> (<span class="keywordtype">size_t</span> j = 0; j &lt; vector.size(); j++) {</div>
<div class="line"><a name="l00168"></a><span class="lineno"> 168</span>&#160; tmp += key[i][j] * vector[j];</div>
<div class="line"><a name="l00169"></a><span class="lineno"> 169</span>&#160; }</div>
<div class="line"><a name="l00170"></a><span class="lineno"> 170</span>&#160; out[i] = <span class="keyword">static_cast&lt;</span>uint8_t<span class="keyword">&gt;</span>(tmp % L);</div>
<div class="line"><a name="l00171"></a><span class="lineno"> 171</span>&#160; }</div>
<div class="line"><a name="l00172"></a><span class="lineno"> 172</span>&#160; </div>
<div class="line"><a name="l00173"></a><span class="lineno"> 173</span>&#160; <span class="keywordflow">return</span> out;</div>
<div class="line"><a name="l00174"></a><span class="lineno"> 174</span>&#160; }</div>
<div class="fragment"><div class="line"><a id="l00160" name="l00160"></a><span class="lineno"> 160</span> {</div>
<div class="line"><a id="l00161" name="l00161"></a><span class="lineno"> 161</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/numeric/valarray.html">std::valarray&lt;uint8_t&gt;</a> out(vector); <span class="comment">// make a copy</span></div>
<div class="line"><a id="l00162" name="l00162"></a><span class="lineno"> 162</span> </div>
<div class="line"><a id="l00163" name="l00163"></a><span class="lineno"> 163</span> <span class="keywordtype">size_t</span> L = <a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/string/byte/strlen.html">std::strlen</a>(<a class="code hl_variable" href="../../d6/d4e/namespaceciphers.html#ab9aec0ccf4b6809f652bb540be87c216">STRKEY</a>);</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> <span class="keywordflow">for</span> (<span class="keywordtype">size_t</span> i = 0; i &lt; key.<a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector/size.html">size</a>(); i++) {</div>
<div class="line"><a id="l00166" name="l00166"></a><span class="lineno"> 166</span> <span class="keywordtype">int</span> tmp = 0;</div>
<div class="line"><a id="l00167" name="l00167"></a><span class="lineno"> 167</span> <span class="keywordflow">for</span> (<span class="keywordtype">size_t</span> j = 0; j &lt; vector.size(); j++) {</div>
<div class="line"><a id="l00168" name="l00168"></a><span class="lineno"> 168</span> tmp += key[i][j] * vector[j];</div>
<div class="line"><a id="l00169" name="l00169"></a><span class="lineno"> 169</span> }</div>
<div class="line"><a id="l00170" name="l00170"></a><span class="lineno"> 170</span> out[i] = <span class="keyword">static_cast&lt;</span>uint8_t<span class="keyword">&gt;</span>(tmp % L);</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> </div>
<div class="line"><a id="l00173" name="l00173"></a><span class="lineno"> 173</span> <span class="keywordflow">return</span> out;</div>
<div class="line"><a id="l00174" name="l00174"></a><span class="lineno"> 174</span> }</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="../../d6/d26/classciphers_1_1_hill_cipher_a40efd842a5cc44c233641ac2df13b0c0_cgraph.svg" width="304" height="88"><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="../../d6/d26/classciphers_1_1_hill_cipher_ad36cbcc7a458b3f3a2af0c4aa1126590_cgraph.svg" width="304" 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="a716d0313141499d16f57c0c107f04395"></a>
<a id="a63e7b8e92dff8b9260d6d21c31ecebd0" name="a63e7b8e92dff8b9260d6d21c31ecebd0"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a63e7b8e92dff8b9260d6d21c31ecebd0">&#9670;&nbsp;</a></span>modulo()</h2>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
<tr>
<td class="mlabels-left">
<table class="memname">
<tr>
<td class="memname">static int ciphers::HillCipher::modulo </td>
<td>(</td>
<td class="paramtype">int&#160;</td>
<td class="paramname"><em>a</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int&#160;</td>
<td class="paramname"><em>b</em>&#160;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</td>
<td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span><span class="mlabel">static</span><span class="mlabel">private</span></span> </td>
</tr>
</table>
</div><div class="memdoc">
<div class="fragment"><div class="line"><a id="l00314" name="l00314"></a><span class="lineno"> 314</span> {</div>
<div class="line"><a id="l00315" name="l00315"></a><span class="lineno"> 315</span> <span class="keywordtype">int</span> ret = a % b;</div>
<div class="line"><a id="l00316" name="l00316"></a><span class="lineno"> 316</span> <span class="keywordflow">if</span> (ret &lt; 0)</div>
<div class="line"><a id="l00317" name="l00317"></a><span class="lineno"> 317</span> ret += b;</div>
<div class="line"><a id="l00318" name="l00318"></a><span class="lineno"> 318</span> <span class="keywordflow">return</span> ret;</div>
<div class="line"><a id="l00319" name="l00319"></a><span class="lineno"> 319</span> }</div>
</div><!-- fragment -->
</div>
</div>
<a id="a716d0313141499d16f57c0c107f04395" name="a716d0313141499d16f57c0c107f04395"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a716d0313141499d16f57c0c107f04395">&#9670;&nbsp;</a></span>rand_range() <span class="overload">[1/2]</span></h2>
<div class="memitem">
@@ -974,15 +1014,15 @@ template&lt;typename T1 , typename T2 &gt; </div>
</dl>
<dl class="section return"><dt>Returns</dt><dd>determinant of generated random matrix</dd></dl>
<dl class="section warning"><dt>Warning</dt><dd>There will need to be a balance between the matrix size and the range of random numbers. If the matrix is large, the range of random numbers must be small to have a well defined keys. Or if the matrix is smaller, the random numbers range can be larger. For an 8x8 matrix, range should be no more than \([0,10]\) </dd></dl>
<div class="fragment"><div class="line"><a name="l00118"></a><span class="lineno"> 118</span>&#160; {</div>
<div class="line"><a name="l00119"></a><span class="lineno"> 119</span>&#160; <span class="keywordflow">for</span> (<span class="keywordtype">size_t</span> i = 0; i &lt; <a class="code" href="../../d6/d42/data__structures_2sparse__table_8cpp.html#af7db62f21983565c64d5d42d2a49888e">M</a>-&gt;size(); i++) {</div>
<div class="line"><a name="l00120"></a><span class="lineno"> 120</span>&#160; <span class="keywordflow">for</span> (<span class="keywordtype">size_t</span> j = 0; j &lt; <a class="code" href="../../d6/d42/data__structures_2sparse__table_8cpp.html#af7db62f21983565c64d5d42d2a49888e">M</a>[0][0].size(); j++) {</div>
<div class="line"><a name="l00121"></a><span class="lineno"> 121</span>&#160; <a class="code" href="../../d6/d42/data__structures_2sparse__table_8cpp.html#af7db62f21983565c64d5d42d2a49888e">M</a>[0][i][j] = rand_range&lt;T1, T2&gt;(a, b);</div>
<div class="line"><a name="l00122"></a><span class="lineno"> 122</span>&#160; }</div>
<div class="line"><a name="l00123"></a><span class="lineno"> 123</span>&#160; }</div>
<div class="line"><a name="l00124"></a><span class="lineno"> 124</span>&#160; </div>
<div class="line"><a name="l00125"></a><span class="lineno"> 125</span>&#160; <span class="keywordflow">return</span> <a class="code" href="../../d1/dbe/lu__decomposition_8h.html#a3108d43bd32c6fb3b3c158476c51ba7f">determinant_lu</a>(*M);</div>
<div class="line"><a name="l00126"></a><span class="lineno"> 126</span>&#160; }</div>
<div class="fragment"><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">size_t</span> i = 0; i &lt; <a class="code hl_variable" href="../../d6/d42/data__structures_2sparse__table_8cpp.html#af7db62f21983565c64d5d42d2a49888e">M</a>-&gt;size(); i++) {</div>
<div class="line"><a id="l00120" name="l00120"></a><span class="lineno"> 120</span> <span class="keywordflow">for</span> (<span class="keywordtype">size_t</span> j = 0; j &lt; <a class="code hl_variable" href="../../d6/d42/data__structures_2sparse__table_8cpp.html#af7db62f21983565c64d5d42d2a49888e">M</a>[0][0].size(); j++) {</div>
<div class="line"><a id="l00121" name="l00121"></a><span class="lineno"> 121</span> <a class="code hl_variable" href="../../d6/d42/data__structures_2sparse__table_8cpp.html#af7db62f21983565c64d5d42d2a49888e">M</a>[0][i][j] = rand_range&lt;T1, T2&gt;(a, b);</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> }</div>
<div class="line"><a id="l00124" name="l00124"></a><span class="lineno"> 124</span> </div>
<div class="line"><a id="l00125" name="l00125"></a><span class="lineno"> 125</span> <span class="keywordflow">return</span> <a class="code hl_function" href="../../d1/dbe/lu__decomposition_8h.html#a3108d43bd32c6fb3b3c158476c51ba7f">determinant_lu</a>(*M);</div>
<div class="line"><a id="l00126" name="l00126"></a><span class="lineno"> 126</span> }</div>
<div class="ttc" id="adata__structures_2sparse__table_8cpp_html_af7db62f21983565c64d5d42d2a49888e"><div class="ttname"><a href="../../d6/d42/data__structures_2sparse__table_8cpp.html#af7db62f21983565c64d5d42d2a49888e">data_structures::sparse_table::M</a></div><div class="ttdeci">constexpr uint8_t M</div><div class="ttdoc">ceil(log2(N)).</div><div class="ttdef"><b>Definition:</b> sparse_table.cpp:48</div></div>
</div><!-- fragment --><div class="dynheader">
Here is the call graph for this function:</div>
@@ -993,7 +1033,7 @@ Here is the call graph for this function:</div>
</div>
</div>
<a id="a629be41c1ab78850963e4ce14e1d11d9"></a>
<a id="a629be41c1ab78850963e4ce14e1d11d9" name="a629be41c1ab78850963e4ce14e1d11d9"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a629be41c1ab78850963e4ce14e1d11d9">&#9670;&nbsp;</a></span>rand_range() <span class="overload">[2/2]</span></h2>
<div class="memitem">
@@ -1044,13 +1084,13 @@ template&lt;typename T1 , typename T2 &gt; </div>
</dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>random integer in the interval \([a,b)\) </dd></dl>
<div class="fragment"><div class="line"><a name="l00092"></a><span class="lineno"> 92</span>&#160; {</div>
<div class="line"><a name="l00093"></a><span class="lineno"> 93</span>&#160; <span class="comment">// generate random number between 0 and 1</span></div>
<div class="line"><a name="l00094"></a><span class="lineno"> 94</span>&#160; <span class="keywordtype">long</span> <span class="keywordtype">double</span> r = <span class="keyword">static_cast&lt;</span><span class="keywordtype">long</span> <span class="keywordtype">double</span><span class="keyword">&gt;</span>(<a class="codeRef" target="_blank" href="http://en.cppreference.com/w/cpp/numeric/random/rand.html">std::rand</a>()) / RAND_MAX;</div>
<div class="line"><a name="l00095"></a><span class="lineno"> 95</span>&#160; </div>
<div class="line"><a name="l00096"></a><span class="lineno"> 96</span>&#160; <span class="comment">// scale and return random number as integer</span></div>
<div class="line"><a name="l00097"></a><span class="lineno"> 97</span>&#160; <span class="keywordflow">return</span> <span class="keyword">static_cast&lt;</span>T2<span class="keyword">&gt;</span>(r * (b - a) + a);</div>
<div class="line"><a name="l00098"></a><span class="lineno"> 98</span>&#160; }</div>
<div class="fragment"><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> <span class="comment">// generate random number between 0 and 1</span></div>
<div class="line"><a id="l00094" name="l00094"></a><span class="lineno"> 94</span> <span class="keywordtype">long</span> <span class="keywordtype">double</span> r = <span class="keyword">static_cast&lt;</span><span class="keywordtype">long</span> <span class="keywordtype">double</span><span class="keyword">&gt;</span>(<a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/numeric/random/rand.html">std::rand</a>()) / RAND_MAX;</div>
<div class="line"><a id="l00095" name="l00095"></a><span class="lineno"> 95</span> </div>
<div class="line"><a id="l00096" name="l00096"></a><span class="lineno"> 96</span> <span class="comment">// scale and return random number as integer</span></div>
<div class="line"><a id="l00097" name="l00097"></a><span class="lineno"> 97</span> <span class="keywordflow">return</span> <span class="keyword">static_cast&lt;</span>T2<span class="keyword">&gt;</span>(r * (b - a) + a);</div>
<div class="line"><a id="l00098" name="l00098"></a><span class="lineno"> 98</span> }</div>
<div class="ttc" id="arand_html"><div class="ttname"><a href="http://en.cppreference.com/w/cpp/numeric/random/rand.html">std::rand</a></div><div class="ttdeci">T rand(T... args)</div></div>
</div><!-- fragment --><div class="dynheader">
Here is the call graph for this function:</div>
@@ -1070,7 +1110,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="../../d6/d4e/namespaceciphers.html">ciphers</a></li><li class="navelem"><a class="el" href="../../d6/d26/classciphers_1_1_hill_cipher.html">HillCipher</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.1 </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>
</ul>
</div>
</body>

View File

@@ -4,14 +4,13 @@ var classciphers_1_1_hill_cipher =
[ "decrypt_text", "d6/d26/classciphers_1_1_hill_cipher.html#a427acfac1dbff3f48a2b071d449d965b", null ],
[ "encrypt_text", "d6/d26/classciphers_1_1_hill_cipher.html#aa8bbb6e4a5749f6008b06602d5103917", null ],
[ "gcd", "d6/d26/classciphers_1_1_hill_cipher.html#a7760f3665651a0a37937c79c62f219c0", null ],
[ "generate_decryption_key", "d6/d26/classciphers_1_1_hill_cipher.html#abb2c4dc2b8a59d3dfe0fa22c2adc086b", null ],
[ "generate_encryption_key", "d6/d26/classciphers_1_1_hill_cipher.html#a7ca10cd1a0e8e3732391e0427d2d0213", null ],
[ "generate_keys", "d6/d26/classciphers_1_1_hill_cipher.html#a14bfcd14af6cd853130cbacd32e35c13", null ],
[ "generate_decryption_key", "d6/d26/classciphers_1_1_hill_cipher.html#ab02c7563889bf1e363deb8e21967b706", null ],
[ "generate_encryption_key", "d6/d26/classciphers_1_1_hill_cipher.html#a642f70fb54cb50b00fb6df7c3f2b120e", null ],
[ "generate_keys", "d6/d26/classciphers_1_1_hill_cipher.html#a405b0a28d66a61239d3565d5256f9cb5", null ],
[ "get_char_idx", "d6/d26/classciphers_1_1_hill_cipher.html#ae77cad522fa44b8c985779a7188d2f41", null ],
[ "get_idx_char", "d6/d26/classciphers_1_1_hill_cipher.html#a12f727cca9e21f9539cd74b6603adf0c", null ],
[ "get_inverse", "d6/d26/classciphers_1_1_hill_cipher.html#a5a4cdbd4d4dad9efe2ed309bd466dd4b", null ],
[ "mat_mul", "d6/d26/classciphers_1_1_hill_cipher.html#a40efd842a5cc44c233641ac2df13b0c0", null ],
[ "modulo", "d6/d26/classciphers_1_1_hill_cipher.html#a63e7b8e92dff8b9260d6d21c31ecebd0", null ],
[ "get_inverse", "d6/d26/classciphers_1_1_hill_cipher.html#a2eb58750b978a93ac5e6eb29e3e570b7", null ],
[ "mat_mul", "d6/d26/classciphers_1_1_hill_cipher.html#ad36cbcc7a458b3f3a2af0c4aa1126590", null ],
[ "rand_range", "d6/d26/classciphers_1_1_hill_cipher.html#a716d0313141499d16f57c0c107f04395", null ],
[ "rand_range", "d6/d26/classciphers_1_1_hill_cipher.html#a629be41c1ab78850963e4ce14e1d11d9", null ]
];

View File

@@ -1,7 +1,7 @@
<?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.48.0 (20210717.1556)
<!-- Generated by graphviz version 2.49.0 (20210828.1703)
-->
<!-- Title: ciphers::HillCipher::get_inverse Pages: 1 -->
<svg width="228pt" height="66pt"

Before

Width:  |  Height:  |  Size: 2.5 KiB

After

Width:  |  Height:  |  Size: 2.5 KiB

View File

@@ -3,7 +3,7 @@
<area shape="rect" id="node2" href="$d6/d26/classciphers_1_1_hill_cipher.html#ad667fa0860977f6d6d443fa1dbcd80aa" title="Convenience function to perform block cipher operations. The operations are identical for both encryp..." alt="" coords="184,93,315,135"/>
<area shape="rect" id="node3" href="$d6/d26/classciphers_1_1_hill_cipher.html#ae77cad522fa44b8c985779a7188d2f41" title="Get the index of a character in the STRKEY." alt="" coords="363,5,493,47"/>
<area shape="rect" id="node5" href="/Users/runner/work/C-Plus-Plus/C-Plus-Plus/doc/cppreference-doxygen-web.tag.xml$cpp/string/basic_string/size.html#" title=" " alt="" coords="366,71,490,98"/>
<area shape="rect" id="node6" href="$d6/d26/classciphers_1_1_hill_cipher.html#a40efd842a5cc44c233641ac2df13b0c0" title="helper function to perform vector multiplication with encryption or decryption matrix" alt="" coords="363,123,493,164"/>
<area shape="rect" id="node6" href="$d6/d26/classciphers_1_1_hill_cipher.html#ad36cbcc7a458b3f3a2af0c4aa1126590" title="helper function to perform vector multiplication with encryption or decryption matrix" alt="" coords="363,123,493,164"/>
<area shape="rect" id="node7" href="/Users/runner/work/C-Plus-Plus/C-Plus-Plus/doc/cppreference-doxygen-web.tag.xml$cpp/container/vector/size.html#" title=" " alt="" coords="541,158,656,185"/>
<area shape="rect" id="node4" href="/Users/runner/work/C-Plus-Plus/C-Plus-Plus/doc/cppreference-doxygen-web.tag.xml$cpp/string/byte/strlen.html#" title=" " alt="" coords="559,103,639,130"/>
</map>

View File

@@ -1 +1 @@
0cd668ab83784d1d4a2b3fceadf486b3
cacc384c953975f6764caf695b0c62d5

View File

@@ -1,7 +1,7 @@
<?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.48.0 (20210717.1556)
<!-- Generated by graphviz version 2.49.0 (20210828.1703)
-->
<!-- Title: ciphers::HillCipher::decrypt_text Pages: 1 -->
<svg width="496pt" height="145pt"
@@ -69,7 +69,7 @@
<!-- Node6 -->
<g id="node6" class="node">
<title>Node6</title>
<g id="a_node6"><a xlink:href="../../d6/d26/classciphers_1_1_hill_cipher.html#a40efd842a5cc44c233641ac2df13b0c0" target="_top" xlink:title="helper function to perform vector multiplication with encryption or decryption matrix">
<g id="a_node6"><a xlink:href="../../d6/d26/classciphers_1_1_hill_cipher.html#ad36cbcc7a458b3f3a2af0c4aa1126590" target="_top" xlink:title="helper function to perform vector multiplication with encryption or decryption matrix">
<polygon fill="white" stroke="black" points="268,-18.14 268,-48.14 366,-48.14 366,-18.14 268,-18.14"/>
<text text-anchor="start" x="276" y="-36.14" font-family="Helvetica,sans-Serif" font-size="10.00">ciphers::HillCipher</text>
<text text-anchor="middle" x="317" y="-25.14" font-family="Helvetica,sans-Serif" font-size="10.00">::mat_mul</text>

Before

Width:  |  Height:  |  Size: 6.8 KiB

After

Width:  |  Height:  |  Size: 6.8 KiB

View File

@@ -1,7 +1,7 @@
<?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.48.0 (20210717.1556)
<!-- Generated by graphviz version 2.49.0 (20210828.1703)
-->
<!-- Title: ciphers::HillCipher::rand_range Pages: 1 -->
<svg width="197pt" height="39pt"

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 1.8 KiB

View File

@@ -1,7 +1,7 @@
<?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.48.0 (20210717.1556)
<!-- Generated by graphviz version 2.49.0 (20210828.1703)
-->
<!-- Title: ciphers::HillCipher::rand_range Pages: 1 -->
<svg width="477pt" height="53pt"

Before

Width:  |  Height:  |  Size: 3.6 KiB

After

Width:  |  Height:  |  Size: 3.6 KiB

View File

@@ -1,7 +1,7 @@
<?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.48.0 (20210717.1556)
<!-- Generated by graphviz version 2.49.0 (20210828.1703)
-->
<!-- Title: ciphers::HillCipher::gcd Pages: 1 -->
<svg width="222pt" height="28pt"

Before

Width:  |  Height:  |  Size: 1.7 KiB

After

Width:  |  Height:  |  Size: 1.7 KiB

View File

@@ -3,7 +3,7 @@
<area shape="rect" id="node2" href="$d6/d26/classciphers_1_1_hill_cipher.html#ad667fa0860977f6d6d443fa1dbcd80aa" title="Convenience function to perform block cipher operations. The operations are identical for both encryp..." alt="" coords="184,93,315,135"/>
<area shape="rect" id="node3" href="$d6/d26/classciphers_1_1_hill_cipher.html#ae77cad522fa44b8c985779a7188d2f41" title="Get the index of a character in the STRKEY." alt="" coords="363,5,493,47"/>
<area shape="rect" id="node5" href="/Users/runner/work/C-Plus-Plus/C-Plus-Plus/doc/cppreference-doxygen-web.tag.xml$cpp/string/basic_string/size.html#" title=" " alt="" coords="366,71,490,98"/>
<area shape="rect" id="node6" href="$d6/d26/classciphers_1_1_hill_cipher.html#a40efd842a5cc44c233641ac2df13b0c0" title="helper function to perform vector multiplication with encryption or decryption matrix" alt="" coords="363,123,493,164"/>
<area shape="rect" id="node6" href="$d6/d26/classciphers_1_1_hill_cipher.html#ad36cbcc7a458b3f3a2af0c4aa1126590" title="helper function to perform vector multiplication with encryption or decryption matrix" alt="" coords="363,123,493,164"/>
<area shape="rect" id="node7" href="/Users/runner/work/C-Plus-Plus/C-Plus-Plus/doc/cppreference-doxygen-web.tag.xml$cpp/container/vector/size.html#" title=" " alt="" coords="541,158,656,185"/>
<area shape="rect" id="node4" href="/Users/runner/work/C-Plus-Plus/C-Plus-Plus/doc/cppreference-doxygen-web.tag.xml$cpp/string/byte/strlen.html#" title=" " alt="" coords="559,103,639,130"/>
</map>

View File

@@ -1 +1 @@
4919afd3b515b2fef6644a5ddbafdb3f
50b6d83d3d0ff27b6232642f06c128e1

View File

@@ -1,7 +1,7 @@
<?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.48.0 (20210717.1556)
<!-- Generated by graphviz version 2.49.0 (20210828.1703)
-->
<!-- Title: ciphers::HillCipher::encrypt_text Pages: 1 -->
<svg width="496pt" height="145pt"
@@ -69,7 +69,7 @@
<!-- Node6 -->
<g id="node6" class="node">
<title>Node6</title>
<g id="a_node6"><a xlink:href="../../d6/d26/classciphers_1_1_hill_cipher.html#a40efd842a5cc44c233641ac2df13b0c0" target="_top" xlink:title="helper function to perform vector multiplication with encryption or decryption matrix">
<g id="a_node6"><a xlink:href="../../d6/d26/classciphers_1_1_hill_cipher.html#ad36cbcc7a458b3f3a2af0c4aa1126590" target="_top" xlink:title="helper function to perform vector multiplication with encryption or decryption matrix">
<polygon fill="white" stroke="black" points="268,-18.14 268,-48.14 366,-48.14 366,-18.14 268,-18.14"/>
<text text-anchor="start" x="276" y="-36.14" font-family="Helvetica,sans-Serif" font-size="10.00">ciphers::HillCipher</text>
<text text-anchor="middle" x="317" y="-25.14" font-family="Helvetica,sans-Serif" font-size="10.00">::mat_mul</text>

Before

Width:  |  Height:  |  Size: 6.8 KiB

After

Width:  |  Height:  |  Size: 6.8 KiB

View File

@@ -1,7 +1,7 @@
<?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.48.0 (20210717.1556)
<!-- Generated by graphviz version 2.49.0 (20210828.1703)
-->
<!-- Title: ciphers::HillCipher::mat_mul Pages: 1 -->
<svg width="228pt" height="66pt"

Before

Width:  |  Height:  |  Size: 2.6 KiB

After

Width:  |  Height:  |  Size: 2.6 KiB

View File

@@ -2,7 +2,7 @@
<area shape="rect" id="node1" title="Convenience function to perform block cipher operations. The operations are identical for both encryp..." alt="" coords="5,93,136,135"/>
<area shape="rect" id="node2" href="$d6/d26/classciphers_1_1_hill_cipher.html#ae77cad522fa44b8c985779a7188d2f41" title="Get the index of a character in the STRKEY." alt="" coords="184,5,315,47"/>
<area shape="rect" id="node4" href="/Users/runner/work/C-Plus-Plus/C-Plus-Plus/doc/cppreference-doxygen-web.tag.xml$cpp/string/basic_string/size.html#" title=" " alt="" coords="187,71,311,98"/>
<area shape="rect" id="node5" href="$d6/d26/classciphers_1_1_hill_cipher.html#a40efd842a5cc44c233641ac2df13b0c0" title="helper function to perform vector multiplication with encryption or decryption matrix" alt="" coords="184,123,315,164"/>
<area shape="rect" id="node5" href="$d6/d26/classciphers_1_1_hill_cipher.html#ad36cbcc7a458b3f3a2af0c4aa1126590" title="helper function to perform vector multiplication with encryption or decryption matrix" alt="" coords="184,123,315,164"/>
<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="363,158,477,185"/>
<area shape="rect" id="node3" href="/Users/runner/work/C-Plus-Plus/C-Plus-Plus/doc/cppreference-doxygen-web.tag.xml$cpp/string/byte/strlen.html#" title=" " alt="" coords="380,103,460,130"/>
</map>

View File

@@ -1 +1 @@
35fef77fb23db5b708418a70400952e6
9629277b92c4b82b44929679f89e95c6

View File

@@ -1,7 +1,7 @@
<?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.48.0 (20210717.1556)
<!-- Generated by graphviz version 2.49.0 (20210828.1703)
-->
<!-- Title: ciphers::HillCipher::codec Pages: 1 -->
<svg width="362pt" height="145pt"
@@ -53,7 +53,7 @@
<!-- Node5 -->
<g id="node5" class="node">
<title>Node5</title>
<g id="a_node5"><a xlink:href="../../d6/d26/classciphers_1_1_hill_cipher.html#a40efd842a5cc44c233641ac2df13b0c0" target="_top" xlink:title="helper function to perform vector multiplication with encryption or decryption matrix">
<g id="a_node5"><a xlink:href="../../d6/d26/classciphers_1_1_hill_cipher.html#ad36cbcc7a458b3f3a2af0c4aa1126590" target="_top" xlink:title="helper function to perform vector multiplication with encryption or decryption matrix">
<polygon fill="white" stroke="black" points="134,-18.14 134,-48.14 232,-48.14 232,-18.14 134,-18.14"/>
<text text-anchor="start" x="142" y="-36.14" font-family="Helvetica,sans-Serif" font-size="10.00">ciphers::HillCipher</text>
<text text-anchor="middle" x="183" y="-25.14" font-family="Helvetica,sans-Serif" font-size="10.00">::mat_mul</text>

Before

Width:  |  Height:  |  Size: 5.9 KiB

After

Width:  |  Height:  |  Size: 5.9 KiB

View File

@@ -1,7 +1,7 @@
<?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.48.0 (20210717.1556)
<!-- Generated by graphviz version 2.49.0 (20210828.1703)
-->
<!-- Title: ciphers::HillCipher::get_char_idx Pages: 1 -->
<svg width="202pt" height="39pt"

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 1.8 KiB

View File

@@ -2,8 +2,8 @@
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.9.1"/>
<meta http-equiv="X-UA-Compatible" content="IE=11"/>
<meta name="generator" content="Doxygen 1.9.2"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>Algorithms_in_C++: dynamic_programming/house_robber.cpp File Reference</title>
<link href="../../tabs.css" rel="stylesheet" type="text/css"/>
@@ -17,9 +17,9 @@
<script type="text/javascript" src="../../search/searchdata.js"></script>
<script type="text/javascript" src="../../search/search.js"></script>
<script type="text/x-mathjax-config">
MathJax.Hub.Config({
extensions: ["tex2jax.js", "TeX/AMSmath.js", "TeX/AMSsymbols.js"],
jax: ["input/TeX","output/HTML-CSS"],
MathJax.Hub.Config({
extensions: ["tex2jax.js", "TeX/AMSmath.js", "TeX/AMSsymbols.js"],
jax: ["input/TeX","output/HTML-CSS"],
});
</script>
<script type="text/javascript" async="async" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.7/MathJax.js?config=TeX-MML-AM_CHTML/MathJax.js"></script>
@@ -32,8 +32,7 @@
<tbody>
<tr style="height: 56px;">
<td id="projectalign" style="padding-left: 0.5em;">
<div id="projectname">Algorithms_in_C++
&#160;<span id="projectnumber">1.0.0</span>
<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>
</td>
@@ -42,21 +41,22 @@
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.9.1 -->
<!-- Generated by Doxygen 1.9.2 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
var searchBox = new SearchBox("searchBox", "../../search",false,'Search','.html');
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
var searchBox = new SearchBox("searchBox", "../../search",'Search','.html');
/* @license-end */
</script>
<script type="text/javascript" src="../../menudata.js"></script>
<script type="text/javascript" src="../../menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(function() {
initMenu('../../',true,false,'search.php','Search');
$(document).ready(function() { init_search(); });
});
/* @license-end */</script>
/* @license-end */
</script>
<div id="main-nav"></div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
@@ -70,7 +70,7 @@ $(function() {
</div>
</div>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(document).ready(function(){initNavTree('d6/d26/house__robber_8cpp.html','../../'); initResizable(); });
/* @license-end */
</script>
@@ -93,12 +93,11 @@ $(document).ready(function(){initNavTree('d6/d26/house__robber_8cpp.html','../..
<div class="summary">
<a href="#namespaces">Namespaces</a> &#124;
<a href="#func-members">Functions</a> </div>
<div class="headertitle">
<div class="title">house_robber.cpp File Reference</div> </div>
<div class="headertitle"><div class="title">house_robber.cpp File Reference</div></div>
</div><!--header-->
<div class="contents">
<p>Implementation of <a href="https://labuladong.gitbook.io/algo-en/i.-dynamic-programming/houserobber">House Robber Problem</a> algorithm.
<p>Implementation of <a href="https://labuladong.gitbook.io/algo-en/i.-dynamic-programming/houserobber" target="_blank">House Robber Problem</a> algorithm.
<a href="#details">More...</a></p>
<div class="textblock"><code>#include &lt;cassert&gt;</code><br />
<code>#include &lt;climits&gt;</code><br />
@@ -111,16 +110,16 @@ Include dependency graph for house_robber.cpp:</div>
</div>
</div>
</div><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="namespaces"></a>
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="namespaces" name="namespaces"></a>
Namespaces</h2></td></tr>
<tr class="memitem:dd/d24/namespacedynamic__programming"><td class="memItemLeft" align="right" valign="top"> &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../dd/d24/namespacedynamic__programming.html">dynamic_programming</a></td></tr>
<tr class="memitem:dd/d24/namespacedynamic__programming"><td class="memItemLeft" align="right" valign="top">namespace &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../dd/d24/namespacedynamic__programming.html">dynamic_programming</a></td></tr>
<tr class="memdesc:dd/d24/namespacedynamic__programming"><td class="mdescLeft">&#160;</td><td class="mdescRight">Dynamic Programming algorithms. <br /></td></tr>
<tr class="separator:"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:d2/de1/namespacehouse__robber"><td class="memItemLeft" align="right" valign="top"> &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../d2/de1/namespacehouse__robber.html">house_robber</a></td></tr>
<tr class="memdesc:d2/de1/namespacehouse__robber"><td class="mdescLeft">&#160;</td><td class="mdescRight">Functions for the <a href="https://labuladong.gitbook.io/algo-en/i.-dynamic-programming/houserobber">House Robber</a> algorithm. <br /></td></tr>
<tr class="memitem:d2/de1/namespacehouse__robber"><td class="memItemLeft" align="right" valign="top">namespace &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../d2/de1/namespacehouse__robber.html">house_robber</a></td></tr>
<tr class="memdesc:d2/de1/namespacehouse__robber"><td class="mdescLeft">&#160;</td><td class="mdescRight">Functions for the <a href="https://labuladong.gitbook.io/algo-en/i.-dynamic-programming/houserobber" target="_blank">House Robber</a> algorithm. <br /></td></tr>
<tr class="separator:"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="func-members"></a>
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="func-members" name="func-members"></a>
Functions</h2></td></tr>
<tr class="memitem:a1e497c3e3f169afe5baaae6a5d40cbc8"><td class="memItemLeft" align="right" valign="top"><a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/types/integer.html">std::uint32_t</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../d6/d26/house__robber_8cpp.html#a1e497c3e3f169afe5baaae6a5d40cbc8">dynamic_programming::house_robber::houseRobber</a> (const <a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector</a>&lt; uint32_t &gt; &amp;money, const uint32_t &amp;n)</td></tr>
<tr class="memdesc:a1e497c3e3f169afe5baaae6a5d40cbc8"><td class="mdescLeft">&#160;</td><td class="mdescRight">The main function that implements the House Robber algorithm using dynamic programming. <a href="../../d6/d26/house__robber_8cpp.html#a1e497c3e3f169afe5baaae6a5d40cbc8">More...</a><br /></td></tr>
@@ -133,10 +132,10 @@ 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://labuladong.gitbook.io/algo-en/i.-dynamic-programming/houserobber">House Robber Problem</a> algorithm. </p>
<p><a class="el" href="../../dd/d4f/class_solution.html">Solution</a> of House robber problem uses a dynamic programming concept that works in \(O(n)\) time and works in \(O(1)\) space. </p><dl class="section author"><dt>Author</dt><dd><a href="https://github.com/Swastyy">Swastika Gupta</a> </dd></dl>
<div class="textblock"><p >Implementation of <a href="https://labuladong.gitbook.io/algo-en/i.-dynamic-programming/houserobber" target="_blank">House Robber Problem</a> algorithm. </p>
<p ><a class="el" href="../../dd/d4f/class_solution.html">Solution</a> of House robber problem uses a dynamic programming concept that works in \(O(n)\) time and works in \(O(1)\) space. </p><dl class="section author"><dt>Author</dt><dd><a href="https://github.com/Swastyy" target="_blank">Swastika Gupta</a> </dd></dl>
</div><h2 class="groupheader">Function Documentation</h2>
<a id="a1e497c3e3f169afe5baaae6a5d40cbc8"></a>
<a id="a1e497c3e3f169afe5baaae6a5d40cbc8" name="a1e497c3e3f169afe5baaae6a5d40cbc8"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a1e497c3e3f169afe5baaae6a5d40cbc8">&#9670;&nbsp;</a></span>houseRobber()</h2>
<div class="memitem">
@@ -171,28 +170,28 @@ Functions</h2></td></tr>
</dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>maximum amount of money that can be robbed </dd></dl>
<div class="fragment"><div class="line"><a name="l00037"></a><span class="lineno"> 37</span>&#160; {</div>
<div class="line"><a name="l00038"></a><span class="lineno"> 38</span>&#160; <span class="keywordflow">if</span> (n == 0) { <span class="comment">// if there is no house</span></div>
<div class="line"><a name="l00039"></a><span class="lineno"> 39</span>&#160; <span class="keywordflow">return</span> 0;</div>
<div class="line"><a name="l00040"></a><span class="lineno"> 40</span>&#160; }</div>
<div class="line"><a name="l00041"></a><span class="lineno"> 41</span>&#160; <span class="keywordflow">if</span> (n == 1) { <span class="comment">// if there is only one house</span></div>
<div class="line"><a name="l00042"></a><span class="lineno"> 42</span>&#160; <span class="keywordflow">return</span> money[0];</div>
<div class="line"><a name="l00043"></a><span class="lineno"> 43</span>&#160; }</div>
<div class="line"><a name="l00044"></a><span class="lineno"> 44</span>&#160; <span class="keywordflow">if</span> (n == 2) { <span class="comment">// if there are two houses, one with the maximum amount of</span></div>
<div class="line"><a name="l00045"></a><span class="lineno"> 45</span>&#160; <span class="comment">// money will be robbed</span></div>
<div class="line"><a name="l00046"></a><span class="lineno"> 46</span>&#160; <span class="keywordflow">return</span> <a class="codeRef" target="_blank" href="http://en.cppreference.com/w/cpp/algorithm/max.html">std::max</a>(money[0], money[1]);</div>
<div class="line"><a name="l00047"></a><span class="lineno"> 47</span>&#160; }</div>
<div class="line"><a name="l00048"></a><span class="lineno"> 48</span>&#160; uint32_t max_value = 0; <span class="comment">// contains maximum stolen value at the end</span></div>
<div class="line"><a name="l00049"></a><span class="lineno"> 49</span>&#160; uint32_t value1 = money[0];</div>
<div class="line"><a name="l00050"></a><span class="lineno"> 50</span>&#160; uint32_t value2 = <a class="codeRef" target="_blank" href="http://en.cppreference.com/w/cpp/algorithm/max.html">std::max</a>(money[0], money[1]);</div>
<div class="line"><a name="l00051"></a><span class="lineno"> 51</span>&#160; <span class="keywordflow">for</span> (uint32_t i = 2; i &lt; n; i++) {</div>
<div class="line"><a name="l00052"></a><span class="lineno"> 52</span>&#160; max_value = <a class="codeRef" target="_blank" href="http://en.cppreference.com/w/cpp/algorithm/max.html">std::max</a>(money[i] + value1, value2);</div>
<div class="line"><a name="l00053"></a><span class="lineno"> 53</span>&#160; value1 = value2;</div>
<div class="line"><a name="l00054"></a><span class="lineno"> 54</span>&#160; value2 = max_value;</div>
<div class="line"><a name="l00055"></a><span class="lineno"> 55</span>&#160; }</div>
<div class="line"><a name="l00056"></a><span class="lineno"> 56</span>&#160; </div>
<div class="line"><a name="l00057"></a><span class="lineno"> 57</span>&#160; <span class="keywordflow">return</span> max_value;</div>
<div class="line"><a name="l00058"></a><span class="lineno"> 58</span>&#160;}</div>
<div class="fragment"><div class="line"><a id="l00037" name="l00037"></a><span class="lineno"> 37</span> {</div>
<div class="line"><a id="l00038" name="l00038"></a><span class="lineno"> 38</span> <span class="keywordflow">if</span> (n == 0) { <span class="comment">// if there is no house</span></div>
<div class="line"><a id="l00039" name="l00039"></a><span class="lineno"> 39</span> <span class="keywordflow">return</span> 0;</div>
<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="keywordflow">if</span> (n == 1) { <span class="comment">// if there is only one house</span></div>
<div class="line"><a id="l00042" name="l00042"></a><span class="lineno"> 42</span> <span class="keywordflow">return</span> money[0];</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">if</span> (n == 2) { <span class="comment">// if there are two houses, one with the maximum amount of</span></div>
<div class="line"><a id="l00045" name="l00045"></a><span class="lineno"> 45</span> <span class="comment">// money will be robbed</span></div>
<div class="line"><a id="l00046" name="l00046"></a><span class="lineno"> 46</span> <span class="keywordflow">return</span> <a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/algorithm/max.html">std::max</a>(money[0], money[1]);</div>
<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> uint32_t max_value = 0; <span class="comment">// contains maximum stolen value at the end</span></div>
<div class="line"><a id="l00049" name="l00049"></a><span class="lineno"> 49</span> uint32_t value1 = money[0];</div>
<div class="line"><a id="l00050" name="l00050"></a><span class="lineno"> 50</span> uint32_t value2 = <a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/algorithm/max.html">std::max</a>(money[0], money[1]);</div>
<div class="line"><a id="l00051" name="l00051"></a><span class="lineno"> 51</span> <span class="keywordflow">for</span> (uint32_t i = 2; i &lt; n; i++) {</div>
<div class="line"><a id="l00052" name="l00052"></a><span class="lineno"> 52</span> max_value = <a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/algorithm/max.html">std::max</a>(money[i] + value1, value2);</div>
<div class="line"><a id="l00053" name="l00053"></a><span class="lineno"> 53</span> value1 = value2;</div>
<div class="line"><a id="l00054" name="l00054"></a><span class="lineno"> 54</span> value2 = max_value;</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> </div>
<div class="line"><a id="l00057" name="l00057"></a><span class="lineno"> 57</span> <span class="keywordflow">return</span> max_value;</div>
<div class="line"><a id="l00058" name="l00058"></a><span class="lineno"> 58</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><!-- fragment --><div class="dynheader">
Here is the call graph for this function:</div>
@@ -203,7 +202,7 @@ Here is the call graph for this function:</div>
</div>
</div>
<a id="ae66f6b31b5ad750f1fe042a706a4e3d4"></a>
<a id="ae66f6b31b5ad750f1fe042a706a4e3d4" name="ae66f6b31b5ad750f1fe042a706a4e3d4"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ae66f6b31b5ad750f1fe042a706a4e3d4">&#9670;&nbsp;</a></span>main()</h2>
<div class="memitem">
@@ -221,10 +220,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 name="l00111"></a><span class="lineno"> 111</span>&#160; {</div>
<div class="line"><a name="l00112"></a><span class="lineno"> 112</span>&#160; <a class="code" href="../../d6/d26/house__robber_8cpp.html#aa8dca7b867074164d5f45b0f3851269d">test</a>(); <span class="comment">// run self-test implementations</span></div>
<div class="line"><a name="l00113"></a><span class="lineno"> 113</span>&#160; <span class="keywordflow">return</span> 0;</div>
<div class="line"><a name="l00114"></a><span class="lineno"> 114</span>&#160;}</div>
<div class="fragment"><div class="line"><a id="l00111" name="l00111"></a><span class="lineno"> 111</span> {</div>
<div class="line"><a id="l00112" name="l00112"></a><span class="lineno"> 112</span> <a class="code hl_function" href="../../d6/d26/house__robber_8cpp.html#aa8dca7b867074164d5f45b0f3851269d">test</a>(); <span class="comment">// run self-test implementations</span></div>
<div class="line"><a id="l00113" name="l00113"></a><span class="lineno"> 113</span> <span class="keywordflow">return</span> 0;</div>
<div class="line"><a id="l00114" name="l00114"></a><span class="lineno"> 114</span>}</div>
<div class="ttc" id="ahouse__robber_8cpp_html_aa8dca7b867074164d5f45b0f3851269d"><div class="ttname"><a href="../../d6/d26/house__robber_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> house_robber.cpp:66</div></div>
</div><!-- fragment --><div class="dynheader">
Here is the call graph for this function:</div>
@@ -235,7 +234,7 @@ Here is the call graph for this function:</div>
</div>
</div>
<a id="aa8dca7b867074164d5f45b0f3851269d"></a>
<a id="aa8dca7b867074164d5f45b0f3851269d" name="aa8dca7b867074164d5f45b0f3851269d"></a>
<h2 class="memtitle"><span class="permalink"><a href="#aa8dca7b867074164d5f45b0f3851269d">&#9670;&nbsp;</a></span>test()</h2>
<div class="memitem">
@@ -260,46 +259,46 @@ 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 name="l00066"></a><span class="lineno"> 66</span>&#160; {</div>
<div class="line"><a name="l00067"></a><span class="lineno"> 67</span>&#160; <span class="comment">// Test 1</span></div>
<div class="line"><a name="l00068"></a><span class="lineno"> 68</span>&#160; <span class="comment">// [1, 2, 3, 1] return 4</span></div>
<div class="line"><a name="l00069"></a><span class="lineno"> 69</span>&#160; <a class="codeRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector&lt;uint32_t&gt;</a> array1 = {1, 2, 3, 1};</div>
<div class="line"><a name="l00070"></a><span class="lineno"> 70</span>&#160; <a class="codeRef" 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 name="l00071"></a><span class="lineno"> 71</span>&#160; assert(</div>
<div class="line"><a name="l00072"></a><span class="lineno"> 72</span>&#160; dynamic_programming::house_robber::houseRobber(array1, array1.<a class="codeRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector/size.html">size</a>()) ==</div>
<div class="line"><a name="l00073"></a><span class="lineno"> 73</span>&#160; 4); <span class="comment">// here the two non-adjacent houses that are robbed are first and</span></div>
<div class="line"><a name="l00074"></a><span class="lineno"> 74</span>&#160; <span class="comment">// third with total sum money as 4</span></div>
<div class="line"><a name="l00075"></a><span class="lineno"> 75</span>&#160; <a class="codeRef" 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="codeRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/manip/endl.html">std::endl</a>;</div>
<div class="line"><a name="l00076"></a><span class="lineno"> 76</span>&#160; </div>
<div class="line"><a name="l00077"></a><span class="lineno"> 77</span>&#160; <span class="comment">// Test 2</span></div>
<div class="line"><a name="l00078"></a><span class="lineno"> 78</span>&#160; <span class="comment">// [6, 7, 1, 3, 8, 2, 4] return 19</span></div>
<div class="line"><a name="l00079"></a><span class="lineno"> 79</span>&#160; <a class="codeRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector&lt;uint32_t&gt;</a> array2 = {6, 7, 1, 3, 8, 2, 4};</div>
<div class="line"><a name="l00080"></a><span class="lineno"> 80</span>&#160; <a class="codeRef" 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 name="l00081"></a><span class="lineno"> 81</span>&#160; assert(</div>
<div class="line"><a name="l00082"></a><span class="lineno"> 82</span>&#160; dynamic_programming::house_robber::houseRobber(array2, array2.<a class="codeRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector/size.html">size</a>()) ==</div>
<div class="line"><a name="l00083"></a><span class="lineno"> 83</span>&#160; 19); <span class="comment">// here the four non-adjacent houses that are robbed are first,</span></div>
<div class="line"><a name="l00084"></a><span class="lineno"> 84</span>&#160; <span class="comment">// third, fifth and seventh with total sum money as 19</span></div>
<div class="line"><a name="l00085"></a><span class="lineno"> 85</span>&#160; <a class="codeRef" 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="codeRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/manip/endl.html">std::endl</a>;</div>
<div class="line"><a name="l00086"></a><span class="lineno"> 86</span>&#160; </div>
<div class="line"><a name="l00087"></a><span class="lineno"> 87</span>&#160; <span class="comment">// Test 3</span></div>
<div class="line"><a name="l00088"></a><span class="lineno"> 88</span>&#160; <span class="comment">// [] return 0</span></div>
<div class="line"><a name="l00089"></a><span class="lineno"> 89</span>&#160; <a class="codeRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector&lt;uint32_t&gt;</a> array3 = {};</div>
<div class="line"><a name="l00090"></a><span class="lineno"> 90</span>&#160; <a class="codeRef" 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 name="l00091"></a><span class="lineno"> 91</span>&#160; assert(</div>
<div class="line"><a name="l00092"></a><span class="lineno"> 92</span>&#160; dynamic_programming::house_robber::houseRobber(array3, array3.<a class="codeRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector/size.html">size</a>()) ==</div>
<div class="line"><a name="l00093"></a><span class="lineno"> 93</span>&#160; 0); <span class="comment">// since there is no house no money can be robbed</span></div>
<div class="line"><a name="l00094"></a><span class="lineno"> 94</span>&#160; <a class="codeRef" 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="codeRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/manip/endl.html">std::endl</a>;</div>
<div class="line"><a name="l00095"></a><span class="lineno"> 95</span>&#160; </div>
<div class="line"><a name="l00096"></a><span class="lineno"> 96</span>&#160; <span class="comment">// Test 4</span></div>
<div class="line"><a name="l00097"></a><span class="lineno"> 97</span>&#160; <span class="comment">// [2,7,9,3,1] return 12</span></div>
<div class="line"><a name="l00098"></a><span class="lineno"> 98</span>&#160; <a class="codeRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector&lt;uint32_t&gt;</a> array4 = {2, 7, 9, 3, 1};</div>
<div class="line"><a name="l00099"></a><span class="lineno"> 99</span>&#160; <a class="codeRef" 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 name="l00100"></a><span class="lineno"> 100</span>&#160; assert(</div>
<div class="line"><a name="l00101"></a><span class="lineno"> 101</span>&#160; dynamic_programming::house_robber::houseRobber(array4, array4.<a class="codeRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector/size.html">size</a>()) ==</div>
<div class="line"><a name="l00102"></a><span class="lineno"> 102</span>&#160; 12); <span class="comment">// here the three non-adjacent houses that are robbed are first,</span></div>
<div class="line"><a name="l00103"></a><span class="lineno"> 103</span>&#160; <span class="comment">// third and fifth with total sum money as 12</span></div>
<div class="line"><a name="l00104"></a><span class="lineno"> 104</span>&#160; <a class="codeRef" 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="codeRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/manip/endl.html">std::endl</a>;</div>
<div class="line"><a name="l00105"></a><span class="lineno"> 105</span>&#160;}</div>
<div class="fragment"><div class="line"><a id="l00066" name="l00066"></a><span class="lineno"> 66</span> {</div>
<div class="line"><a id="l00067" name="l00067"></a><span class="lineno"> 67</span> <span class="comment">// Test 1</span></div>
<div class="line"><a id="l00068" name="l00068"></a><span class="lineno"> 68</span> <span class="comment">// [1, 2, 3, 1] return 4</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;uint32_t&gt;</a> array1 = {1, 2, 3, 1};</div>
<div class="line"><a id="l00070" name="l00070"></a><span class="lineno"> 70</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="l00071" name="l00071"></a><span class="lineno"> 71</span> assert(</div>
<div class="line"><a id="l00072" name="l00072"></a><span class="lineno"> 72</span> dynamic_programming::house_robber::houseRobber(array1, array1.<a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector/size.html">size</a>()) ==</div>
<div class="line"><a id="l00073" name="l00073"></a><span class="lineno"> 73</span> 4); <span class="comment">// here the two non-adjacent houses that are robbed are first and</span></div>
<div class="line"><a id="l00074" name="l00074"></a><span class="lineno"> 74</span> <span class="comment">// third with total sum money as 4</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_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="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="comment">// Test 2</span></div>
<div class="line"><a id="l00078" name="l00078"></a><span class="lineno"> 78</span> <span class="comment">// [6, 7, 1, 3, 8, 2, 4] return 19</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;uint32_t&gt;</a> array2 = {6, 7, 1, 3, 8, 2, 4};</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 2... &quot;</span>;</div>
<div class="line"><a id="l00081" name="l00081"></a><span class="lineno"> 81</span> assert(</div>
<div class="line"><a id="l00082" name="l00082"></a><span class="lineno"> 82</span> dynamic_programming::house_robber::houseRobber(array2, array2.<a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector/size.html">size</a>()) ==</div>
<div class="line"><a id="l00083" name="l00083"></a><span class="lineno"> 83</span> 19); <span class="comment">// here the four non-adjacent houses that are robbed are first,</span></div>
<div class="line"><a id="l00084" name="l00084"></a><span class="lineno"> 84</span> <span class="comment">// third, fifth and seventh with total sum money as 19</span></div>
<div class="line"><a id="l00085" name="l00085"></a><span class="lineno"> 85</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="l00086" name="l00086"></a><span class="lineno"> 86</span> </div>
<div class="line"><a id="l00087" name="l00087"></a><span class="lineno"> 87</span> <span class="comment">// Test 3</span></div>
<div class="line"><a id="l00088" name="l00088"></a><span class="lineno"> 88</span> <span class="comment">// [] return 0</span></div>
<div class="line"><a id="l00089" name="l00089"></a><span class="lineno"> 89</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector&lt;uint32_t&gt;</a> array3 = {};</div>
<div class="line"><a id="l00090" name="l00090"></a><span class="lineno"> 90</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="l00091" name="l00091"></a><span class="lineno"> 91</span> assert(</div>
<div class="line"><a id="l00092" name="l00092"></a><span class="lineno"> 92</span> dynamic_programming::house_robber::houseRobber(array3, array3.<a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector/size.html">size</a>()) ==</div>
<div class="line"><a id="l00093" name="l00093"></a><span class="lineno"> 93</span> 0); <span class="comment">// since there is no house no money can be robbed</span></div>
<div class="line"><a id="l00094" name="l00094"></a><span class="lineno"> 94</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="l00095" name="l00095"></a><span class="lineno"> 95</span> </div>
<div class="line"><a id="l00096" name="l00096"></a><span class="lineno"> 96</span> <span class="comment">// Test 4</span></div>
<div class="line"><a id="l00097" name="l00097"></a><span class="lineno"> 97</span> <span class="comment">// [2,7,9,3,1] return 12</span></div>
<div class="line"><a id="l00098" name="l00098"></a><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;uint32_t&gt;</a> array4 = {2, 7, 9, 3, 1};</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/io/basic_ostream.html">std::cout</a> &lt;&lt; <span class="stringliteral">&quot;Test 4... &quot;</span>;</div>
<div class="line"><a id="l00100" name="l00100"></a><span class="lineno"> 100</span> assert(</div>
<div class="line"><a id="l00101" name="l00101"></a><span class="lineno"> 101</span> dynamic_programming::house_robber::houseRobber(array4, array4.<a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector/size.html">size</a>()) ==</div>
<div class="line"><a id="l00102" name="l00102"></a><span class="lineno"> 102</span> 12); <span class="comment">// here the three non-adjacent houses that are robbed are first,</span></div>
<div class="line"><a id="l00103" name="l00103"></a><span class="lineno"> 103</span> <span class="comment">// third and fifth with total sum money as 12</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;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="l00105" name="l00105"></a><span class="lineno"> 105</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="asize_html"><div class="ttname"><a href="http://en.cppreference.com/w/cpp/container/vector/size.html">std::vector::size</a></div><div class="ttdeci">T size(T... args)</div></div>
@@ -319,7 +318,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="../../d6/d26/house__robber_8cpp.html">house_robber.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.1 </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>
</ul>
</div>
</body>

View File

@@ -1,7 +1,7 @@
<?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.48.0 (20210717.1556)
<!-- Generated by graphviz version 2.49.0 (20210828.1703)
-->
<!-- Title: dynamic_programming::house_robber::houseRobber Pages: 1 -->
<svg width="247pt" height="57pt"

Before

Width:  |  Height:  |  Size: 2.2 KiB

After

Width:  |  Height:  |  Size: 2.2 KiB

View File

@@ -1,7 +1,7 @@
<?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.48.0 (20210717.1556)
<!-- Generated by graphviz version 2.49.0 (20210828.1703)
-->
<!-- Title: test Pages: 1 -->
<svg width="163pt" height="66pt"

Before

Width:  |  Height:  |  Size: 2.3 KiB

After

Width:  |  Height:  |  Size: 2.3 KiB

View File

@@ -1,7 +1,7 @@
<?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.48.0 (20210717.1556)
<!-- Generated by graphviz version 2.49.0 (20210828.1703)
-->
<!-- Title: main Pages: 1 -->
<svg width="237pt" height="66pt"

Before

Width:  |  Height:  |  Size: 3.1 KiB

After

Width:  |  Height:  |  Size: 3.1 KiB