<!-- HTML header for doxygen 1.8.8-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<!-- For Mobile Devices -->
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta name="generator" content="Doxygen 1.8.17"/>
<script type="text/javascript" src="https://code.jquery.com/jquery-2.1.1.min.js"></script>
<title>QuEST: Debugging</title>
<!--<link href="tabs.css" rel="stylesheet" type="text/css"/>-->
<script type="text/javascript" src="dynsections.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
<link href="style.css" rel="stylesheet" type="text/css"/>
<link href='https://fonts.googleapis.com/css?family=Roboto+Slab' rel='stylesheet' type='text/css'>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
<link href="jquery.smartmenus.bootstrap.css" rel="stylesheet">
<script type="text/javascript" src="jquery.smartmenus.js"></script>
<!-- SmartMenus jQuery Bootstrap Addon -->
<script type="text/javascript" src="jquery.smartmenus.bootstrap.js"></script>
<!-- SmartMenus jQuery plugin -->
</head>
<body>
<nav class="navbar navbar-default" role="navigation">
<div class="container">
<div class="navbar-header">
<a class="navbar-brand"><img alt="Logo" src="logo.png"/></a>
<a class="navbar-brand"><b>QuEST</b> v3.1.0<br>The Quantum Exact Simulation Toolkit</a>
</div>
</div>
</nav>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div class="content" id="content">
<div class="container">
<div class="row">
<div class="col-sm-12 panel " style="padding-bottom: 15px;">
<div style="margin-bottom: 15px;">
<!-- end header part -->
<!-- Generated by Doxygen 1.8.17 -->
<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&dn=gpl-2.0.txt GPL-v2 */
$(function() {
initMenu('',false,false,'search.php','Search');
});
/* @license-end */</script>
<div id="main-nav"></div>
</div><!-- top -->
<div class="header">
<div class="summary">
<a href="#func-members">Functions</a> </div>
<div class="headertitle">
<div class="title">Debugging</div> </div>
</div><!--header-->
<div class="contents">
<p>Utilities for seeding and debugging, such as state-logging.
<a href="#details">More...</a></p>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="func-members"></a>
Functions</h2></td></tr>
<tr class="memitem:ga924ef2dbda6b733b4041270077c76ece"><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="group__debug.html#ga924ef2dbda6b733b4041270077c76ece">copyStateFromGPU</a> (<a class="el" href="structQureg.html">Qureg</a> qureg)</td></tr>
<tr class="memdesc:ga924ef2dbda6b733b4041270077c76ece"><td class="mdescLeft"> </td><td class="mdescRight">In GPU mode, this copies the state-vector (or density matrix) from GPU memory (qureg.deviceStateVec) to RAM (qureg.stateVec), where it can be accessed/modified by the user. <a href="group__debug.html#ga924ef2dbda6b733b4041270077c76ece">More...</a><br /></td></tr>
<tr class="separator:ga924ef2dbda6b733b4041270077c76ece"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:ga11448560006dd165128e404b54ebb2f7"><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="group__debug.html#ga11448560006dd165128e404b54ebb2f7">copyStateToGPU</a> (<a class="el" href="structQureg.html">Qureg</a> qureg)</td></tr>
<tr class="memdesc:ga11448560006dd165128e404b54ebb2f7"><td class="mdescLeft"> </td><td class="mdescRight">In GPU mode, this copies the state-vector (or density matrix) from RAM (qureg.stateVec) to VRAM / GPU-memory (qureg.deviceStateVec), which is the version operated upon by other calls to the API. <a href="group__debug.html#ga11448560006dd165128e404b54ebb2f7">More...</a><br /></td></tr>
<tr class="separator:ga11448560006dd165128e404b54ebb2f7"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:ga2d955c6e51067371eee69795532a2d62"><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="group__debug.html#ga2d955c6e51067371eee69795532a2d62">getEnvironmentString</a> (<a class="el" href="structQuESTEnv.html">QuESTEnv</a> env, <a class="el" href="structQureg.html">Qureg</a> qureg, char str[200])</td></tr>
<tr class="memdesc:ga2d955c6e51067371eee69795532a2d62"><td class="mdescLeft"> </td><td class="mdescRight">Sets <code>str</code> to a string containing the number of qubits in <code>qureg</code>, and the hardware facilities used (e.g. <a href="group__debug.html#ga2d955c6e51067371eee69795532a2d62">More...</a><br /></td></tr>
<tr class="separator:ga2d955c6e51067371eee69795532a2d62"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:gaa696c94112e5fbbc996af10dfc4e2c1c"><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="group__debug.html#gaa696c94112e5fbbc996af10dfc4e2c1c">initDebugState</a> (<a class="el" href="structQureg.html">Qureg</a> qureg)</td></tr>
<tr class="memdesc:gaa696c94112e5fbbc996af10dfc4e2c1c"><td class="mdescLeft"> </td><td class="mdescRight">Initialises <code>qureg</code> to be in the un-normalised, non-physical state with with n-th complex amplitude (2n/10 + i(2n+1)/10). <a href="group__debug.html#gaa696c94112e5fbbc996af10dfc4e2c1c">More...</a><br /></td></tr>
<tr class="separator:gaa696c94112e5fbbc996af10dfc4e2c1c"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:ga51a64b05d31ef9bcf6a63ce26c0092db"><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="group__debug.html#ga51a64b05d31ef9bcf6a63ce26c0092db">invalidQuESTInputError</a> (const char *errMsg, const char *errFunc)</td></tr>
<tr class="memdesc:ga51a64b05d31ef9bcf6a63ce26c0092db"><td class="mdescLeft"> </td><td class="mdescRight">An internal function called when invalid arguments are passed to a QuEST API call, which the user can optionally override by redefining. <a href="group__debug.html#ga51a64b05d31ef9bcf6a63ce26c0092db">More...</a><br /></td></tr>
<tr class="separator:ga51a64b05d31ef9bcf6a63ce26c0092db"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:gaf8a14ae79c3fb2c0b5f6255cc37bebf9"><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="group__debug.html#gaf8a14ae79c3fb2c0b5f6255cc37bebf9">reportQuESTEnv</a> (<a class="el" href="structQuESTEnv.html">QuESTEnv</a> env)</td></tr>
<tr class="memdesc:gaf8a14ae79c3fb2c0b5f6255cc37bebf9"><td class="mdescLeft"> </td><td class="mdescRight">Report information about the QuEST environment. <a href="group__debug.html#gaf8a14ae79c3fb2c0b5f6255cc37bebf9">More...</a><br /></td></tr>
<tr class="separator:gaf8a14ae79c3fb2c0b5f6255cc37bebf9"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:ga97d96af7c7ea7b31e32cbe3b25377e09"><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="group__debug.html#ga97d96af7c7ea7b31e32cbe3b25377e09">reportQuregParams</a> (<a class="el" href="structQureg.html">Qureg</a> qureg)</td></tr>
<tr class="memdesc:ga97d96af7c7ea7b31e32cbe3b25377e09"><td class="mdescLeft"> </td><td class="mdescRight">Report metainformation about a set of qubits: number of qubits, number of probability amplitudes. <a href="group__debug.html#ga97d96af7c7ea7b31e32cbe3b25377e09">More...</a><br /></td></tr>
<tr class="separator:ga97d96af7c7ea7b31e32cbe3b25377e09"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:gacd5f0ee488157837a8483c1515817f98"><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="group__debug.html#gacd5f0ee488157837a8483c1515817f98">reportState</a> (<a class="el" href="structQureg.html">Qureg</a> qureg)</td></tr>
<tr class="memdesc:gacd5f0ee488157837a8483c1515817f98"><td class="mdescLeft"> </td><td class="mdescRight">Print the current state vector of probability amplitudes for a set of qubits to file. <a href="group__debug.html#gacd5f0ee488157837a8483c1515817f98">More...</a><br /></td></tr>
<tr class="separator:gacd5f0ee488157837a8483c1515817f98"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:gaa33ed720560d051eb4126b4a534bc4c6"><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="group__debug.html#gaa33ed720560d051eb4126b4a534bc4c6">reportStateToScreen</a> (<a class="el" href="structQureg.html">Qureg</a> qureg, <a class="el" href="structQuESTEnv.html">QuESTEnv</a> env, int reportRank)</td></tr>
<tr class="memdesc:gaa33ed720560d051eb4126b4a534bc4c6"><td class="mdescLeft"> </td><td class="mdescRight">Print the current state vector of probability amplitudes for a set of qubits to standard out. <a href="group__debug.html#gaa33ed720560d051eb4126b4a534bc4c6">More...</a><br /></td></tr>
<tr class="separator:gaa33ed720560d051eb4126b4a534bc4c6"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:ga95012dad46509b4b461974c34cfd7b3d"><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="group__debug.html#ga95012dad46509b4b461974c34cfd7b3d">seedQuEST</a> (unsigned long int *seedArray, int numSeeds)</td></tr>
<tr class="memdesc:ga95012dad46509b4b461974c34cfd7b3d"><td class="mdescLeft"> </td><td class="mdescRight">Seed the Mersenne Twister used for random number generation in the QuEST environment with a user defined seed. <a href="group__debug.html#ga95012dad46509b4b461974c34cfd7b3d">More...</a><br /></td></tr>
<tr class="separator:ga95012dad46509b4b461974c34cfd7b3d"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:gaa8437ef3bf135231e2916e64dde1c94e"><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="group__debug.html#gaa8437ef3bf135231e2916e64dde1c94e">seedQuESTDefault</a> (void)</td></tr>
<tr class="memdesc:gaa8437ef3bf135231e2916e64dde1c94e"><td class="mdescLeft"> </td><td class="mdescRight">Seed the Mersenne Twister used for random number generation in the QuEST environment with an example defualt seed. <a href="group__debug.html#gaa8437ef3bf135231e2916e64dde1c94e">More...</a><br /></td></tr>
<tr class="separator:gaa8437ef3bf135231e2916e64dde1c94e"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:ga8d31fe2d1ad4d01e2a1f5f6b8bc15b77"><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="group__debug.html#ga8d31fe2d1ad4d01e2a1f5f6b8bc15b77">syncQuESTEnv</a> (<a class="el" href="structQuESTEnv.html">QuESTEnv</a> env)</td></tr>
<tr class="memdesc:ga8d31fe2d1ad4d01e2a1f5f6b8bc15b77"><td class="mdescLeft"> </td><td class="mdescRight">Guarantees that all code up to the given point has been executed on all nodes (if running in distributed mode) <a href="group__debug.html#ga8d31fe2d1ad4d01e2a1f5f6b8bc15b77">More...</a><br /></td></tr>
<tr class="separator:ga8d31fe2d1ad4d01e2a1f5f6b8bc15b77"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:gac7e38d768a1bd79019f88cc1e6295092"><td class="memItemLeft" align="right" valign="top">int </td><td class="memItemRight" valign="bottom"><a class="el" href="group__debug.html#gac7e38d768a1bd79019f88cc1e6295092">syncQuESTSuccess</a> (int successCode)</td></tr>
<tr class="memdesc:gac7e38d768a1bd79019f88cc1e6295092"><td class="mdescLeft"> </td><td class="mdescRight">Performs a logical AND on all successCodes held by all processes. <a href="group__debug.html#gac7e38d768a1bd79019f88cc1e6295092">More...</a><br /></td></tr>
<tr class="separator:gac7e38d768a1bd79019f88cc1e6295092"><td class="memSeparator" colspan="2"> </td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<p>Utilities for seeding and debugging, such as state-logging. </p>
<dl class="section author"><dt>Author</dt><dd>Ania Brown </dd>
<dd>
Tyson Jones </dd>
<dd>
Balint Koczor </dd>
<dd>
Nicolas Vogt of HQS (one-qubit damping) </dd></dl>
<h2 class="groupheader">Function Documentation</h2>
<a id="ga924ef2dbda6b733b4041270077c76ece"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga924ef2dbda6b733b4041270077c76ece">◆ </a></span>copyStateFromGPU()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void copyStateFromGPU </td>
<td>(</td>
<td class="paramtype"><a class="el" href="structQureg.html">Qureg</a> </td>
<td class="paramname"><em>qureg</em></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<p>In GPU mode, this copies the state-vector (or density matrix) from GPU memory (qureg.deviceStateVec) to RAM (qureg.stateVec), where it can be accessed/modified by the user. </p>
<p>In CPU mode, this function has no effect. In conjunction with <a class="el" href="group__debug.html#ga11448560006dd165128e404b54ebb2f7" title="In GPU mode, this copies the state-vector (or density matrix) from RAM (qureg.stateVec) to VRAM / GPU...">copyStateToGPU()</a>, this allows a user to directly modify the state-vector in a harware agnostic way. Note though that users should instead use <a class="el" href="group__init.html#gabc0c64f8adf307d2a44184dc0f8ca66e" title="Overwrites a subset of the amplitudes in qureg, with those passed in reals and imags.">setAmps()</a> if possible.</p>
<p>For example, to set the first real element to 1, one could do: </p><pre class="fragment">copyStateFromGPU(qureg);
qureg.stateVec.real[0] = 1;
copyStateToGPU(qureg);
</pre><p>Note users should never access qureg.deviceStateVec directly.</p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramdir">[in,out]</td><td class="paramname">qureg</td><td>the qureg of which to copy .deviceStateVec to .stateVec in GPU mode </td></tr>
</table>
</dd>
</dl>
<dl class="section author"><dt>Author</dt><dd>Ania Brown </dd>
<dd>
Tyson Jones (doc) </dd></dl>
<p class="definition">Definition at line <a class="el" href="QuEST__cpu_8c_source.html#l00039">39</a> of file <a class="el" href="QuEST__cpu_8c_source.html">QuEST_cpu.c</a>.</p>
<div class="fragment"><div class="line"><a name="l00039"></a><span class="lineno"> 39</span>  {</div>
<div class="line"><a name="l00040"></a><span class="lineno"> 40</span> }</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST__gpu_8cu_source.html#l00020">DEBUG</a>, <a class="el" href="QuEST_8h_source.html#l00184">Qureg::deviceStateVec</a>, <a class="el" href="QuEST_8h_source.html#l00170">Qureg::numAmpsPerChunk</a>, and <a class="el" href="QuEST_8h_source.html#l00179">Qureg::stateVec</a>.</p>
<p class="reference">Referenced by <a class="el" href="utilities_8cpp_source.html#l00681">areEqual()</a>, <a class="el" href="QuEST__gpu_8cu_source.html#l01476">densmatr_calcTotalProb()</a>, <a class="el" href="QuEST__gpu_8cu_source.html#l01499">statevec_calcTotalProb()</a>, <a class="el" href="QuEST__gpu_8cu_source.html#l00649">statevec_compareStates()</a>, <a class="el" href="QuEST__gpu_8cu_source.html#l00421">statevec_reportStateToScreen()</a>, <a class="el" href="utilities_8cpp_source.html#l00862">toQMatrix()</a>, and <a class="el" href="utilities_8cpp_source.html#l00904">toQVector()</a>.</p>
</div>
</div>
<a id="ga11448560006dd165128e404b54ebb2f7"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga11448560006dd165128e404b54ebb2f7">◆ </a></span>copyStateToGPU()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void copyStateToGPU </td>
<td>(</td>
<td class="paramtype"><a class="el" href="structQureg.html">Qureg</a> </td>
<td class="paramname"><em>qureg</em></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<p>In GPU mode, this copies the state-vector (or density matrix) from RAM (qureg.stateVec) to VRAM / GPU-memory (qureg.deviceStateVec), which is the version operated upon by other calls to the API. </p>
<p>In CPU mode, this function has no effect. In conjunction with <a class="el" href="group__debug.html#ga924ef2dbda6b733b4041270077c76ece" title="In GPU mode, this copies the state-vector (or density matrix) from GPU memory (qureg....">copyStateFromGPU()</a> (which should be called first), this allows a user to directly modify the state-vector in a harware agnostic way. Note though that users should instead use <a class="el" href="group__init.html#gabc0c64f8adf307d2a44184dc0f8ca66e" title="Overwrites a subset of the amplitudes in qureg, with those passed in reals and imags.">setAmps()</a> if possible.</p>
<p>For example, to set the first real element to 1, one could do: </p><pre class="fragment">copyStateFromGPU(qureg);
qureg.stateVec.real[0] = 1;
copyStateToGPU(qureg);
</pre><p>Note users should never access qureg.deviceStateVec directly.</p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramdir">[in,out]</td><td class="paramname">qureg</td><td>the qureg of which to copy .stateVec to .deviceStateVec in GPU mode </td></tr>
</table>
</dd>
</dl>
<dl class="section author"><dt>Author</dt><dd>Ania Brown </dd>
<dd>
Tyson Jones (doc) </dd></dl>
<p class="definition">Definition at line <a class="el" href="QuEST__cpu_8c_source.html#l00036">36</a> of file <a class="el" href="QuEST__cpu_8c_source.html">QuEST_cpu.c</a>.</p>
<div class="fragment"><div class="line"><a name="l00036"></a><span class="lineno"> 36</span>  {</div>
<div class="line"><a name="l00037"></a><span class="lineno"> 37</span> }</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST__gpu_8cu_source.html#l00020">DEBUG</a>, <a class="el" href="QuEST_8h_source.html#l00184">Qureg::deviceStateVec</a>, <a class="el" href="QuEST_8h_source.html#l00170">Qureg::numAmpsPerChunk</a>, and <a class="el" href="QuEST_8h_source.html#l00179">Qureg::stateVec</a>.</p>
<p class="reference">Referenced by <a class="el" href="QuEST__gpu_8cu_source.html#l00605">statevec_initStateFromSingleFile()</a>, <a class="el" href="test__state__initialisations_8cpp_source.html#l00438">TEST_CASE()</a>, and <a class="el" href="utilities_8cpp_source.html#l00946">toQureg()</a>.</p>
</div>
</div>
<a id="ga2d955c6e51067371eee69795532a2d62"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga2d955c6e51067371eee69795532a2d62">◆ </a></span>getEnvironmentString()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void getEnvironmentString </td>
<td>(</td>
<td class="paramtype"><a class="el" href="structQuESTEnv.html">QuESTEnv</a> </td>
<td class="paramname"><em>env</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype"><a class="el" href="structQureg.html">Qureg</a> </td>
<td class="paramname"><em>qureg</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">char </td>
<td class="paramname"><em>str</em>[200] </td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Sets <code>str</code> to a string containing the number of qubits in <code>qureg</code>, and the hardware facilities used (e.g. </p>
<p>GPU, MPI and/or OMP).</p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramdir">[in]</td><td class="paramname">env</td><td>object representing the execution environment. A single instance is used for each program </td></tr>
<tr><td class="paramdir">[in]</td><td class="paramname">qureg</td><td>the qureg of which to query the simulating hardware </td></tr>
<tr><td class="paramdir">[out]</td><td class="paramname">str</td><td>to be populated with the output string </td></tr>
</table>
</dd>
</dl>
<dl class="section author"><dt>Author</dt><dd>Ania Brown </dd></dl>
<p class="definition">Definition at line <a class="el" href="QuEST__gpu_8cu_source.html#l00393">393</a> of file <a class="el" href="QuEST__gpu_8cu_source.html">QuEST_gpu.cu</a>.</p>
<div class="fragment"><div class="line"><a name="l00393"></a><span class="lineno"> 393</span>  {</div>
<div class="line"><a name="l00394"></a><span class="lineno"> 394</span>  sprintf(str, <span class="stringliteral">"%dqubits_GPU_noMpi_noOMP"</span>, qureg.<a class="code" href="structQureg.html#a0a86e8a50ea8c998b4a0a6640c5a1218">numQubitsInStateVec</a>); </div>
<div class="line"><a name="l00395"></a><span class="lineno"> 395</span> }</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST_8h_source.html#l00167">Qureg::numQubitsInStateVec</a>.</p>
</div>
</div>
<a id="gaa696c94112e5fbbc996af10dfc4e2c1c"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gaa696c94112e5fbbc996af10dfc4e2c1c">◆ </a></span>initDebugState()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void initDebugState </td>
<td>(</td>
<td class="paramtype"><a class="el" href="structQureg.html">Qureg</a> </td>
<td class="paramname"><em>qureg</em></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Initialises <code>qureg</code> to be in the un-normalised, non-physical state with with n-th complex amplitude (2n/10 + i(2n+1)/10). </p>
<p>This is used internally for debugging and testing.</p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramdir">[in,out]</td><td class="paramname">qureg</td><td>the register to have its amplitudes overwritten </td></tr>
</table>
</dd>
</dl>
<dl class="section author"><dt>Author</dt><dd>Ania Brown </dd>
<dd>
Tyson Jones (doc) </dd></dl>
<p class="definition">Definition at line <a class="el" href="QuEST_8c_source.html#l01057">1057</a> of file <a class="el" href="QuEST_8c_source.html">QuEST.c</a>.</p>
<div class="fragment"><div class="line"><a name="l01057"></a><span class="lineno"> 1057</span>  {</div>
<div class="line"><a name="l01058"></a><span class="lineno"> 1058</span>  <a class="code" href="QuEST__internal_8h.html#ad9fd3017ea40cf63fd04b39e03494972">statevec_initDebugState</a>(qureg);</div>
<div class="line"><a name="l01059"></a><span class="lineno"> 1059</span> }</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST__cpu_8c_source.html#l01559">statevec_initDebugState()</a>.</p>
<p class="reference">Referenced by <a class="el" href="test__calculations_8cpp_source.html#l00111">TEST_CASE()</a>.</p>
</div>
</div>
<a id="ga51a64b05d31ef9bcf6a63ce26c0092db"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga51a64b05d31ef9bcf6a63ce26c0092db">◆ </a></span>invalidQuESTInputError()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void invalidQuESTInputError </td>
<td>(</td>
<td class="paramtype">const char * </td>
<td class="paramname"><em>errMsg</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">const char * </td>
<td class="paramname"><em>errFunc</em> </td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</div><div class="memdoc">
<p>An internal function called when invalid arguments are passed to a QuEST API call, which the user can optionally override by redefining. </p>
<p>This function is a weak symbol, so that users can choose how input errors are handled, by redefining it in their own code. Users must ensure that the triggered API call does not continue (e.g. the user exits or throws an exception), else QuEST will continue with the valid input and likely trigger a seg-fault. This function is triggered before any internal state-change, hence it is safe to interrupt with exceptions.</p>
<p>E.g. in C </p><div class="fragment"><div class="line"><span class="keywordtype">void</span> <a class="code" href="group__debug.html#ga51a64b05d31ef9bcf6a63ce26c0092db">invalidQuESTInputError</a>(<span class="keyword">const</span> <span class="keywordtype">char</span>* errMsg, <span class="keyword">const</span> <span class="keywordtype">char</span>* errFunc) {</div>
<div class="line"> </div>
<div class="line"> <span class="comment">// log to file</span></div>
<div class="line"> printf(<span class="stringliteral">"ERROR! Writing to file...\n"</span>);</div>
<div class="line"> FILE *fp = fopen(<span class="stringliteral">"errorlog.txt"</span>, <span class="stringliteral">"w"</span>);</div>
<div class="line"> fprintf(fp, <span class="stringliteral">"incorrect usage of function '%s': %s"</span>, errFunc, errMsg);</div>
<div class="line"> fclose(fp);</div>
<div class="line"> </div>
<div class="line"> <span class="comment">// exit</span></div>
<div class="line"> exit(1);</div>
<div class="line">} </div>
</div><!-- fragment --><p>This function is compatible with C++ exceptions, though note the user of extern "C": </p><div class="fragment"><div class="line"><span class="keyword">extern</span> <span class="stringliteral">"C"</span> <span class="keywordtype">void</span> <a class="code" href="group__debug.html#ga51a64b05d31ef9bcf6a63ce26c0092db">invalidQuESTInputError</a>(<span class="keyword">const</span> <span class="keywordtype">char</span>* errMsg, <span class="keyword">const</span> <span class="keywordtype">char</span>* errFunc) {</div>
<div class="line"> </div>
<div class="line"> <span class="keywordtype">string</span> err = <span class="stringliteral">"in function "</span> + string(errFunc) + <span class="stringliteral">": "</span> + string(errMsg);</div>
<div class="line"> <span class="keywordflow">throw</span> std::invalid_argument(err);</div>
<div class="line">} </div>
</div><!-- fragment --><dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramdir">[in]</td><td class="paramname">errMsg</td><td>a string describing the nature of the argument error </td></tr>
<tr><td class="paramdir">[in]</td><td class="paramname">errFunc</td><td>the name of the invalidly-called API function </td></tr>
</table>
</dd>
</dl>
<dl class="exception"><dt>Exceptions</dt><dd>
<table class="exception">
<tr><td class="paramname">exitWithError</td><td>unless overriden by the user </td></tr>
</table>
</dd>
</dl>
<dl class="section author"><dt>Author</dt><dd>Tyson Jones</dd></dl>
<p>An internal function called when invalid arguments are passed to a QuEST API call, which the user can optionally override by redefining.</p>
<p>an negative qubit index). This is redefined here to, in lieu of printing and exiting, throw a C++ exception which can be caught (and hence unit tested for) by Catch2 </p>
<p class="definition">Definition at line <a class="el" href="QuEST__validation_8c_source.html#l00142">142</a> of file <a class="el" href="QuEST__validation_8c_source.html">QuEST_validation.c</a>.</p>
<div class="fragment"><div class="line"><a name="l00142"></a><span class="lineno"> 142</span>  {</div>
<div class="line"><a name="l00143"></a><span class="lineno"> 143</span>  <a class="code" href="QuEST__validation_8c.html#aa37cc778ac42f5350830b90d0292b501">exitWithError</a>(errMsg, errFunc);</div>
<div class="line"><a name="l00144"></a><span class="lineno"> 144</span> }</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST__validation_8c_source.html#l00133">exitWithError()</a>.</p>
<p class="reference">Referenced by <a class="el" href="QuEST__validation_8c_source.html#l00146">QuESTAssert()</a>.</p>
</div>
</div>
<a id="gaf8a14ae79c3fb2c0b5f6255cc37bebf9"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gaf8a14ae79c3fb2c0b5f6255cc37bebf9">◆ </a></span>reportQuESTEnv()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void reportQuESTEnv </td>
<td>(</td>
<td class="paramtype"><a class="el" href="structQuESTEnv.html">QuESTEnv</a> </td>
<td class="paramname"><em>env</em></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Report information about the QuEST environment. </p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramdir">[in]</td><td class="paramname">env</td><td>object representing the execution environment. A single instance is used for each program </td></tr>
</table>
</dd>
</dl>
<dl class="section author"><dt>Author</dt><dd>Ania Brown </dd></dl>
<p class="definition">Definition at line <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00179">179</a> of file <a class="el" href="QuEST__cpu__distributed_8c_source.html">QuEST_cpu_distributed.c</a>.</p>
<div class="fragment"><div class="line"><a name="l00179"></a><span class="lineno"> 179</span>  {</div>
<div class="line"><a name="l00180"></a><span class="lineno"> 180</span>  <span class="keywordflow">if</span> (env.<a class="code" href="structQuESTEnv.html#aa648bb336cf8598467cb62db00b9cee8">rank</a>==0){</div>
<div class="line"><a name="l00181"></a><span class="lineno"> 181</span>  printf(<span class="stringliteral">"EXECUTION ENVIRONMENT:\n"</span>); </div>
<div class="line"><a name="l00182"></a><span class="lineno"> 182</span>  printf(<span class="stringliteral">"Running distributed (MPI) version\n"</span>);</div>
<div class="line"><a name="l00183"></a><span class="lineno"> 183</span>  printf(<span class="stringliteral">"Number of ranks is %d\n"</span>, env.<a class="code" href="structQuESTEnv.html#af22aacd7c9905accae28484785c193b4">numRanks</a>);</div>
<div class="line"><a name="l00184"></a><span class="lineno"> 184</span> <span class="preprocessor"># ifdef _OPENMP</span></div>
<div class="line"><a name="l00185"></a><span class="lineno"> 185</span>  printf(<span class="stringliteral">"OpenMP enabled\n"</span>);</div>
<div class="line"><a name="l00186"></a><span class="lineno"> 186</span>  printf(<span class="stringliteral">"Number of threads available is %d\n"</span>, omp_get_max_threads());</div>
<div class="line"><a name="l00187"></a><span class="lineno"> 187</span> <span class="preprocessor"># else</span></div>
<div class="line"><a name="l00188"></a><span class="lineno"> 188</span>  printf(<span class="stringliteral">"OpenMP disabled\n"</span>);</div>
<div class="line"><a name="l00189"></a><span class="lineno"> 189</span> <span class="preprocessor"># endif </span></div>
<div class="line"><a name="l00190"></a><span class="lineno"> 190</span>  printf(<span class="stringliteral">"Precision: size of qreal is %ld bytes\n"</span>, <span class="keyword">sizeof</span>(<a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>) );</div>
<div class="line"><a name="l00191"></a><span class="lineno"> 191</span>  }</div>
<div class="line"><a name="l00192"></a><span class="lineno"> 192</span> }</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST_8h_source.html#l00202">QuESTEnv::numRanks</a>, <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>, and <a class="el" href="QuEST_8h_source.html#l00201">QuESTEnv::rank</a>.</p>
</div>
</div>
<a id="ga97d96af7c7ea7b31e32cbe3b25377e09"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga97d96af7c7ea7b31e32cbe3b25377e09">◆ </a></span>reportQuregParams()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void reportQuregParams </td>
<td>(</td>
<td class="paramtype"><a class="el" href="structQureg.html">Qureg</a> </td>
<td class="paramname"><em>qureg</em></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Report metainformation about a set of qubits: number of qubits, number of probability amplitudes. </p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramdir">[in]</td><td class="paramname">qureg</td><td>object representing the set of qubits </td></tr>
</table>
</dd>
</dl>
<dl class="section author"><dt>Author</dt><dd>Ania Brown </dd></dl>
<p class="definition">Definition at line <a class="el" href="QuEST__common_8c_source.html#l00233">233</a> of file <a class="el" href="QuEST__common_8c_source.html">QuEST_common.c</a>.</p>
<div class="fragment"><div class="line"><a name="l00233"></a><span class="lineno"> 233</span>  {</div>
<div class="line"><a name="l00234"></a><span class="lineno"> 234</span>  <span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> numAmps = 1LL << qureg.<a class="code" href="structQureg.html#a0a86e8a50ea8c998b4a0a6640c5a1218">numQubitsInStateVec</a>;</div>
<div class="line"><a name="l00235"></a><span class="lineno"> 235</span>  <span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> numAmpsPerRank = numAmps/qureg.<a class="code" href="structQureg.html#aa3deb7163aab90a61e755a1f200f5413">numChunks</a>;</div>
<div class="line"><a name="l00236"></a><span class="lineno"> 236</span>  <span class="keywordflow">if</span> (qureg.<a class="code" href="structQureg.html#ac2929e681d3d95591c18cf168dbbe4f0">chunkId</a>==0){</div>
<div class="line"><a name="l00237"></a><span class="lineno"> 237</span>  printf(<span class="stringliteral">"QUBITS:\n"</span>);</div>
<div class="line"><a name="l00238"></a><span class="lineno"> 238</span>  printf(<span class="stringliteral">"Number of qubits is %d.\n"</span>, qureg.<a class="code" href="structQureg.html#a0a86e8a50ea8c998b4a0a6640c5a1218">numQubitsInStateVec</a>);</div>
<div class="line"><a name="l00239"></a><span class="lineno"> 239</span>  printf(<span class="stringliteral">"Number of amps is %lld.\n"</span>, numAmps);</div>
<div class="line"><a name="l00240"></a><span class="lineno"> 240</span>  printf(<span class="stringliteral">"Number of amps per rank is %lld.\n"</span>, numAmpsPerRank);</div>
<div class="line"><a name="l00241"></a><span class="lineno"> 241</span>  }</div>
<div class="line"><a name="l00242"></a><span class="lineno"> 242</span> }</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST_8h_source.html#l00174">Qureg::chunkId</a>, <a class="el" href="QuEST_8h_source.html#l00176">Qureg::numChunks</a>, and <a class="el" href="QuEST_8h_source.html#l00167">Qureg::numQubitsInStateVec</a>.</p>
</div>
</div>
<a id="gacd5f0ee488157837a8483c1515817f98"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gacd5f0ee488157837a8483c1515817f98">◆ </a></span>reportState()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void reportState </td>
<td>(</td>
<td class="paramtype"><a class="el" href="structQureg.html">Qureg</a> </td>
<td class="paramname"><em>qureg</em></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Print the current state vector of probability amplitudes for a set of qubits to file. </p>
<p>File format: </p><pre class="fragment">real, imag
realComponent1, imagComponent1
realComponent2, imagComponent2
...
realComponentN, imagComponentN
</pre><p>File naming convention:</p>
<p>For each node that the program runs on, a file 'state_rank_[node_rank].csv' is generated. If there is more than one node, ranks after the first do not include the header </p><pre class="fragment">real, imag
</pre><p> so that files are easier to combine.</p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramdir">[in,out]</td><td class="paramname">qureg</td><td>object representing the set of qubits </td></tr>
</table>
</dd>
</dl>
<dl class="section author"><dt>Author</dt><dd>Ania Brown </dd></dl>
<p class="definition">Definition at line <a class="el" href="QuEST__common_8c_source.html#l00215">215</a> of file <a class="el" href="QuEST__common_8c_source.html">QuEST_common.c</a>.</p>
<div class="fragment"><div class="line"><a name="l00215"></a><span class="lineno"> 215</span>  {</div>
<div class="line"><a name="l00216"></a><span class="lineno"> 216</span>  FILE *state;</div>
<div class="line"><a name="l00217"></a><span class="lineno"> 217</span>  <span class="keywordtype">char</span> filename[100];</div>
<div class="line"><a name="l00218"></a><span class="lineno"> 218</span>  <span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> index;</div>
<div class="line"><a name="l00219"></a><span class="lineno"> 219</span>  sprintf(filename, <span class="stringliteral">"state_rank_%d.csv"</span>, qureg.<a class="code" href="structQureg.html#ac2929e681d3d95591c18cf168dbbe4f0">chunkId</a>);</div>
<div class="line"><a name="l00220"></a><span class="lineno"> 220</span>  state = fopen(filename, <span class="stringliteral">"w"</span>);</div>
<div class="line"><a name="l00221"></a><span class="lineno"> 221</span>  <span class="keywordflow">if</span> (qureg.<a class="code" href="structQureg.html#ac2929e681d3d95591c18cf168dbbe4f0">chunkId</a>==0) fprintf(state, <span class="stringliteral">"real, imag\n"</span>);</div>
<div class="line"><a name="l00222"></a><span class="lineno"> 222</span>  </div>
<div class="line"><a name="l00223"></a><span class="lineno"> 223</span>  <span class="keywordflow">for</span>(index=0; index<qureg.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a>; index++){</div>
<div class="line"><a name="l00224"></a><span class="lineno"> 224</span> <span class="preprocessor"> # if QuEST_PREC==1 || QuEST_PREC==2</span></div>
<div class="line"><a name="l00225"></a><span class="lineno"> 225</span>  fprintf(state, <span class="stringliteral">"%.12f, %.12f\n"</span>, qureg.<a class="code" href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">stateVec</a>.real[index], qureg.<a class="code" href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">stateVec</a>.imag[index]);</div>
<div class="line"><a name="l00226"></a><span class="lineno"> 226</span> <span class="preprocessor"> # elif QuEST_PREC == 4</span></div>
<div class="line"><a name="l00227"></a><span class="lineno"> 227</span>  fprintf(state, <span class="stringliteral">"%.12Lf, %.12Lf\n"</span>, qureg.<a class="code" href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">stateVec</a>.real[index], qureg.<a class="code" href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">stateVec</a>.imag[index]);</div>
<div class="line"><a name="l00228"></a><span class="lineno"> 228</span> <span class="preprocessor"> #endif</span></div>
<div class="line"><a name="l00229"></a><span class="lineno"> 229</span>  }</div>
<div class="line"><a name="l00230"></a><span class="lineno"> 230</span>  fclose(state);</div>
<div class="line"><a name="l00231"></a><span class="lineno"> 231</span> }</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST_8h_source.html#l00174">Qureg::chunkId</a>, <a class="el" href="QuEST_8h_source.html#l00170">Qureg::numAmpsPerChunk</a>, and <a class="el" href="QuEST_8h_source.html#l00179">Qureg::stateVec</a>.</p>
</div>
</div>
<a id="gaa33ed720560d051eb4126b4a534bc4c6"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gaa33ed720560d051eb4126b4a534bc4c6">◆ </a></span>reportStateToScreen()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void reportStateToScreen </td>
<td>(</td>
<td class="paramtype"><a class="el" href="structQureg.html">Qureg</a> </td>
<td class="paramname"><em>qureg</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype"><a class="el" href="structQuESTEnv.html">QuESTEnv</a> </td>
<td class="paramname"><em>env</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int </td>
<td class="paramname"><em>reportRank</em> </td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Print the current state vector of probability amplitudes for a set of qubits to standard out. </p>
<p>For debugging purposes. Each rank should print output serially. Only print output for systems <= 5 qubits</p>
<dl class="section author"><dt>Author</dt><dd>Ania Brown </dd></dl>
<p class="definition">Definition at line <a class="el" href="QuEST_8c_source.html#l01073">1073</a> of file <a class="el" href="QuEST_8c_source.html">QuEST.c</a>.</p>
<div class="fragment"><div class="line"><a name="l01073"></a><span class="lineno"> 1073</span>  {</div>
<div class="line"><a name="l01074"></a><span class="lineno"> 1074</span>  <a class="code" href="QuEST__internal_8h.html#a1e57230c7995447039e62a84c0a36524">statevec_reportStateToScreen</a>(qureg, env, reportRank);</div>
<div class="line"><a name="l01075"></a><span class="lineno"> 1075</span> }</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST__cpu_8c_source.html#l01334">statevec_reportStateToScreen()</a>.</p>
</div>
</div>
<a id="ga95012dad46509b4b461974c34cfd7b3d"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga95012dad46509b4b461974c34cfd7b3d">◆ </a></span>seedQuEST()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void seedQuEST </td>
<td>(</td>
<td class="paramtype">unsigned long int * </td>
<td class="paramname"><em>seedArray</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int </td>
<td class="paramname"><em>numSeeds</em> </td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Seed the Mersenne Twister used for random number generation in the QuEST environment with a user defined seed. </p>
<p>This function uses the mt19937 init_by_array function with numSeeds keys supplied by the user. Subsequent calls to mt19937 genrand functions will use this seeding. For a multi process code, the same seed is given to all process, therefore this seeding is only appropriate to use for functions such as measure where all processes require the same random value.</p>
<p>For more information about the MT, see <a href="http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/MT2002/emt19937ar.html">http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/MT2002/emt19937ar.html</a></p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramdir">[in]</td><td class="paramname">seedArray</td><td>Array of integers to use as seed. This allows the MT to be initialised with more than a 32-bit integer if required </td></tr>
<tr><td class="paramdir">[in]</td><td class="paramname">numSeeds</td><td>Length of seedArray </td></tr>
</table>
</dd>
</dl>
<dl class="section author"><dt>Author</dt><dd>Ania Brown</dd></dl>
<p>Seed the Mersenne Twister used for random number generation in the QuEST environment with a user defined seed. </p>
<p class="definition">Definition at line <a class="el" href="QuEST__common_8c_source.html#l00208">208</a> of file <a class="el" href="QuEST__common_8c_source.html">QuEST_common.c</a>.</p>
<div class="fragment"><div class="line"><a name="l00208"></a><span class="lineno"> 208</span>  {</div>
<div class="line"><a name="l00209"></a><span class="lineno"> 209</span>  <span class="comment">// init MT random number generator with user defined list of seeds</span></div>
<div class="line"><a name="l00210"></a><span class="lineno"> 210</span>  <span class="comment">// for the MPI version, it is ok that all procs will get the same seed as random numbers will only be </span></div>
<div class="line"><a name="l00211"></a><span class="lineno"> 211</span>  <span class="comment">// used by the master process</span></div>
<div class="line"><a name="l00212"></a><span class="lineno"> 212</span>  <a class="code" href="mt19937ar_8c.html#ac1283f9b1ed571332f5ffe53545ffc16">init_by_array</a>(seedArray, numSeeds); </div>
<div class="line"><a name="l00213"></a><span class="lineno"> 213</span> }</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="mt19937ar_8c_source.html#l00080">init_by_array()</a>.</p>
</div>
</div>
<a id="gaa8437ef3bf135231e2916e64dde1c94e"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gaa8437ef3bf135231e2916e64dde1c94e">◆ </a></span>seedQuESTDefault()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void seedQuESTDefault </td>
<td>(</td>
<td class="paramtype">void </td>
<td class="paramname"></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Seed the Mersenne Twister used for random number generation in the QuEST environment with an example defualt seed. </p>
<p>This default seeding function uses the mt19937 init_by_array function with two keys – time and pid. Subsequent calls to mt19937 genrand functions will use this seeding. For a multi process code, the same seed is given to all process, therefore this seeding is only appropriate to use for functions such as measure where all processes require the same random value.</p>
<p>For more information about the MT, see <a href="http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/MT2002/emt19937ar.html">http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/MT2002/emt19937ar.html</a></p>
<dl class="section author"><dt>Author</dt><dd>Ania Brown </dd>
<dd>
Balint Koczor (Windows compatibility) </dd></dl>
<p class="definition">Definition at line <a class="el" href="QuEST__cpu__distributed_8c_source.html#l01321">1321</a> of file <a class="el" href="QuEST__cpu__distributed_8c_source.html">QuEST_cpu_distributed.c</a>.</p>
<div class="fragment"><div class="line"><a name="l01321"></a><span class="lineno"> 1321</span>  {</div>
<div class="line"><a name="l01322"></a><span class="lineno"> 1322</span>  <span class="comment">// init MT random number generator with three keys -- time and pid</span></div>
<div class="line"><a name="l01323"></a><span class="lineno"> 1323</span>  <span class="comment">// for the MPI version, it is ok that all procs will get the same seed as random numbers will only be </span></div>
<div class="line"><a name="l01324"></a><span class="lineno"> 1324</span>  <span class="comment">// used by the master process</span></div>
<div class="line"><a name="l01325"></a><span class="lineno"> 1325</span>  </div>
<div class="line"><a name="l01326"></a><span class="lineno"> 1326</span>  <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> key[2];</div>
<div class="line"><a name="l01327"></a><span class="lineno"> 1327</span>  <a class="code" href="QuEST__common_8c.html#a2b323b65cd6512720e6aa27c182fcea0">getQuESTDefaultSeedKey</a>(key);</div>
<div class="line"><a name="l01328"></a><span class="lineno"> 1328</span>  <span class="comment">// this seed will be used to generate the same random number on all procs,</span></div>
<div class="line"><a name="l01329"></a><span class="lineno"> 1329</span>  <span class="comment">// therefore we want to make sure all procs receive the same key</span></div>
<div class="line"><a name="l01330"></a><span class="lineno"> 1330</span>  MPI_Bcast(key, 2, MPI_UNSIGNED_LONG, 0, MPI_COMM_WORLD);</div>
<div class="line"><a name="l01331"></a><span class="lineno"> 1331</span>  <a class="code" href="mt19937ar_8c.html#ac1283f9b1ed571332f5ffe53545ffc16">init_by_array</a>(key, 2);</div>
<div class="line"><a name="l01332"></a><span class="lineno"> 1332</span> }</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST__common_8c_source.html#l00181">getQuESTDefaultSeedKey()</a>, and <a class="el" href="mt19937ar_8c_source.html#l00080">init_by_array()</a>.</p>
<p class="reference">Referenced by <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00129">createQuESTEnv()</a>.</p>
</div>
</div>
<a id="ga8d31fe2d1ad4d01e2a1f5f6b8bc15b77"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga8d31fe2d1ad4d01e2a1f5f6b8bc15b77">◆ </a></span>syncQuESTEnv()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void syncQuESTEnv </td>
<td>(</td>
<td class="paramtype"><a class="el" href="structQuESTEnv.html">QuESTEnv</a> </td>
<td class="paramname"><em>env</em></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Guarantees that all code up to the given point has been executed on all nodes (if running in distributed mode) </p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramdir">[in]</td><td class="paramname">env</td><td>object representing the execution environment. A single instance is used for each program </td></tr>
</table>
</dd>
</dl>
<dl class="section author"><dt>Author</dt><dd>Ania Brown </dd></dl>
<p class="definition">Definition at line <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00162">162</a> of file <a class="el" href="QuEST__cpu__distributed_8c_source.html">QuEST_cpu_distributed.c</a>.</p>
<div class="fragment"><div class="line"><a name="l00162"></a><span class="lineno"> 162</span>  {</div>
<div class="line"><a name="l00163"></a><span class="lineno"> 163</span>  MPI_Barrier(MPI_COMM_WORLD);</div>
<div class="line"><a name="l00164"></a><span class="lineno"> 164</span> }</div>
</div><!-- fragment -->
<p class="reference">Referenced by <a class="el" href="utilities_8cpp_source.html#l00681">areEqual()</a>, <a class="el" href="QuEST__cpu_8c_source.html#l01593">statevec_initStateFromSingleFile()</a>, <a class="el" href="QuEST__cpu_8c_source.html#l01334">statevec_reportStateToScreen()</a>, <a class="el" href="utilities_8cpp_source.html#l00862">toQMatrix()</a>, <a class="el" href="utilities_8cpp_source.html#l00946">toQureg()</a>, and <a class="el" href="utilities_8cpp_source.html#l00904">toQVector()</a>.</p>
</div>
</div>
<a id="gac7e38d768a1bd79019f88cc1e6295092"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gac7e38d768a1bd79019f88cc1e6295092">◆ </a></span>syncQuESTSuccess()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">int syncQuESTSuccess </td>
<td>(</td>
<td class="paramtype">int </td>
<td class="paramname"><em>successCode</em></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Performs a logical AND on all successCodes held by all processes. </p>
<p>If any one process has a zero successCode all processes will return a zero success code.</p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramdir">[in]</td><td class="paramname">successCode</td><td>1 if process task succeeded, 0 if process task failed </td></tr>
</table>
</dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>1 if all processes succeeded, 0 if any one process failed </dd></dl>
<dl class="section author"><dt>Author</dt><dd>Ania Brown </dd></dl>
<p class="definition">Definition at line <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00166">166</a> of file <a class="el" href="QuEST__cpu__distributed_8c_source.html">QuEST_cpu_distributed.c</a>.</p>
<div class="fragment"><div class="line"><a name="l00166"></a><span class="lineno"> 166</span>  {</div>
<div class="line"><a name="l00167"></a><span class="lineno"> 167</span>  <span class="keywordtype">int</span> totalSuccess;</div>
<div class="line"><a name="l00168"></a><span class="lineno"> 168</span>  MPI_Allreduce(&successCode, &totalSuccess, 1, MPI_INT, MPI_LAND, MPI_COMM_WORLD);</div>
<div class="line"><a name="l00169"></a><span class="lineno"> 169</span>  <span class="keywordflow">return</span> totalSuccess;</div>
<div class="line"><a name="l00170"></a><span class="lineno"> 170</span> }</div>
</div><!-- fragment -->
</div>
</div>
</div><!-- contents -->
<div class="ttc" id="amt19937ar_8c_html_ac1283f9b1ed571332f5ffe53545ffc16"><div class="ttname"><a href="mt19937ar_8c.html#ac1283f9b1ed571332f5ffe53545ffc16">init_by_array</a></div><div class="ttdeci">void init_by_array(unsigned long init_key[], int key_length)</div><div class="ttdef"><b>Definition:</b> <a href="mt19937ar_8c_source.html#l00080">mt19937ar.c:80</a></div></div>
<div class="ttc" id="astructQuESTEnv_html_aa648bb336cf8598467cb62db00b9cee8"><div class="ttname"><a href="structQuESTEnv.html#aa648bb336cf8598467cb62db00b9cee8">QuESTEnv::rank</a></div><div class="ttdeci">int rank</div><div class="ttdef"><b>Definition:</b> <a href="QuEST_8h_source.html#l00201">QuEST.h:201</a></div></div>
<div class="ttc" id="astructQureg_html_aa3deb7163aab90a61e755a1f200f5413"><div class="ttname"><a href="structQureg.html#aa3deb7163aab90a61e755a1f200f5413">Qureg::numChunks</a></div><div class="ttdeci">int numChunks</div><div class="ttdoc">Number of chunks the state vector is broken up into – the number of MPI processes used.</div><div class="ttdef"><b>Definition:</b> <a href="QuEST_8h_source.html#l00176">QuEST.h:176</a></div></div>
<div class="ttc" id="aQuEST__common_8c_html_a2b323b65cd6512720e6aa27c182fcea0"><div class="ttname"><a href="QuEST__common_8c.html#a2b323b65cd6512720e6aa27c182fcea0">getQuESTDefaultSeedKey</a></div><div class="ttdeci">void getQuESTDefaultSeedKey(unsigned long int *key)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__common_8c_source.html#l00181">QuEST_common.c:181</a></div></div>
<div class="ttc" id="agroup__type_html_ga7740e349b4f8bae6451547680f0ce2d6"><div class="ttname"><a href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a></div><div class="ttdeci">#define qreal</div></div>
<div class="ttc" id="astructQureg_html_a0a86e8a50ea8c998b4a0a6640c5a1218"><div class="ttname"><a href="structQureg.html#a0a86e8a50ea8c998b4a0a6640c5a1218">Qureg::numQubitsInStateVec</a></div><div class="ttdeci">int numQubitsInStateVec</div><div class="ttdoc">Number of qubits in the state-vector - this is double the number represented for mixed states.</div><div class="ttdef"><b>Definition:</b> <a href="QuEST_8h_source.html#l00167">QuEST.h:167</a></div></div>
<div class="ttc" id="agroup__debug_html_ga51a64b05d31ef9bcf6a63ce26c0092db"><div class="ttname"><a href="group__debug.html#ga51a64b05d31ef9bcf6a63ce26c0092db">invalidQuESTInputError</a></div><div class="ttdeci">void invalidQuESTInputError(const char *errMsg, const char *errFunc)</div><div class="ttdoc">An internal function called when invalid arguments are passed to a QuEST API call,...</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__validation_8c_source.html#l00142">QuEST_validation.c:142</a></div></div>
<div class="ttc" id="astructQureg_html_ac2929e681d3d95591c18cf168dbbe4f0"><div class="ttname"><a href="structQureg.html#ac2929e681d3d95591c18cf168dbbe4f0">Qureg::chunkId</a></div><div class="ttdeci">int chunkId</div><div class="ttdoc">The position of the chunk of the state vector held by this process in the full state vector.</div><div class="ttdef"><b>Definition:</b> <a href="QuEST_8h_source.html#l00174">QuEST.h:174</a></div></div>
<div class="ttc" id="aQuEST__validation_8c_html_aa37cc778ac42f5350830b90d0292b501"><div class="ttname"><a href="QuEST__validation_8c.html#aa37cc778ac42f5350830b90d0292b501">exitWithError</a></div><div class="ttdeci">void exitWithError(const char *msg, const char *func)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__validation_8c_source.html#l00133">QuEST_validation.c:133</a></div></div>
<div class="ttc" id="astructQureg_html_ab0ea0358482b62f43fdd781469607d97"><div class="ttname"><a href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">Qureg::numAmpsPerChunk</a></div><div class="ttdeci">long long int numAmpsPerChunk</div><div class="ttdoc">Number of probability amplitudes held in stateVec by this process In the non-MPI version,...</div><div class="ttdef"><b>Definition:</b> <a href="QuEST_8h_source.html#l00170">QuEST.h:170</a></div></div>
<div class="ttc" id="aQuEST__internal_8h_html_a1e57230c7995447039e62a84c0a36524"><div class="ttname"><a href="QuEST__internal_8h.html#a1e57230c7995447039e62a84c0a36524">statevec_reportStateToScreen</a></div><div class="ttdeci">void statevec_reportStateToScreen(Qureg qureg, QuESTEnv env, int reportRank)</div><div class="ttdoc">Print the current state vector of probability amplitudes for a set of qubits to standard out.</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__cpu_8c_source.html#l01334">QuEST_cpu.c:1334</a></div></div>
<div class="ttc" id="astructQuESTEnv_html_af22aacd7c9905accae28484785c193b4"><div class="ttname"><a href="structQuESTEnv.html#af22aacd7c9905accae28484785c193b4">QuESTEnv::numRanks</a></div><div class="ttdeci">int numRanks</div><div class="ttdef"><b>Definition:</b> <a href="QuEST_8h_source.html#l00202">QuEST.h:202</a></div></div>
<div class="ttc" id="aQuEST__internal_8h_html_ad9fd3017ea40cf63fd04b39e03494972"><div class="ttname"><a href="QuEST__internal_8h.html#ad9fd3017ea40cf63fd04b39e03494972">statevec_initDebugState</a></div><div class="ttdeci">void statevec_initDebugState(Qureg qureg)</div><div class="ttdoc">Initialise the state vector of probability amplitudes to an (unphysical) state with each component of...</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__cpu_8c_source.html#l01559">QuEST_cpu.c:1559</a></div></div>
<div class="ttc" id="astructQureg_html_a441e4cacef6bd17adb9813c7442d42fe"><div class="ttname"><a href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">Qureg::stateVec</a></div><div class="ttdeci">ComplexArray stateVec</div><div class="ttdoc">Computational state amplitudes - a subset thereof in the MPI version.</div><div class="ttdef"><b>Definition:</b> <a href="QuEST_8h_source.html#l00179">QuEST.h:179</a></div></div>
<!-- HTML footer for doxygen 1.8.8-->
<!-- start footer part -->
</div>
</div>
</div>
</div>
</div>
</body>
<script type="text/javascript" src="boot.js"></script>
</html>