405 lines
18 KiB
HTML
405 lines
18 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>Penning Trap Simulation: src/utils.cpp File Reference</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">Penning Trap Simulation
|
|
</div>
|
|
<div id="projectbrief">Simulate particle behavior inside a Penning Trap</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&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&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&dn=expat.txt MIT */
|
|
$(document).ready(function(){initNavTree('utils_8cpp.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="summary">
|
|
<a href="#func-members">Functions</a> </div>
|
|
<div class="headertitle"><div class="title">utils.cpp File Reference</div></div>
|
|
</div><!--header-->
|
|
<div class="contents">
|
|
|
|
<p>Implementation of the utils.
|
|
<a href="#details">More...</a></p>
|
|
<div class="textblock"><code>#include "<a class="el" href="utils_8hpp_source.html">utils.hpp</a>"</code><br />
|
|
</div>
|
|
<p><a href="utils_8cpp_source.html">Go to the source code of this file.</a></p>
|
|
<table class="memberdecls">
|
|
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="func-members" name="func-members"></a>
|
|
Functions</h2></td></tr>
|
|
<tr class="memitem:acd2a9c7a7d5a7fe9163be8c4cc110746"><td class="memItemLeft" align="right" valign="top">std::string </td><td class="memItemRight" valign="bottom"><a class="el" href="utils_8cpp.html#acd2a9c7a7d5a7fe9163be8c4cc110746">scientific_format</a> (double d, int width, int prec)</td></tr>
|
|
<tr class="memdesc:acd2a9c7a7d5a7fe9163be8c4cc110746"><td class="mdescLeft"> </td><td class="mdescRight">Turns a double into a string written in scientific format. <br /></td></tr>
|
|
<tr class="separator:acd2a9c7a7d5a7fe9163be8c4cc110746"><td class="memSeparator" colspan="2"> </td></tr>
|
|
<tr class="memitem:a58565270b643b24e3132f38c653e0199"><td class="memItemLeft" align="right" valign="top">std::string </td><td class="memItemRight" valign="bottom"><a class="el" href="utils_8cpp.html#a58565270b643b24e3132f38c653e0199">scientific_format</a> (const std::vector< double > &v, int width, int prec)</td></tr>
|
|
<tr class="memdesc:a58565270b643b24e3132f38c653e0199"><td class="mdescLeft"> </td><td class="mdescRight">Turns a vector of doubles into a string written in scientific format. <br /></td></tr>
|
|
<tr class="separator:a58565270b643b24e3132f38c653e0199"><td class="memSeparator" colspan="2"> </td></tr>
|
|
<tr class="memitem:aff5e07c3c1d321709b0cc38e999f427b"><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="utils_8cpp.html#aff5e07c3c1d321709b0cc38e999f427b">m_assert</a> (bool expr, std::string expr_str, std::string f, std::string file, int line, std::string msg)</td></tr>
|
|
<tr class="memdesc:aff5e07c3c1d321709b0cc38e999f427b"><td class="mdescLeft"> </td><td class="mdescRight">Test an expression, confirm that test is ok, or abort execution. <br /></td></tr>
|
|
<tr class="separator:aff5e07c3c1d321709b0cc38e999f427b"><td class="memSeparator" colspan="2"> </td></tr>
|
|
<tr class="memitem:a6be6f938bcbb235ebb6a2ed9d08411b2"><td class="memItemLeft" align="right" valign="top">bool </td><td class="memItemRight" valign="bottom"><a class="el" href="utils_8cpp.html#a6be6f938bcbb235ebb6a2ed9d08411b2">close_to</a> (arma::vec &a, arma::vec &b, double tol)</td></tr>
|
|
<tr class="memdesc:a6be6f938bcbb235ebb6a2ed9d08411b2"><td class="mdescLeft"> </td><td class="mdescRight">Test if two armadillo vectors are close to each other. <br /></td></tr>
|
|
<tr class="separator:a6be6f938bcbb235ebb6a2ed9d08411b2"><td class="memSeparator" colspan="2"> </td></tr>
|
|
<tr class="memitem:acf13f4e492199cb7231bfa646dbd08de"><td class="memItemLeft" align="right" valign="top">bool </td><td class="memItemRight" valign="bottom"><a class="el" href="utils_8cpp.html#acf13f4e492199cb7231bfa646dbd08de">mkpath</a> (std::string path, int mode)</td></tr>
|
|
<tr class="memdesc:acf13f4e492199cb7231bfa646dbd08de"><td class="mdescLeft"> </td><td class="mdescRight">Make path given. <br /></td></tr>
|
|
<tr class="separator:acf13f4e492199cb7231bfa646dbd08de"><td class="memSeparator" colspan="2"> </td></tr>
|
|
</table>
|
|
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
|
|
<div class="textblock"><p>Implementation of the utils. </p>
|
|
<dl class="section author"><dt>Author</dt><dd>Cory Alexander Balaton (coryab) </dd>
|
|
<dd>
|
|
Janita Ovidie Sandtrøen Willumsen (janitaws)</dd></dl>
|
|
<dl class="section version"><dt>Version</dt><dd>1.0</dd></dl>
|
|
<dl class="bug"><dt><b><a class="el" href="bug.html#_bug000011">Bug:</a></b></dt><dd>No known bugs </dd></dl>
|
|
|
|
<p class="definition">Definition in file <a class="el" href="utils_8cpp_source.html">utils.cpp</a>.</p>
|
|
</div><h2 class="groupheader">Function Documentation</h2>
|
|
<a id="a6be6f938bcbb235ebb6a2ed9d08411b2" name="a6be6f938bcbb235ebb6a2ed9d08411b2"></a>
|
|
<h2 class="memtitle"><span class="permalink"><a href="#a6be6f938bcbb235ebb6a2ed9d08411b2">◆ </a></span>close_to()</h2>
|
|
|
|
<div class="memitem">
|
|
<div class="memproto">
|
|
<table class="memname">
|
|
<tr>
|
|
<td class="memname">bool close_to </td>
|
|
<td>(</td>
|
|
<td class="paramtype">arma::vec & </td>
|
|
<td class="paramname"><em>a</em>, </td>
|
|
</tr>
|
|
<tr>
|
|
<td class="paramkey"></td>
|
|
<td></td>
|
|
<td class="paramtype">arma::vec & </td>
|
|
<td class="paramname"><em>b</em>, </td>
|
|
</tr>
|
|
<tr>
|
|
<td class="paramkey"></td>
|
|
<td></td>
|
|
<td class="paramtype">double </td>
|
|
<td class="paramname"><em>tol</em> = <code>1e-8</code> </td>
|
|
</tr>
|
|
<tr>
|
|
<td></td>
|
|
<td>)</td>
|
|
<td></td><td></td>
|
|
</tr>
|
|
</table>
|
|
</div><div class="memdoc">
|
|
|
|
<p>Test if two armadillo vectors are close to each other. </p>
|
|
<p>This function takes in 2 vectors and checks if they are approximately equal to each other given a tolerance.</p>
|
|
<dl class="params"><dt>Parameters</dt><dd>
|
|
<table class="params">
|
|
<tr><td class="paramname">a</td><td>Vector a </td></tr>
|
|
<tr><td class="paramname">b</td><td>Vector b </td></tr>
|
|
<tr><td class="paramname">tol</td><td>The tolerance</td></tr>
|
|
</table>
|
|
</dd>
|
|
</dl>
|
|
<dl class="section return"><dt>Returns</dt><dd>bool </dd></dl>
|
|
|
|
<p class="definition">Definition at line <a class="el" href="utils_8cpp_source.html#l00058">58</a> of file <a class="el" href="utils_8cpp_source.html">utils.cpp</a>.</p>
|
|
|
|
</div>
|
|
</div>
|
|
<a id="aff5e07c3c1d321709b0cc38e999f427b" name="aff5e07c3c1d321709b0cc38e999f427b"></a>
|
|
<h2 class="memtitle"><span class="permalink"><a href="#aff5e07c3c1d321709b0cc38e999f427b">◆ </a></span>m_assert()</h2>
|
|
|
|
<div class="memitem">
|
|
<div class="memproto">
|
|
<table class="memname">
|
|
<tr>
|
|
<td class="memname">void m_assert </td>
|
|
<td>(</td>
|
|
<td class="paramtype">bool </td>
|
|
<td class="paramname"><em>expr</em>, </td>
|
|
</tr>
|
|
<tr>
|
|
<td class="paramkey"></td>
|
|
<td></td>
|
|
<td class="paramtype">std::string </td>
|
|
<td class="paramname"><em>expr_str</em>, </td>
|
|
</tr>
|
|
<tr>
|
|
<td class="paramkey"></td>
|
|
<td></td>
|
|
<td class="paramtype">std::string </td>
|
|
<td class="paramname"><em>func</em>, </td>
|
|
</tr>
|
|
<tr>
|
|
<td class="paramkey"></td>
|
|
<td></td>
|
|
<td class="paramtype">std::string </td>
|
|
<td class="paramname"><em>file</em>, </td>
|
|
</tr>
|
|
<tr>
|
|
<td class="paramkey"></td>
|
|
<td></td>
|
|
<td class="paramtype">int </td>
|
|
<td class="paramname"><em>line</em>, </td>
|
|
</tr>
|
|
<tr>
|
|
<td class="paramkey"></td>
|
|
<td></td>
|
|
<td class="paramtype">std::string </td>
|
|
<td class="paramname"><em>msg</em> </td>
|
|
</tr>
|
|
<tr>
|
|
<td></td>
|
|
<td>)</td>
|
|
<td></td><td></td>
|
|
</tr>
|
|
</table>
|
|
</div><div class="memdoc">
|
|
|
|
<p>Test an expression, confirm that test is ok, or abort execution. </p>
|
|
<p>This function takes in an expression and prints an OK message if it's true, or it prints a fail message and aborts execution if it fails.</p>
|
|
<dl class="params"><dt>Parameters</dt><dd>
|
|
<table class="params">
|
|
<tr><td class="paramname">expr</td><td>The expression to be evaluated </td></tr>
|
|
<tr><td class="paramname">expr_str</td><td>The stringified version of the expression </td></tr>
|
|
<tr><td class="paramname">func</td><td>The function name of the caller </td></tr>
|
|
<tr><td class="paramname">file</td><td>The file of the caller </td></tr>
|
|
<tr><td class="paramname">line</td><td>The line number where this function is called from </td></tr>
|
|
<tr><td class="paramname">msg</td><td>The message to be displayed </td></tr>
|
|
</table>
|
|
</dd>
|
|
</dl>
|
|
|
|
<p class="definition">Definition at line <a class="el" href="utils_8cpp_source.html#l00040">40</a> of file <a class="el" href="utils_8cpp_source.html">utils.cpp</a>.</p>
|
|
|
|
</div>
|
|
</div>
|
|
<a id="acf13f4e492199cb7231bfa646dbd08de" name="acf13f4e492199cb7231bfa646dbd08de"></a>
|
|
<h2 class="memtitle"><span class="permalink"><a href="#acf13f4e492199cb7231bfa646dbd08de">◆ </a></span>mkpath()</h2>
|
|
|
|
<div class="memitem">
|
|
<div class="memproto">
|
|
<table class="memname">
|
|
<tr>
|
|
<td class="memname">bool mkpath </td>
|
|
<td>(</td>
|
|
<td class="paramtype">std::string </td>
|
|
<td class="paramname"><em>path</em>, </td>
|
|
</tr>
|
|
<tr>
|
|
<td class="paramkey"></td>
|
|
<td></td>
|
|
<td class="paramtype">int </td>
|
|
<td class="paramname"><em>mode</em> = <code>0777</code> </td>
|
|
</tr>
|
|
<tr>
|
|
<td></td>
|
|
<td>)</td>
|
|
<td></td><td></td>
|
|
</tr>
|
|
</table>
|
|
</div><div class="memdoc">
|
|
|
|
<p>Make path given. </p>
|
|
<p>This tries to be the equivalent to "mkdir -p" and creates a new directory whenever it needs to.</p>
|
|
<dl class="params"><dt>Parameters</dt><dd>
|
|
<table class="params">
|
|
<tr><td class="paramname">path</td><td>The path to be created </td></tr>
|
|
<tr><td class="paramname">mode</td><td>The mode/permissions for all the new directories</td></tr>
|
|
</table>
|
|
</dd>
|
|
</dl>
|
|
<dl class="section return"><dt>Returns</dt><dd>bool Success/Fail </dd></dl>
|
|
|
|
<p class="definition">Definition at line <a class="el" href="utils_8cpp_source.html#l00072">72</a> of file <a class="el" href="utils_8cpp_source.html">utils.cpp</a>.</p>
|
|
|
|
</div>
|
|
</div>
|
|
<a id="a58565270b643b24e3132f38c653e0199" name="a58565270b643b24e3132f38c653e0199"></a>
|
|
<h2 class="memtitle"><span class="permalink"><a href="#a58565270b643b24e3132f38c653e0199">◆ </a></span>scientific_format() <span class="overload">[1/2]</span></h2>
|
|
|
|
<div class="memitem">
|
|
<div class="memproto">
|
|
<table class="memname">
|
|
<tr>
|
|
<td class="memname">std::string scientific_format </td>
|
|
<td>(</td>
|
|
<td class="paramtype">const std::vector< double > & </td>
|
|
<td class="paramname"><em>v</em>, </td>
|
|
</tr>
|
|
<tr>
|
|
<td class="paramkey"></td>
|
|
<td></td>
|
|
<td class="paramtype">int </td>
|
|
<td class="paramname"><em>width</em> = <code>20</code>, </td>
|
|
</tr>
|
|
<tr>
|
|
<td class="paramkey"></td>
|
|
<td></td>
|
|
<td class="paramtype">int </td>
|
|
<td class="paramname"><em>prec</em> = <code>10</code> </td>
|
|
</tr>
|
|
<tr>
|
|
<td></td>
|
|
<td>)</td>
|
|
<td></td><td></td>
|
|
</tr>
|
|
</table>
|
|
</div><div class="memdoc">
|
|
|
|
<p>Turns a vector of doubles into a string written in scientific format. </p>
|
|
<p>The code is stolen from <a href="https://github.com/anderkve/FYS3150">https://github.com/anderkve/FYS3150</a>.</p>
|
|
<dl class="params"><dt>Parameters</dt><dd>
|
|
<table class="params">
|
|
<tr><td class="paramname">v</td><td>The vector to stringify </td></tr>
|
|
<tr><td class="paramname">width</td><td>The reserved width of the string </td></tr>
|
|
<tr><td class="paramname">prec</td><td>The precision of the stringified number</td></tr>
|
|
</table>
|
|
</dd>
|
|
</dl>
|
|
<dl class="section return"><dt>Returns</dt><dd>std::string </dd></dl>
|
|
|
|
<p class="definition">Definition at line <a class="el" href="utils_8cpp_source.html#l00022">22</a> of file <a class="el" href="utils_8cpp_source.html">utils.cpp</a>.</p>
|
|
|
|
</div>
|
|
</div>
|
|
<a id="acd2a9c7a7d5a7fe9163be8c4cc110746" name="acd2a9c7a7d5a7fe9163be8c4cc110746"></a>
|
|
<h2 class="memtitle"><span class="permalink"><a href="#acd2a9c7a7d5a7fe9163be8c4cc110746">◆ </a></span>scientific_format() <span class="overload">[2/2]</span></h2>
|
|
|
|
<div class="memitem">
|
|
<div class="memproto">
|
|
<table class="memname">
|
|
<tr>
|
|
<td class="memname">std::string scientific_format </td>
|
|
<td>(</td>
|
|
<td class="paramtype">double </td>
|
|
<td class="paramname"><em>d</em>, </td>
|
|
</tr>
|
|
<tr>
|
|
<td class="paramkey"></td>
|
|
<td></td>
|
|
<td class="paramtype">int </td>
|
|
<td class="paramname"><em>width</em> = <code>20</code>, </td>
|
|
</tr>
|
|
<tr>
|
|
<td class="paramkey"></td>
|
|
<td></td>
|
|
<td class="paramtype">int </td>
|
|
<td class="paramname"><em>prec</em> = <code>10</code> </td>
|
|
</tr>
|
|
<tr>
|
|
<td></td>
|
|
<td>)</td>
|
|
<td></td><td></td>
|
|
</tr>
|
|
</table>
|
|
</div><div class="memdoc">
|
|
|
|
<p>Turns a double into a string written in scientific format. </p>
|
|
<p>The code is stolen from <a href="https://github.com/anderkve/FYS3150">https://github.com/anderkve/FYS3150</a>.</p>
|
|
<dl class="params"><dt>Parameters</dt><dd>
|
|
<table class="params">
|
|
<tr><td class="paramname">d</td><td>The number to stringify </td></tr>
|
|
<tr><td class="paramname">width</td><td>The reserved width of the string </td></tr>
|
|
<tr><td class="paramname">prec</td><td>The precision of the stringified number</td></tr>
|
|
</table>
|
|
</dd>
|
|
</dl>
|
|
<dl class="section return"><dt>Returns</dt><dd>std::string </dd></dl>
|
|
|
|
<p class="definition">Definition at line <a class="el" href="utils_8cpp_source.html#l00015">15</a> of file <a class="el" href="utils_8cpp_source.html">utils.cpp</a>.</p>
|
|
|
|
</div>
|
|
</div>
|
|
</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_68267d1309a1af8e8297ef4c3efbcdba.html">src</a></li><li class="navelem"><a class="el" href="utils_8cpp.html">utils.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.6 </li>
|
|
</ul>
|
|
</div>
|
|
</body>
|
|
</html>
|