<!-- 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.4.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:gadc5c01d8ea32e28c188db52be26116b6"><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="group__debug.html#gadc5c01d8ea32e28c188db52be26116b6">getEnvironmentString</a> (<a class="el" href="structQuESTEnv.html">QuESTEnv</a> env, char str[200])</td></tr>
<tr class="memdesc:gadc5c01d8ea32e28c188db52be26116b6"><td class="mdescLeft"> </td><td class="mdescRight">Sets <code>str</code> to a string containing information about the runtime environment, including whether simulation is using CUDA (for GPU), OpenMP (for multithreading) and/or MPI (for distribution). <a href="group__debug.html#gadc5c01d8ea32e28c188db52be26116b6">More...</a><br /></td></tr>
<tr class="separator:gadc5c01d8ea32e28c188db52be26116b6"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:gaaf64c49f51b622702e66d917bf5b5e16"><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="group__debug.html#gaaf64c49f51b622702e66d917bf5b5e16">getQuESTSeeds</a> (<a class="el" href="structQuESTEnv.html">QuESTEnv</a> env, unsigned long int **seeds, int *numSeeds)</td></tr>
<tr class="memdesc:gaaf64c49f51b622702e66d917bf5b5e16"><td class="mdescLeft"> </td><td class="mdescRight">Obtain the seeds presently used in random number generation. <a href="group__debug.html#gaaf64c49f51b622702e66d917bf5b5e16">More...</a><br /></td></tr>
<tr class="separator:gaaf64c49f51b622702e66d917bf5b5e16"><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 <img class="formulaInl" alt="$n$" src="form_60.png"/>-th complex amplitude given by <img class="formulaInl" alt="$2n/10 + i(2n+1)/10$" src="form_61.png"/>. <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:gab27234d9ccf440bb5e5d834e8f7e3938"><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="group__debug.html#gab27234d9ccf440bb5e5d834e8f7e3938">reportPauliHamil</a> (<a class="el" href="structPauliHamil.html">PauliHamil</a> hamil)</td></tr>
<tr class="memdesc:gab27234d9ccf440bb5e5d834e8f7e3938"><td class="mdescLeft"> </td><td class="mdescRight">Print the <code><a class="el" href="structPauliHamil.html" title="A Pauli Hamiltonian, expressed as a real-weighted sum of pauli products, and which can hence represen...">PauliHamil</a></code> to screen. <a href="group__debug.html#gab27234d9ccf440bb5e5d834e8f7e3938">More...</a><br /></td></tr>
<tr class="separator:gab27234d9ccf440bb5e5d834e8f7e3938"><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:ga555451c697ea4a9d27389155f68fdabc"><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="group__debug.html#ga555451c697ea4a9d27389155f68fdabc">seedQuEST</a> (<a class="el" href="structQuESTEnv.html">QuESTEnv</a> *env, unsigned long int *seedArray, int numSeeds)</td></tr>
<tr class="memdesc:ga555451c697ea4a9d27389155f68fdabc"><td class="mdescLeft"> </td><td class="mdescRight">Seeds the random number generator with a custom array of key(s), overriding the default keys. <a href="group__debug.html#ga555451c697ea4a9d27389155f68fdabc">More...</a><br /></td></tr>
<tr class="separator:ga555451c697ea4a9d27389155f68fdabc"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:gae53fad7ebafccf236ad62b41e3244214"><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="group__debug.html#gae53fad7ebafccf236ad62b41e3244214">seedQuESTDefault</a> (<a class="el" href="structQuESTEnv.html">QuESTEnv</a> *env)</td></tr>
<tr class="memdesc:gae53fad7ebafccf236ad62b41e3244214"><td class="mdescLeft"> </td><td class="mdescRight">Seeds the random number generator with the (master node) current time and process ID. <a href="group__debug.html#gae53fad7ebafccf236ad62b41e3244214">More...</a><br /></td></tr>
<tr class="separator:gae53fad7ebafccf236ad62b41e3244214"><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 state-vector 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><div class="fragment"><div class="line"><a class="code" href="group__debug.html#ga924ef2dbda6b733b4041270077c76ece">copyStateFromGPU</a>(qureg);</div>
<div class="line">qureg.<a class="code" href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">stateVec</a>.real[0] = 1;</div>
<div class="line"><a class="code" href="group__debug.html#ga11448560006dd165128e404b54ebb2f7">copyStateToGPU</a>(qureg);</div>
</div><!-- fragment --><p>Note users should never access qureg.deviceStateVec directly.</p>
<dl class="section see"><dt>See also</dt><dd><ul>
<li><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></li>
</ul>
</dd></dl>
<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 <code>.deviceStateVec</code> to <code>.stateVec</code> 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#l00045">45</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="l00045"></a><span class="lineno"> 45</span>  {</div>
<div class="line"><a name="l00046"></a><span class="lineno"> 46</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#l00346">Qureg::deviceStateVec</a>, <a class="el" href="QuEST_8h_source.html#l00332">Qureg::numAmpsPerChunk</a>, and <a class="el" href="QuEST_8h_source.html#l00341">Qureg::stateVec</a>.</p>
<p class="reference">Referenced by <a class="el" href="utilities_8cpp_source.html#l00856">areEqual()</a>, <a class="el" href="QuEST__gpu_8cu_source.html#l01632">densmatr_calcTotalProb()</a>, <a class="el" href="QuEST__gpu_8cu_source.html#l01655">statevec_calcTotalProb()</a>, <a class="el" href="QuEST__gpu_8cu_source.html#l00771">statevec_compareStates()</a>, <a class="el" href="QuEST__gpu_8cu_source.html#l00543">statevec_reportStateToScreen()</a>, <a class="el" href="test__data__structures_8cpp_source.html#l00768">TEST_CASE()</a>, <a class="el" href="utilities_8cpp_source.html#l01071">toQMatrix()</a>, and <a class="el" href="utilities_8cpp_source.html#l01113">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 state-vector 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><div class="fragment"><div class="line"><a class="code" href="group__debug.html#ga924ef2dbda6b733b4041270077c76ece">copyStateFromGPU</a>(qureg);</div>
<div class="line">qureg.<a class="code" href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">stateVec</a>.real[0] = 1;</div>
<div class="line"><a class="code" href="group__debug.html#ga11448560006dd165128e404b54ebb2f7">copyStateToGPU</a>(qureg);</div>
</div><!-- fragment --><p>Note users should never access qureg.deviceStateVec directly.</p>
<dl class="section see"><dt>See also</dt><dd><ul>
<li><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></li>
</ul>
</dd></dl>
<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 <code>.stateVec</code> to <code>.deviceStateVec</code> 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#l00042">42</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="l00042"></a><span class="lineno"> 42</span>  {</div>
<div class="line"><a name="l00043"></a><span class="lineno"> 43</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#l00346">Qureg::deviceStateVec</a>, <a class="el" href="QuEST_8h_source.html#l00332">Qureg::numAmpsPerChunk</a>, and <a class="el" href="QuEST_8h_source.html#l00341">Qureg::stateVec</a>.</p>
<p class="reference">Referenced by <a class="el" href="QuEST__gpu_8cu_source.html#l00727">statevec_initStateFromSingleFile()</a>, <a class="el" href="test__data__structures_8cpp_source.html#l00768">TEST_CASE()</a>, and <a class="el" href="utilities_8cpp_source.html#l01201">toQureg()</a>.</p>
</div>
</div>
<a id="gadc5c01d8ea32e28c188db52be26116b6"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gadc5c01d8ea32e28c188db52be26116b6">◆ </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">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 information about the runtime environment, including whether simulation is using CUDA (for GPU), OpenMP (for multithreading) and/or MPI (for distribution). </p>
<p>The number of CPU threads and distributed ranks is also reported. Note there is currently no reporting of the number of GPU cores used.</p>
<p>The string format is: </p><div class="fragment"><div class="line"><span class="stringliteral">"CUDA=b OpenMP=b MPI=b threads=n ranks=n"</span></div>
</div><!-- fragment --><p>where <b>b</b> is 0 or 1, and <b>n</b> are integers.</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">[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>
<dd>
Tyson Jones </dd></dl>
<p class="definition">Definition at line <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00198">198</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="l00198"></a><span class="lineno"> 198</span>  {</div>
<div class="line"><a name="l00199"></a><span class="lineno"> 199</span>  <span class="keywordtype">int</span> ompStatus=0;</div>
<div class="line"><a name="l00200"></a><span class="lineno"> 200</span>  <span class="keywordtype">int</span> numThreads=1;</div>
<div class="line"><a name="l00201"></a><span class="lineno"> 201</span> <span class="preprocessor"># ifdef _OPENMP</span></div>
<div class="line"><a name="l00202"></a><span class="lineno"> 202</span>  ompStatus=1;</div>
<div class="line"><a name="l00203"></a><span class="lineno"> 203</span>  numThreads=omp_get_max_threads(); </div>
<div class="line"><a name="l00204"></a><span class="lineno"> 204</span> <span class="preprocessor"># endif</span></div>
<div class="line"><a name="l00205"></a><span class="lineno"> 205</span>  sprintf(str, <span class="stringliteral">"CUDA=0 OpenMP=%d MPI=1 threads=%d ranks=%d"</span>, ompStatus, numThreads, env.<a class="code" href="structQuESTEnv.html#af22aacd7c9905accae28484785c193b4">numRanks</a>);</div>
<div class="line"><a name="l00206"></a><span class="lineno"> 206</span> }</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST_8h_source.html#l00365">QuESTEnv::numRanks</a>.</p>
</div>
</div>
<a id="gaaf64c49f51b622702e66d917bf5b5e16"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gaaf64c49f51b622702e66d917bf5b5e16">◆ </a></span>getQuESTSeeds()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void getQuESTSeeds </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">unsigned long int ** </td>
<td class="paramname"><em>seeds</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>Obtain the seeds presently used in random number generation. </p>
<p>This function sets argument <code>seeds</code> to the address of the array of keys which have seeded QuEST's <a href="http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/MT2002/emt19937ar.html">Mersenne Twister</a> random number generator. <code>numSeeds</code> is set to the length of <code>seeds</code>. These are the seeds which inform the outcomes of random functions like <a class="el" href="group__normgate.html#ga2a3794103125f1e3cfa103f8b1963656" title="Measures a single qubit, collapsing it randomly to 0 or 1.">measure()</a>, and are set using <a class="el" href="group__debug.html#ga555451c697ea4a9d27389155f68fdabc" title="Seeds the random number generator with a custom array of key(s), overriding the default keys.">seedQuEST()</a> and <a class="el" href="group__debug.html#gae53fad7ebafccf236ad62b41e3244214" title="Seeds the random number generator with the (master node) current time and process ID.">seedQuESTDefault()</a>.</p>
<blockquote class="doxtable">
<p>The output <code>seeds</code> array <b>must not</b> be freed, and should not be modified. </p>
</blockquote>
<p>Obtaining QuEST's seeds is useful for seeding your own random number generators, so that a simulation (with random QuEST measurements, and your own random decisions) can be precisely repeated later, just by calling <a class="el" href="group__debug.html#ga555451c697ea4a9d27389155f68fdabc" title="Seeds the random number generator with a custom array of key(s), overriding the default keys.">seedQuEST()</a>.</p>
<p>Note this function merely sets the arguments to the attributes for <code>env</code>. I.e. </p><div class="fragment"><div class="line"><span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span>* seeds;</div>
<div class="line"><span class="keywordtype">int</span> numSeeds;</div>
<div class="line"><a class="code" href="group__debug.html#gaaf64c49f51b622702e66d917bf5b5e16">getQuESTSeeds</a>(env, &seeds, &numSeeds);</div>
<div class="line"> </div>
<div class="line">func(seeds, numSeeds);</div>
</div><!-- fragment --><p>is equivalent to </p><div class="fragment"><div class="line">func(env.<a class="code" href="structQuESTEnv.html#a66feaa60d3adc7dcf6f8b66514989356">seeds</a>, env.<a class="code" href="structQuESTEnv.html#a46e67e1a5ab930e04ff59f83f1d8630d">numSeeds</a>);</div>
</div><!-- fragment --><p>However, one should not rely upon their local pointer from <a class="el" href="group__debug.html#gaaf64c49f51b622702e66d917bf5b5e16" title="Obtain the seeds presently used in random number generation.">getQuESTSeeds()</a> to be automatically updated after a subsequent call to <a class="el" href="group__debug.html#ga555451c697ea4a9d27389155f68fdabc" title="Seeds the random number generator with a custom array of key(s), overriding the default keys.">seedQuEST()</a> or <a class="el" href="group__debug.html#gae53fad7ebafccf236ad62b41e3244214" title="Seeds the random number generator with the (master node) current time and process ID.">seedQuESTDefault()</a>. Instead, <a class="el" href="group__debug.html#gaaf64c49f51b622702e66d917bf5b5e16" title="Obtain the seeds presently used in random number generation.">getQuESTSeeds()</a> should be recalled.</p>
<dl class="section see"><dt>See also</dt><dd><ul>
<li><a class="el" href="group__debug.html#ga555451c697ea4a9d27389155f68fdabc" title="Seeds the random number generator with a custom array of key(s), overriding the default keys.">seedQuEST()</a></li>
<li><a class="el" href="group__debug.html#gae53fad7ebafccf236ad62b41e3244214" title="Seeds the random number generator with the (master node) current time and process ID.">seedQuESTDefault()</a></li>
</ul>
</dd></dl>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramdir">[in]</td><td class="paramname">env</td><td>the <a class="el" href="structQuESTEnv.html" title="Information about the environment the program is running in.">QuESTEnv</a> runtime environment </td></tr>
<tr><td class="paramdir">[in]</td><td class="paramname">seeds</td><td>a pointer to an unitialised array to be modified </td></tr>
<tr><td class="paramdir">[in]</td><td class="paramname">numSeeds</td><td>a pointer to an integer to be modified </td></tr>
</table>
</dd>
</dl>
<dl class="section author"><dt>Author</dt><dd>Tyson Jones </dd></dl>
<p class="definition">Definition at line <a class="el" href="QuEST_8c_source.html#l01622">1622</a> of file <a class="el" href="QuEST_8c_source.html">QuEST.c</a>.</p>
<div class="fragment"><div class="line"><a name="l01622"></a><span class="lineno"> 1622</span>  {</div>
<div class="line"><a name="l01623"></a><span class="lineno"> 1623</span>  *seeds = env.<a class="code" href="structQuESTEnv.html#a66feaa60d3adc7dcf6f8b66514989356">seeds</a>;</div>
<div class="line"><a name="l01624"></a><span class="lineno"> 1624</span>  *numSeeds = env.<a class="code" href="structQuESTEnv.html#a46e67e1a5ab930e04ff59f83f1d8630d">numSeeds</a>;</div>
<div class="line"><a name="l01625"></a><span class="lineno"> 1625</span> }</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST_8h_source.html#l00367">QuESTEnv::numSeeds</a>, and <a class="el" href="QuEST_8h_source.html#l00366">QuESTEnv::seeds</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 <img class="formulaInl" alt="$n$" src="form_60.png"/>-th complex amplitude given by <img class="formulaInl" alt="$2n/10 + i(2n+1)/10$" src="form_61.png"/>. </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#l01578">1578</a> of file <a class="el" href="QuEST_8c_source.html">QuEST.c</a>.</p>
<div class="fragment"><div class="line"><a name="l01578"></a><span class="lineno"> 1578</span>  {</div>
<div class="line"><a name="l01579"></a><span class="lineno"> 1579</span>  <a class="code" href="QuEST__internal_8h.html#ad9fd3017ea40cf63fd04b39e03494972">statevec_initDebugState</a>(qureg);</div>
<div class="line"><a name="l01580"></a><span class="lineno"> 1580</span> }</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST__cpu_8c_source.html#l01657">statevec_initDebugState()</a>.</p>
<p class="reference">Referenced by <a class="el" href="test__calculations_8cpp_source.html#l00117">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"><a class="el" href="group__debug.html#ga51a64b05d31ef9bcf6a63ce26c0092db" title="An internal function called when invalid arguments are passed to a QuEST API call,...">invalidQuESTInputError()</a></td><td><ul>
<li>unless overriden by the user </li>
</ul>
</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#l00209">209</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="l00209"></a><span class="lineno"> 209</span>  {</div>
<div class="line"><a name="l00210"></a><span class="lineno"> 210</span>  <a class="code" href="QuEST__validation_8c.html#a4904c29bfd00713c13ce54bf40a6afe1">default_invalidQuESTInputError</a>(errMsg, errFunc);</div>
<div class="line"><a name="l00211"></a><span class="lineno"> 211</span> }</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST__validation_8c_source.html#l00199">default_invalidQuESTInputError()</a>.</p>
<p class="reference">Referenced by <a class="el" href="QuEST__validation_8c_source.html#l00216">QuESTAssert()</a>, <a class="el" href="QuEST__validation_8c_source.html#l00543">validateFileOpened()</a>, <a class="el" href="QuEST__validation_8c_source.html#l00673">validateHamilFileCoeffParsed()</a>, <a class="el" href="QuEST__validation_8c_source.html#l00664">validateHamilFileParams()</a>, <a class="el" href="QuEST__validation_8c_source.html#l00693">validateHamilFilePauliCode()</a>, and <a class="el" href="QuEST__validation_8c_source.html#l00683">validateHamilFilePauliParsed()</a>.</p>
</div>
</div>
<a id="gab27234d9ccf440bb5e5d834e8f7e3938"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gab27234d9ccf440bb5e5d834e8f7e3938">◆ </a></span>reportPauliHamil()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void reportPauliHamil </td>
<td>(</td>
<td class="paramtype"><a class="el" href="structPauliHamil.html">PauliHamil</a> </td>
<td class="paramname"><em>hamil</em></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Print the <code><a class="el" href="structPauliHamil.html" title="A Pauli Hamiltonian, expressed as a real-weighted sum of pauli products, and which can hence represen...">PauliHamil</a></code> to screen. </p>
<p>The output features a new line for each term, each with format </p><pre class="fragment">c p1 p2 p3 ... pN
</pre><p>where <code>c</code> is the real coefficient of the term, and <code>p1</code> ... <code>pN</code> are numbers <code>0</code>, <code>1</code>, <code>2</code>, <code>3</code> to indicate identity, pauliX, pauliY and pauliZ operators respectively, acting on qubits <code>0</code> through <code>N-1</code> (all qubits). A tab character separates c and p1, but single spaces separate the Pauli operators.</p>
<dl class="section see"><dt>See also</dt><dd><ul>
<li><a class="el" href="group__type.html#ga35b28710877c462927366fa602e591cb" title="Dynamically allocates a Hamiltonian expressed as a real-weighted sum of products of Pauli operators.">createPauliHamil()</a></li>
<li><a class="el" href="group__type.html#gadbe6701dda1d49168f2f23253e370a7a" title="Initialise PauliHamil instance hamil with the given term coefficients and Pauli codes (one for every ...">initPauliHamil()</a></li>
<li><a class="el" href="group__type.html#gaa77376c5e3518186eb085f37826d6008" title="Creates a PauliHamil instance, a real-weighted sum of products of Pauli operators,...">createPauliHamilFromFile()</a></li>
</ul>
</dd></dl>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramdir">[in]</td><td class="paramname">hamil</td><td>an instantiated <a class="el" href="structPauliHamil.html" title="A Pauli Hamiltonian, expressed as a real-weighted sum of pauli products, and which can hence represen...">PauliHamil</a> </td></tr>
</table>
</dd>
</dl>
<dl class="exception"><dt>Exceptions</dt><dd>
<table class="exception">
<tr><td class="paramname">invalidQuESTInputError</td><td>if the parameters of <code>hamil</code> are invalid, i.e. if <code>numQubits</code> <= 0, or if <code>numSumTerms</code> <= 0, or if <code>pauliCodes</code> contains an invalid Pauli code. </td></tr>
</table>
</dd>
</dl>
<dl class="section author"><dt>Author</dt><dd>Tyson Jones </dd></dl>
<p class="definition">Definition at line <a class="el" href="QuEST_8c_source.html#l01598">1598</a> of file <a class="el" href="QuEST_8c_source.html">QuEST.c</a>.</p>
<div class="fragment"><div class="line"><a name="l01598"></a><span class="lineno"> 1598</span>  {</div>
<div class="line"><a name="l01599"></a><span class="lineno"> 1599</span>  <a class="code" href="QuEST__validation_8c.html#a066b0c4d0b02a0f3b9be7e5c68d9de6a">validatePauliHamil</a>(hamil, __func__);</div>
<div class="line"><a name="l01600"></a><span class="lineno"> 1600</span>  </div>
<div class="line"><a name="l01601"></a><span class="lineno"> 1601</span>  <span class="keywordflow">for</span> (<span class="keywordtype">int</span> t=0; t<hamil.<a class="code" href="structPauliHamil.html#a737e46b40ef8990cf004d22eb9dbe2e4">numSumTerms</a>; t++) {</div>
<div class="line"><a name="l01602"></a><span class="lineno"> 1602</span>  printf(REAL_QASM_FORMAT, hamil.<a class="code" href="structPauliHamil.html#ac1c6c9f6299cf83bbba88123216c3cac">termCoeffs</a>[t]);</div>
<div class="line"><a name="l01603"></a><span class="lineno"> 1603</span>  printf(<span class="stringliteral">"\t"</span>);</div>
<div class="line"><a name="l01604"></a><span class="lineno"> 1604</span>  <span class="keywordflow">for</span> (<span class="keywordtype">int</span> q=0; q<hamil.<a class="code" href="structPauliHamil.html#acb49fff0e3160ea1904c9ca34408b4e1">numQubits</a>; q++)</div>
<div class="line"><a name="l01605"></a><span class="lineno"> 1605</span>  printf(<span class="stringliteral">"%d "</span>, (<span class="keywordtype">int</span>) hamil.<a class="code" href="structPauliHamil.html#a4b8d38c403553c07ceddcd40c46ce6c8">pauliCodes</a>[q+t*hamil.<a class="code" href="structPauliHamil.html#acb49fff0e3160ea1904c9ca34408b4e1">numQubits</a>]);</div>
<div class="line"><a name="l01606"></a><span class="lineno"> 1606</span>  printf(<span class="stringliteral">"\n"</span>);</div>
<div class="line"><a name="l01607"></a><span class="lineno"> 1607</span>  }</div>
<div class="line"><a name="l01608"></a><span class="lineno"> 1608</span> }</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST_8h_source.html#l00287">PauliHamil::numQubits</a>, <a class="el" href="QuEST_8h_source.html#l00285">PauliHamil::numSumTerms</a>, <a class="el" href="QuEST_8h_source.html#l00281">PauliHamil::pauliCodes</a>, <a class="el" href="QuEST_8h_source.html#l00283">PauliHamil::termCoeffs</a>, and <a class="el" href="QuEST__validation_8c_source.html#l00655">validatePauliHamil()</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#l00183">183</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="l00183"></a><span class="lineno"> 183</span>  {</div>
<div class="line"><a name="l00184"></a><span class="lineno"> 184</span>  <span class="keywordflow">if</span> (env.<a class="code" href="structQuESTEnv.html#aa648bb336cf8598467cb62db00b9cee8">rank</a>==0){</div>
<div class="line"><a name="l00185"></a><span class="lineno"> 185</span>  printf(<span class="stringliteral">"EXECUTION ENVIRONMENT:\n"</span>); </div>
<div class="line"><a name="l00186"></a><span class="lineno"> 186</span>  printf(<span class="stringliteral">"Running distributed (MPI) version\n"</span>);</div>
<div class="line"><a name="l00187"></a><span class="lineno"> 187</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="l00188"></a><span class="lineno"> 188</span> <span class="preprocessor"># ifdef _OPENMP</span></div>
<div class="line"><a name="l00189"></a><span class="lineno"> 189</span>  printf(<span class="stringliteral">"OpenMP enabled\n"</span>);</div>
<div class="line"><a name="l00190"></a><span class="lineno"> 190</span>  printf(<span class="stringliteral">"Number of threads available is %d\n"</span>, omp_get_max_threads());</div>
<div class="line"><a name="l00191"></a><span class="lineno"> 191</span> <span class="preprocessor"># else</span></div>
<div class="line"><a name="l00192"></a><span class="lineno"> 192</span>  printf(<span class="stringliteral">"OpenMP disabled\n"</span>);</div>
<div class="line"><a name="l00193"></a><span class="lineno"> 193</span> <span class="preprocessor"># endif </span></div>
<div class="line"><a name="l00194"></a><span class="lineno"> 194</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="l00195"></a><span class="lineno"> 195</span>  }</div>
<div class="line"><a name="l00196"></a><span class="lineno"> 196</span> }</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST_8h_source.html#l00365">QuESTEnv::numRanks</a>, <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>, and <a class="el" href="QuEST_8h_source.html#l00364">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#l00237">237</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="l00237"></a><span class="lineno"> 237</span>  {</div>
<div class="line"><a name="l00238"></a><span class="lineno"> 238</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="l00239"></a><span class="lineno"> 239</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="l00240"></a><span class="lineno"> 240</span>  <span class="keywordflow">if</span> (qureg.<a class="code" href="structQureg.html#ac2929e681d3d95591c18cf168dbbe4f0">chunkId</a>==0){</div>
<div class="line"><a name="l00241"></a><span class="lineno"> 241</span>  printf(<span class="stringliteral">"QUBITS:\n"</span>);</div>
<div class="line"><a name="l00242"></a><span class="lineno"> 242</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="l00243"></a><span class="lineno"> 243</span>  printf(<span class="stringliteral">"Number of amps is %lld.\n"</span>, numAmps);</div>
<div class="line"><a name="l00244"></a><span class="lineno"> 244</span>  printf(<span class="stringliteral">"Number of amps per rank is %lld.\n"</span>, numAmpsPerRank);</div>
<div class="line"><a name="l00245"></a><span class="lineno"> 245</span>  }</div>
<div class="line"><a name="l00246"></a><span class="lineno"> 246</span> }</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST_8h_source.html#l00336">Qureg::chunkId</a>, <a class="el" href="QuEST_8h_source.html#l00338">Qureg::numChunks</a>, and <a class="el" href="QuEST_8h_source.html#l00329">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#l00219">219</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="l00219"></a><span class="lineno"> 219</span>  {</div>
<div class="line"><a name="l00220"></a><span class="lineno"> 220</span>  FILE *state;</div>
<div class="line"><a name="l00221"></a><span class="lineno"> 221</span>  <span class="keywordtype">char</span> filename[100];</div>
<div class="line"><a name="l00222"></a><span class="lineno"> 222</span>  <span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> index;</div>
<div class="line"><a name="l00223"></a><span class="lineno"> 223</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="l00224"></a><span class="lineno"> 224</span>  state = fopen(filename, <span class="stringliteral">"w"</span>);</div>
<div class="line"><a name="l00225"></a><span class="lineno"> 225</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="l00226"></a><span class="lineno"> 226</span>  </div>
<div class="line"><a name="l00227"></a><span class="lineno"> 227</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="l00228"></a><span class="lineno"> 228</span> <span class="preprocessor"> # if QuEST_PREC==1 || QuEST_PREC==2</span></div>
<div class="line"><a name="l00229"></a><span class="lineno"> 229</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="l00230"></a><span class="lineno"> 230</span> <span class="preprocessor"> # elif QuEST_PREC == 4</span></div>
<div class="line"><a name="l00231"></a><span class="lineno"> 231</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="l00232"></a><span class="lineno"> 232</span> <span class="preprocessor"> #endif</span></div>
<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>  fclose(state);</div>
<div class="line"><a name="l00235"></a><span class="lineno"> 235</span> }</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST_8h_source.html#l00336">Qureg::chunkId</a>, <a class="el" href="QuEST_8h_source.html#l00332">Qureg::numAmpsPerChunk</a>, and <a class="el" href="QuEST_8h_source.html#l00341">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#l01594">1594</a> of file <a class="el" href="QuEST_8c_source.html">QuEST.c</a>.</p>
<div class="fragment"><div class="line"><a name="l01594"></a><span class="lineno"> 1594</span>  {</div>
<div class="line"><a name="l01595"></a><span class="lineno"> 1595</span>  <a class="code" href="QuEST__internal_8h.html#a1e57230c7995447039e62a84c0a36524">statevec_reportStateToScreen</a>(qureg, env, reportRank);</div>
<div class="line"><a name="l01596"></a><span class="lineno"> 1596</span> }</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST__cpu_8c_source.html#l01439">statevec_reportStateToScreen()</a>.</p>
</div>
</div>
<a id="ga555451c697ea4a9d27389155f68fdabc"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga555451c697ea4a9d27389155f68fdabc">◆ </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"><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">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>Seeds the random number generator with a custom array of key(s), overriding the default keys. </p>
<p>This determines the sequence of outcomes in functions like <a class="el" href="group__normgate.html#ga2a3794103125f1e3cfa103f8b1963656" title="Measures a single qubit, collapsing it randomly to 0 or 1.">measure()</a> and <a class="el" href="group__normgate.html#gae192ac0759e46c7b20a7182020155240" title="Measures a single qubit, collapsing it randomly to 0 or 1, and additionally gives the probability of ...">measureWithStats()</a>.</p>
<p>In distributed mode, the key(s) passed to the master node will be broadcast to all other nodes, such that every node generates the same sequence of pseudorandom numbers.</p>
<p>This function will copy the contents of <code>seedArray</code> into a permanent array <code>env.seeds</code>, so <code>seedArray</code> is afterward safe to free.</p>
<blockquote class="doxtable">
<p>QuEST uses the <a href="http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/MT2002/emt19937ar.html">Mersenne Twister</a> for random number generation. </p>
</blockquote>
<dl class="section see"><dt>See also</dt><dd><ul>
<li>Use <a class="el" href="group__debug.html#gae53fad7ebafccf236ad62b41e3244214" title="Seeds the random number generator with the (master node) current time and process ID.">seedQuESTDefault()</a> to seed via the current timestamp and process id.</li>
<li>Use <a class="el" href="group__debug.html#gaaf64c49f51b622702e66d917bf5b5e16" title="Obtain the seeds presently used in random number generation.">getQuESTSeeds()</a> to obtain the seeds currently being used for RNG.</li>
</ul>
</dd></dl>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramdir">[in]</td><td class="paramname">env</td><td>a pointer to the <a class="el" href="structQuESTEnv.html" title="Information about the environment the program is running in.">QuESTEnv</a> runtime environment </td></tr>
<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>
<dd>
Tyson Jones (doc) </dd></dl>
<p class="definition">Definition at line <a class="el" href="QuEST__cpu__distributed_8c_source.html#l01388">1388</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="l01388"></a><span class="lineno"> 1388</span>  {</div>
<div class="line"><a name="l01389"></a><span class="lineno"> 1389</span>  </div>
<div class="line"><a name="l01390"></a><span class="lineno"> 1390</span>  <span class="comment">// it is imperative every node agrees on the seed, so that random decisions </span></div>
<div class="line"><a name="l01391"></a><span class="lineno"> 1391</span>  <span class="comment">// agree on every node. Hence we use only the master node keys.</span></div>
<div class="line"><a name="l01392"></a><span class="lineno"> 1392</span>  MPI_Bcast(seedArray, numSeeds, MPI_UNSIGNED_LONG, 0, MPI_COMM_WORLD);</div>
<div class="line"><a name="l01393"></a><span class="lineno"> 1393</span>  </div>
<div class="line"><a name="l01394"></a><span class="lineno"> 1394</span>  <span class="comment">// free existing seed array, if exists</span></div>
<div class="line"><a name="l01395"></a><span class="lineno"> 1395</span>  <span class="keywordflow">if</span> (env-><a class="code" href="structQuESTEnv.html#a66feaa60d3adc7dcf6f8b66514989356">seeds</a> != NULL)</div>
<div class="line"><a name="l01396"></a><span class="lineno"> 1396</span>  free(env-><a class="code" href="structQuESTEnv.html#a66feaa60d3adc7dcf6f8b66514989356">seeds</a>);</div>
<div class="line"><a name="l01397"></a><span class="lineno"> 1397</span>  </div>
<div class="line"><a name="l01398"></a><span class="lineno"> 1398</span>  <span class="comment">// record keys in permanent heap</span></div>
<div class="line"><a name="l01399"></a><span class="lineno"> 1399</span>  env-><a class="code" href="structQuESTEnv.html#a66feaa60d3adc7dcf6f8b66514989356">seeds</a> = malloc(numSeeds * <span class="keyword">sizeof</span> *(env-><a class="code" href="structQuESTEnv.html#a66feaa60d3adc7dcf6f8b66514989356">seeds</a>));</div>
<div class="line"><a name="l01400"></a><span class="lineno"> 1400</span>  <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i=0; i<numSeeds; i++)</div>
<div class="line"><a name="l01401"></a><span class="lineno"> 1401</span>  (env-><a class="code" href="structQuESTEnv.html#a66feaa60d3adc7dcf6f8b66514989356">seeds</a>)[i] = seedArray[i];</div>
<div class="line"><a name="l01402"></a><span class="lineno"> 1402</span>  env-><a class="code" href="structQuESTEnv.html#a46e67e1a5ab930e04ff59f83f1d8630d">numSeeds</a> = numSeeds;</div>
<div class="line"><a name="l01403"></a><span class="lineno"> 1403</span>  </div>
<div class="line"><a name="l01404"></a><span class="lineno"> 1404</span>  <span class="comment">// pass keys to Mersenne Twister seeder</span></div>
<div class="line"><a name="l01405"></a><span class="lineno"> 1405</span>  <a class="code" href="mt19937ar_8c.html#ac1283f9b1ed571332f5ffe53545ffc16">init_by_array</a>(seedArray, numSeeds); </div>
<div class="line"><a name="l01406"></a><span class="lineno"> 1406</span> }</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="mt19937ar_8c_source.html#l00080">init_by_array()</a>, <a class="el" href="QuEST_8h_source.html#l00367">QuESTEnv::numSeeds</a>, and <a class="el" href="QuEST_8h_source.html#l00366">QuESTEnv::seeds</a>.</p>
<p class="reference">Referenced by <a class="el" href="QuEST_8c_source.html#l01614">seedQuESTDefault()</a>.</p>
</div>
</div>
<a id="gae53fad7ebafccf236ad62b41e3244214"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gae53fad7ebafccf236ad62b41e3244214">◆ </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"><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>Seeds the random number generator with the (master node) current time and process ID. </p>
<p>This is the default seeding used by <a class="el" href="group__type.html#ga8ba2c3388dd64d9348c3b091852d36d4" title="Create the QuEST execution environment.">createQuESTEnv()</a>, and determines the outcomes in functions like <a class="el" href="group__normgate.html#ga2a3794103125f1e3cfa103f8b1963656" title="Measures a single qubit, collapsing it randomly to 0 or 1.">measure()</a> and <a class="el" href="group__normgate.html#gae192ac0759e46c7b20a7182020155240" title="Measures a single qubit, collapsing it randomly to 0 or 1, and additionally gives the probability of ...">measureWithStats()</a>.</p>
<p>In distributed mode, every node agrees on the seed (nominated by the master node) such that every node generates the same sequence of pseudorandom numbers.</p>
<blockquote class="doxtable">
<p>QuEST uses the <a href="http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/MT2002/emt19937ar.html">Mersenne Twister</a> for random number generation. </p>
</blockquote>
<dl class="section see"><dt>See also</dt><dd><ul>
<li>Use <a class="el" href="group__debug.html#ga555451c697ea4a9d27389155f68fdabc" title="Seeds the random number generator with a custom array of key(s), overriding the default keys.">seedQuEST()</a> to provide a custom seed, overriding the default.</li>
<li>Use <a class="el" href="group__debug.html#gaaf64c49f51b622702e66d917bf5b5e16" title="Obtain the seeds presently used in random number generation.">getQuESTSeeds()</a> to obtain the seeds currently being used for RNG.</li>
</ul>
</dd></dl>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramdir">[in]</td><td class="paramname">env</td><td>a pointer to the <a class="el" href="structQuESTEnv.html" title="Information about the environment the program is running in.">QuESTEnv</a> runtime environment </td></tr>
</table>
</dd>
</dl>
<dl class="section author"><dt>Author</dt><dd>Ania Brown </dd>
<dd>
Balint Koczor (Windows compatibility) </dd>
<dd>
Tyson Jones (doc) </dd></dl>
<p class="definition">Definition at line <a class="el" href="QuEST_8c_source.html#l01614">1614</a> of file <a class="el" href="QuEST_8c_source.html">QuEST.c</a>.</p>
<div class="fragment"><div class="line"><a name="l01614"></a><span class="lineno"> 1614</span>  {</div>
<div class="line"><a name="l01615"></a><span class="lineno"> 1615</span>  </div>
<div class="line"><a name="l01616"></a><span class="lineno"> 1616</span>  <span class="comment">// seed Mersenne Twister random number generator with two keys -- time and pid</span></div>
<div class="line"><a name="l01617"></a><span class="lineno"> 1617</span>  <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> keys[2];</div>
<div class="line"><a name="l01618"></a><span class="lineno"> 1618</span>  <a class="code" href="QuEST__common_8c.html#a2b323b65cd6512720e6aa27c182fcea0">getQuESTDefaultSeedKey</a>(keys);</div>
<div class="line"><a name="l01619"></a><span class="lineno"> 1619</span>  <a class="code" href="group__debug.html#ga555451c697ea4a9d27389155f68fdabc">seedQuEST</a>(env, keys, 2);</div>
<div class="line"><a name="l01620"></a><span class="lineno"> 1620</span> }</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST__common_8c_source.html#l00195">getQuESTDefaultSeedKey()</a>, and <a class="el" href="QuEST__cpu__distributed_8c_source.html#l01388">seedQuEST()</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="section see"><dt>See also</dt><dd><ul>
<li><a class="el" href="group__debug.html#gac7e38d768a1bd79019f88cc1e6295092" title="Performs a logical AND on all successCodes held by all processes.">syncQuESTSuccess()</a></li>
</ul>
</dd></dl>
<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#l00164">164</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="l00164"></a><span class="lineno"> 164</span>  {</div>
<div class="line"><a name="l00165"></a><span class="lineno"> 165</span>  MPI_Barrier(MPI_COMM_WORLD);</div>
<div class="line"><a name="l00166"></a><span class="lineno"> 166</span> }</div>
</div><!-- fragment -->
<p class="reference">Referenced by <a class="el" href="utilities_8cpp_source.html#l00856">areEqual()</a>, <a class="el" href="utilities_8cpp_source.html#l01375">deleteFilesWithPrefixSynch()</a>, <a class="el" href="QuEST__cpu_8c_source.html#l01691">statevec_initStateFromSingleFile()</a>, <a class="el" href="QuEST__cpu_8c_source.html#l01439">statevec_reportStateToScreen()</a>, <a class="el" href="test__data__structures_8cpp_source.html#l00255">TEST_CASE()</a>, <a class="el" href="utilities_8cpp_source.html#l01071">toQMatrix()</a>, <a class="el" href="utilities_8cpp_source.html#l01201">toQureg()</a>, <a class="el" href="utilities_8cpp_source.html#l01113">toQVector()</a>, and <a class="el" href="utilities_8cpp_source.html#l01362">writeToFileSynch()</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#l00168">168</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="l00168"></a><span class="lineno"> 168</span>  {</div>
<div class="line"><a name="l00169"></a><span class="lineno"> 169</span>  <span class="keywordtype">int</span> totalSuccess;</div>
<div class="line"><a name="l00170"></a><span class="lineno"> 170</span>  MPI_Allreduce(&successCode, &totalSuccess, 1, MPI_INT, MPI_LAND, MPI_COMM_WORLD);</div>
<div class="line"><a name="l00171"></a><span class="lineno"> 171</span>  <span class="keywordflow">return</span> totalSuccess;</div>
<div class="line"><a name="l00172"></a><span class="lineno"> 172</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="agroup__debug_html_ga924ef2dbda6b733b4041270077c76ece"><div class="ttname"><a href="group__debug.html#ga924ef2dbda6b733b4041270077c76ece">copyStateFromGPU</a></div><div class="ttdeci">void copyStateFromGPU(Qureg qureg)</div><div class="ttdoc">In GPU mode, this copies the state-vector (or density matrix) from GPU memory (qureg....</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__cpu_8c_source.html#l00045">QuEST_cpu.c:45</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#l00364">QuEST.h:364</a></div></div>
<div class="ttc" id="astructQuESTEnv_html_a46e67e1a5ab930e04ff59f83f1d8630d"><div class="ttname"><a href="structQuESTEnv.html#a46e67e1a5ab930e04ff59f83f1d8630d">QuESTEnv::numSeeds</a></div><div class="ttdeci">int numSeeds</div><div class="ttdef"><b>Definition:</b> <a href="QuEST_8h_source.html#l00367">QuEST.h:367</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#l00338">QuEST.h:338</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#l00195">QuEST_common.c:195</a></div></div>
<div class="ttc" id="agroup__debug_html_gaaf64c49f51b622702e66d917bf5b5e16"><div class="ttname"><a href="group__debug.html#gaaf64c49f51b622702e66d917bf5b5e16">getQuESTSeeds</a></div><div class="ttdeci">void getQuESTSeeds(QuESTEnv env, unsigned long int **seeds, int *numSeeds)</div><div class="ttdoc">Obtain the seeds presently used in random number generation.</div><div class="ttdef"><b>Definition:</b> <a href="QuEST_8c_source.html#l01622">QuEST.c:1622</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#l00329">QuEST.h:329</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#l00209">QuEST_validation.c:209</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#l00336">QuEST.h:336</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#l00332">QuEST.h:332</a></div></div>
<div class="ttc" id="astructPauliHamil_html_ac1c6c9f6299cf83bbba88123216c3cac"><div class="ttname"><a href="structPauliHamil.html#ac1c6c9f6299cf83bbba88123216c3cac">PauliHamil::termCoeffs</a></div><div class="ttdeci">qreal * termCoeffs</div><div class="ttdoc">The real coefficient of each Pauli product. This is an array of length PauliHamil....</div><div class="ttdef"><b>Definition:</b> <a href="QuEST_8h_source.html#l00283">QuEST.h:283</a></div></div>
<div class="ttc" id="astructPauliHamil_html_a4b8d38c403553c07ceddcd40c46ce6c8"><div class="ttname"><a href="structPauliHamil.html#a4b8d38c403553c07ceddcd40c46ce6c8">PauliHamil::pauliCodes</a></div><div class="ttdeci">enum pauliOpType * pauliCodes</div><div class="ttdoc">The Pauli operators acting on each qubit, flattened over every operator.</div><div class="ttdef"><b>Definition:</b> <a href="QuEST_8h_source.html#l00281">QuEST.h:281</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#l01439">QuEST_cpu.c:1439</a></div></div>
<div class="ttc" id="agroup__debug_html_ga11448560006dd165128e404b54ebb2f7"><div class="ttname"><a href="group__debug.html#ga11448560006dd165128e404b54ebb2f7">copyStateToGPU</a></div><div class="ttdeci">void copyStateToGPU(Qureg qureg)</div><div class="ttdoc">In GPU mode, this copies the state-vector (or density matrix) from RAM (qureg.stateVec) to VRAM / GPU...</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__cpu_8c_source.html#l00042">QuEST_cpu.c:42</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#l00365">QuEST.h:365</a></div></div>
<div class="ttc" id="astructPauliHamil_html_a737e46b40ef8990cf004d22eb9dbe2e4"><div class="ttname"><a href="structPauliHamil.html#a737e46b40ef8990cf004d22eb9dbe2e4">PauliHamil::numSumTerms</a></div><div class="ttdeci">int numSumTerms</div><div class="ttdoc">The number of terms in the weighted sum, or the number of Pauli products.</div><div class="ttdef"><b>Definition:</b> <a href="QuEST_8h_source.html#l00285">QuEST.h:285</a></div></div>
<div class="ttc" id="astructQuESTEnv_html_a66feaa60d3adc7dcf6f8b66514989356"><div class="ttname"><a href="structQuESTEnv.html#a66feaa60d3adc7dcf6f8b66514989356">QuESTEnv::seeds</a></div><div class="ttdeci">unsigned long int * seeds</div><div class="ttdef"><b>Definition:</b> <a href="QuEST_8h_source.html#l00366">QuEST.h:366</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#l01657">QuEST_cpu.c:1657</a></div></div>
<div class="ttc" id="aQuEST__validation_8c_html_a066b0c4d0b02a0f3b9be7e5c68d9de6a"><div class="ttname"><a href="QuEST__validation_8c.html#a066b0c4d0b02a0f3b9be7e5c68d9de6a">validatePauliHamil</a></div><div class="ttdeci">void validatePauliHamil(PauliHamil hamil, const char *caller)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__validation_8c_source.html#l00655">QuEST_validation.c:655</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#l00341">QuEST.h:341</a></div></div>
<div class="ttc" id="astructPauliHamil_html_acb49fff0e3160ea1904c9ca34408b4e1"><div class="ttname"><a href="structPauliHamil.html#acb49fff0e3160ea1904c9ca34408b4e1">PauliHamil::numQubits</a></div><div class="ttdeci">int numQubits</div><div class="ttdoc">The number of qubits informing the Hilbert dimension of the Hamiltonian.</div><div class="ttdef"><b>Definition:</b> <a href="QuEST_8h_source.html#l00287">QuEST.h:287</a></div></div>
<div class="ttc" id="agroup__debug_html_ga555451c697ea4a9d27389155f68fdabc"><div class="ttname"><a href="group__debug.html#ga555451c697ea4a9d27389155f68fdabc">seedQuEST</a></div><div class="ttdeci">void seedQuEST(QuESTEnv *env, unsigned long int *seedArray, int numSeeds)</div><div class="ttdoc">Seeds the random number generator with a custom array of key(s), overriding the default keys.</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__cpu__distributed_8c_source.html#l01388">QuEST_cpu_distributed.c:1388</a></div></div>
<div class="ttc" id="aQuEST__validation_8c_html_a4904c29bfd00713c13ce54bf40a6afe1"><div class="ttname"><a href="QuEST__validation_8c.html#a4904c29bfd00713c13ce54bf40a6afe1">default_invalidQuESTInputError</a></div><div class="ttdeci">void default_invalidQuESTInputError(const char *errMsg, const char *errFunc)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__validation_8c_source.html#l00199">QuEST_validation.c:199</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>