Project-4/docs/utils_8hpp_source.html
2023-12-05 19:32:43 +01:00

168 lines
14 KiB
HTML

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=11"/>
<meta name="generator" content="Doxygen 1.9.6"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>2 Dimensional Ising Model: include/utils.hpp Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<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"],
jax: ["input/TeX","output/HTML-CSS"],
});
</script>
<script type="text/javascript" async="async" src="https://cdn.jsdelivr.net/npm/mathjax@2/MathJax.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
<link href="doxygen-awesome.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
<tbody>
<tr id="projectrow">
<td id="projectalign">
<div id="projectname">2 Dimensional Ising Model
</div>
<div id="projectbrief">Simulate the change in energy and magnetization in a ferro magnet</div>
</td>
</tr>
</tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.9.6 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
var searchBox = new SearchBox("searchBox", "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:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(function() {
initMenu('',true,false,'search.php','Search');
$(document).ready(function() { init_search(); });
});
/* @license-end */
</script>
<div id="main-nav"></div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
<div id="nav-tree">
<div id="nav-tree-contents">
<div id="nav-sync" class="sync"></div>
</div>
</div>
<div id="splitbar" style="-moz-user-select:none;"
class="ui-resizable-handle">
</div>
</div>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(document).ready(function(){initNavTree('utils_8hpp_source.html',''); initResizable(); });
/* @license-end */
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
onmouseover="return searchBox.OnSearchSelectShow()"
onmouseout="return searchBox.OnSearchSelectHide()"
onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>
<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<div id="MSearchResults">
<div class="SRPage">
<div id="SRIndex">
<div id="SRResults"></div>
<div class="SRStatus" id="Loading">Loading...</div>
<div class="SRStatus" id="Searching">Searching...</div>
<div class="SRStatus" id="NoMatches">No Matches</div>
</div>
</div>
</div>
</div>
<div class="header">
<div class="headertitle"><div class="title">utils.hpp</div></div>
</div><!--header-->
<div class="contents">
<a href="utils_8hpp.html">Go to the documentation of this file.</a><div class="fragment"><div class="line"><a id="l00001" name="l00001"></a><span class="lineno"> 1</span> </div>
<div class="line"><a id="l00017" name="l00017"></a><span class="lineno"> 17</span><span class="preprocessor">#ifndef __UTILS__</span></div>
<div class="line"><a id="l00018" name="l00018"></a><span class="lineno"> 18</span><span class="preprocessor">#define __UTILS__</span></div>
<div class="line"><a id="l00019" name="l00019"></a><span class="lineno"> 19</span> </div>
<div class="line"><a id="l00020" name="l00020"></a><span class="lineno"> 20</span><span class="preprocessor">#include &lt;armadillo&gt;</span></div>
<div class="line"><a id="l00021" name="l00021"></a><span class="lineno"> 21</span><span class="preprocessor">#include &lt;iomanip&gt;</span></div>
<div class="line"><a id="l00022" name="l00022"></a><span class="lineno"> 22</span><span class="preprocessor">#include &lt;sstream&gt;</span></div>
<div class="line"><a id="l00023" name="l00023"></a><span class="lineno"> 23</span><span class="preprocessor">#include &lt;string&gt;</span></div>
<div class="line"><a id="l00024" name="l00024"></a><span class="lineno"> 24</span><span class="preprocessor">#include &lt;sys/stat.h&gt;</span></div>
<div class="line"><a id="l00025" name="l00025"></a><span class="lineno"> 25</span><span class="preprocessor">#include &lt;vector&gt;</span></div>
<div class="line"><a id="l00026" name="l00026"></a><span class="lineno"> 26</span> </div>
<div class="line"><a id="l00035" name="l00035"></a><span class="lineno"> 35</span><span class="preprocessor">#ifdef DBG</span></div>
<div class="line"><a id="l00036" name="l00036"></a><span class="lineno"> 36</span><span class="preprocessor">#define DEBUG(msg) \</span></div>
<div class="line"><a id="l00037" name="l00037"></a><span class="lineno"> 37</span><span class="preprocessor"> std::cout &lt;&lt; __FILE__ &lt;&lt; &quot; &quot;</span> &lt;&lt; __LINE__ &lt;&lt; &quot;: &quot; &lt;&lt; msg &lt;&lt; std::endl</div>
<div class="line"><a id="l00038" name="l00038"></a><span class="lineno"> 38</span><span class="preprocessor">#else</span></div>
<div class="line"><a id="l00039" name="l00039"></a><span class="lineno"><a class="line" href="utils_8hpp.html#aecc1f7a8a2493b9e021e5bff76a00a5b"> 39</a></span><span class="preprocessor">#define DEBUG(msg)</span></div>
<div class="line"><a id="l00040" name="l00040"></a><span class="lineno"> 40</span><span class="preprocessor">#endif</span></div>
<div class="line"><a id="l00041" name="l00041"></a><span class="lineno"> 41</span> </div>
<div class="line"><a id="l00045" name="l00045"></a><span class="lineno"><a class="line" href="utils_8hpp.html#a60dca3177fb9cb5256609adc7af55168"> 45</a></span><span class="preprocessor">#define __METHOD_NAME__ details::methodName(__PRETTY_FUNCTION__)</span></div>
<div class="line"><a id="l00046" name="l00046"></a><span class="lineno"> 46</span> </div>
<div class="line"><a id="l00047" name="l00047"></a><span class="lineno"> 47</span><span class="keyword">namespace </span>details {</div>
<div class="line"><a id="l00058" name="l00058"></a><span class="lineno"><a class="line" href="utils_8hpp.html#a178c4922157666a6e9c127c2ffd96346"> 58</a></span><span class="keyword">inline</span> std::string <a class="code hl_function" href="utils_8hpp.html#a178c4922157666a6e9c127c2ffd96346">methodName</a>(<span class="keyword">const</span> std::string &amp;pretty_function)</div>
<div class="line"><a id="l00059" name="l00059"></a><span class="lineno"> 59</span>{</div>
<div class="line"><a id="l00060" name="l00060"></a><span class="lineno"> 60</span> <span class="keywordtype">size_t</span> colons = pretty_function.find(<span class="stringliteral">&quot;::&quot;</span>);</div>
<div class="line"><a id="l00061" name="l00061"></a><span class="lineno"> 61</span> <span class="keywordtype">size_t</span> begin = pretty_function.substr(0, colons).rfind(<span class="stringliteral">&quot; &quot;</span>) + 1;</div>
<div class="line"><a id="l00062" name="l00062"></a><span class="lineno"> 62</span> <span class="keywordtype">size_t</span> end = pretty_function.rfind(<span class="stringliteral">&quot;(&quot;</span>) - begin;</div>
<div class="line"><a id="l00063" name="l00063"></a><span class="lineno"> 63</span> </div>
<div class="line"><a id="l00064" name="l00064"></a><span class="lineno"> 64</span> <span class="keywordflow">return</span> pretty_function.substr(begin, end) + <span class="stringliteral">&quot;()&quot;</span>;</div>
<div class="line"><a id="l00065" name="l00065"></a><span class="lineno"> 65</span>}</div>
<div class="line"><a id="l00066" name="l00066"></a><span class="lineno"> 66</span> </div>
<div class="line"><a id="l00067" name="l00067"></a><span class="lineno"> 67</span>} <span class="comment">// namespace details</span></div>
<div class="line"><a id="l00068" name="l00068"></a><span class="lineno"> 68</span> </div>
<div class="line"><a id="l00069" name="l00069"></a><span class="lineno"> 69</span><span class="keyword">namespace </span>utils {</div>
<div class="line"><a id="l00070" name="l00070"></a><span class="lineno"> 70</span> </div>
<div class="line"><a id="l00081" name="l00081"></a><span class="lineno"> 81</span>std::string <a class="code hl_function" href="utils_8hpp.html#a3529a74fd2a25d24de73d9d4e1c90835">scientific_format</a>(<span class="keywordtype">double</span> d, <span class="keywordtype">int</span> width = 20, <span class="keywordtype">int</span> prec = 10);</div>
<div class="line"><a id="l00082" name="l00082"></a><span class="lineno"> 82</span> </div>
<div class="line"><a id="l00094" name="l00094"></a><span class="lineno"> 94</span>std::string <a class="code hl_function" href="utils_8hpp.html#a3529a74fd2a25d24de73d9d4e1c90835">scientific_format</a>(<span class="keyword">const</span> std::vector&lt;double&gt; &amp;v, <span class="keywordtype">int</span> width = 20,</div>
<div class="line"><a id="l00095" name="l00095"></a><span class="lineno"> 95</span> <span class="keywordtype">int</span> prec = 10);</div>
<div class="line"><a id="l00096" name="l00096"></a><span class="lineno"> 96</span> </div>
<div class="line"><a id="l00107" name="l00107"></a><span class="lineno"> 107</span><span class="keywordtype">bool</span> <a class="code hl_function" href="utils_8hpp.html#a2b45adc86b70f42021582994e83fa00d">mkpath</a>(std::string path, <span class="keywordtype">int</span> mode = 0777);</div>
<div class="line"><a id="l00108" name="l00108"></a><span class="lineno"> 108</span> </div>
<div class="line"><a id="l00115" name="l00115"></a><span class="lineno"> 115</span>std::string <a class="code hl_function" href="utils_8hpp.html#aed026119193a9bbe076671809ff0f430">dirname</a>(<span class="keyword">const</span> std::string &amp;path);</div>
<div class="line"><a id="l00116" name="l00116"></a><span class="lineno"> 116</span> </div>
<div class="line"><a id="l00130" name="l00130"></a><span class="lineno"> 130</span>std::string <a class="code hl_function" href="utils_8hpp.html#ae91fad89394d745d544737e43524bde6">concatpath</a>(<span class="keyword">const</span> std::string &amp;left, <span class="keyword">const</span> std::string &amp;right);</div>
<div class="line"><a id="l00131" name="l00131"></a><span class="lineno"> 131</span> </div>
<div class="line"><a id="l00132" name="l00132"></a><span class="lineno"> 132</span>} <span class="comment">// namespace utils</span></div>
<div class="line"><a id="l00133" name="l00133"></a><span class="lineno"> 133</span> </div>
<div class="line"><a id="l00134" name="l00134"></a><span class="lineno"> 134</span><span class="preprocessor">#endif</span></div>
<div class="ttc" id="autils_8hpp_html_a178c4922157666a6e9c127c2ffd96346"><div class="ttname"><a href="utils_8hpp.html#a178c4922157666a6e9c127c2ffd96346">details::methodName</a></div><div class="ttdeci">std::string methodName(const std::string &amp;pretty_function)</div><div class="ttdoc">Takes in the PRETTY_FUNCTION string and removes the return type.</div><div class="ttdef"><b>Definition:</b> <a href="utils_8hpp_source.html#l00058">utils.hpp:58</a></div></div>
<div class="ttc" id="autils_8hpp_html_a2b45adc86b70f42021582994e83fa00d"><div class="ttname"><a href="utils_8hpp.html#a2b45adc86b70f42021582994e83fa00d">utils::mkpath</a></div><div class="ttdeci">bool mkpath(std::string path, int mode=0777)</div><div class="ttdoc">Make path given.</div><div class="ttdef"><b>Definition:</b> <a href="utils_8cpp_source.html#l00032">utils.cpp:32</a></div></div>
<div class="ttc" id="autils_8hpp_html_a3529a74fd2a25d24de73d9d4e1c90835"><div class="ttname"><a href="utils_8hpp.html#a3529a74fd2a25d24de73d9d4e1c90835">utils::scientific_format</a></div><div class="ttdeci">std::string scientific_format(double d, int width=20, int prec=10)</div><div class="ttdoc">Turns a double into a string written in scientific format.</div><div class="ttdef"><b>Definition:</b> <a href="utils_8cpp_source.html#l00016">utils.cpp:16</a></div></div>
<div class="ttc" id="autils_8hpp_html_ae91fad89394d745d544737e43524bde6"><div class="ttname"><a href="utils_8hpp.html#ae91fad89394d745d544737e43524bde6">utils::concatpath</a></div><div class="ttdeci">std::string concatpath(const std::string &amp;left, const std::string &amp;right)</div><div class="ttdoc">Take 2 strings and concatenate them and make sure there is a directory separator (/) between them.</div><div class="ttdef"><b>Definition:</b> <a href="utils_8cpp_source.html#l00063">utils.cpp:63</a></div></div>
<div class="ttc" id="autils_8hpp_html_aed026119193a9bbe076671809ff0f430"><div class="ttname"><a href="utils_8hpp.html#aed026119193a9bbe076671809ff0f430">utils::dirname</a></div><div class="ttdeci">std::string dirname(const std::string &amp;path)</div><div class="ttdoc">Get the directory name of the path.</div><div class="ttdef"><b>Definition:</b> <a href="utils_8cpp_source.html#l00058">utils.cpp:58</a></div></div>
</div><!-- fragment --></div><!-- contents -->
</div><!-- doc-content -->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
<ul>
<li class="navelem"><a class="el" href="dir_d44c64559bbebec7f509842c48db8b23.html">include</a></li><li class="navelem"><a class="el" href="utils_8hpp.html">utils.hpp</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.6 </li>
</ul>
</div>
</body>
</html>