quest-rs 0.2.8

Safe Rust wrapper around the Quantum Exact Simulation Toolkit (QuEST)
<!-- 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: Operators</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&amp;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">Operators</div>  </div>
</div><!--header-->
<div class="contents">

<p>Non-physical operators which may be non-unitary, non-norm-preserving, even non-Hermitian.  
<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:ga6fc26cf857db070e12959e59ecfed8a6"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__operator.html#ga6fc26cf857db070e12959e59ecfed8a6">applyPauliSum</a> (<a class="el" href="structQureg.html">Qureg</a> inQureg, enum <a class="el" href="group__type.html#ga1c703cf89629e4e9c7023cd402d67028">pauliOpType</a> *allPauliCodes, <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> *termCoeffs, int numSumTerms, <a class="el" href="structQureg.html">Qureg</a> outQureg)</td></tr>
<tr class="memdesc:ga6fc26cf857db070e12959e59ecfed8a6"><td class="mdescLeft">&#160;</td><td class="mdescRight">Modifies <code>outQureg</code> to be the result of applying the weighted sum of Pauli products (a Hermitian but not necessarily unitary operator) to <code>inQureg</code>.  <a href="group__operator.html#ga6fc26cf857db070e12959e59ecfed8a6">More...</a><br /></td></tr>
<tr class="separator:ga6fc26cf857db070e12959e59ecfed8a6"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<p>Non-physical operators which may be non-unitary, non-norm-preserving, even non-Hermitian. </p>
<h2 class="groupheader">Function Documentation</h2>
<a id="ga6fc26cf857db070e12959e59ecfed8a6"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga6fc26cf857db070e12959e59ecfed8a6">&#9670;&nbsp;</a></span>applyPauliSum()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void applyPauliSum </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>inQureg</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">enum <a class="el" href="group__type.html#ga1c703cf89629e4e9c7023cd402d67028">pauliOpType</a> *&#160;</td>
          <td class="paramname"><em>allPauliCodes</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> *&#160;</td>
          <td class="paramname"><em>termCoeffs</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>numSumTerms</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>outQureg</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Modifies <code>outQureg</code> to be the result of applying the weighted sum of Pauli products (a Hermitian but not necessarily unitary operator) to <code>inQureg</code>. </p>
<p>Note that afterward, <code>outQureg</code> may no longer be normalised and ergo not a statevector or density matrix. Users must therefore be careful passing <code>outQureg</code> to other QuEST functions which assume normalisation in order to function correctly.</p>
<p>Letting <img class="formulaInl" alt="$ \alpha = \sum_i c_i \otimes_j^{N} \hat{\sigma}_{i,j} $" src="form_161.png"/> be the operators indicated by <code>allPauliCodes</code> (where <img class="formulaInl" alt="$ c_i \in $" src="form_134.png"/> <code>termCoeffs</code> and <img class="formulaInl" alt="$ N = $" src="form_135.png"/> <code>qureg.numQubitsRepresented</code>), this function effects <img class="formulaInl" alt="$ \alpha | \psi \rangle $" src="form_162.png"/> on statevector <img class="formulaInl" alt="$ |\psi\rangle $" src="form_163.png"/> and <img class="formulaInl" alt="$\alpha \rho$" src="form_164.png"/> (left matrix multiplication) on density matrix <img class="formulaInl" alt="$ \rho $" src="form_39.png"/>.</p>
<p><code>allPauliCodes</code> is an array of length <code>numSumTerms*<code>qureg.numQubitsRepresented</code> which</code> specifies which Pauli operators to apply, where 0 = <code>PAULI_I</code>, 1 = <code>PAULI_X</code>, 2 = <code>PAULI_Y</code>, 3 = <code>PAULI_Z</code>. For each sum term, a Pauli operator must be specified for EVERY qubit in <code>qureg</code>; each set of <code>numSumTerms</code> operators will be grouped into a product. <code>termCoeffs</code> is an arrray of length <code>numSumTerms</code> containing the term coefficients. For example, on a 3-qubit statevector, </p><pre class="fragment">int paulis[6] = {PAULI_X, PAULI_I, PAULI_I,  PAULI_X, PAULI_Y, PAULI_Z};
qreal coeffs[2] = {1.5, -3.6};
applyPauliSum(inQureg, paulis, coeffs, 2, outQureg);
</pre><p>will apply Hermitian operation <img class="formulaInl" alt="$ (1.5 X I I - 3.6 X Y Z) $" src="form_165.png"/> (where in this notation, the left-most operator applies to the least-significant qubit, i.e. that with index 0).</p>
<p>In theory, <code>inQureg</code> is unchanged though its state is temporarily modified and is reverted by re-applying Paulis (XX=YY=ZZ=I), so may see a change by small numerical errors. The initial state in <code>outQureg</code> is not used.</p>
<p><code>inQureg</code> and <code>outQureg</code> must both be state-vectors, or both density matrices, of equal dimensions. <code>inQureg</code> cannot be <code>outQureg</code>.</p>
<p>This function works by applying each Pauli product to <code>inQureg</code> in turn, and adding the resulting state (weighted by a coefficient in <code>termCoeffs</code>) to the initially-blanked <code>outQureg</code>. Ergo it should scale with the total number of Pauli operators specified (excluding identities), and the qureg dimension.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">inQureg</td><td>the register containing the state which <code>outQureg</code> will be set to, under the action of the Hermitiain operator specified by the Pauli codes. <code>inQureg</code> should be unchanged, though may vary slightly due to numerical error. </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">allPauliCodes</td><td>a list of the Pauli codes (0=PAULI_I, 1=PAULI_X, 2=PAULI_Y, 3=PAULI_Z) of all Paulis involved in the products of terms. A Pauli must be specified for each qubit in the register, in every term of the sum. </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">termCoeffs</td><td>The coefficients of each term in the sum of Pauli products </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">numSumTerms</td><td>The total number of Pauli products specified </td></tr>
    <tr><td class="paramdir">[out]</td><td class="paramname">outQureg</td><td>the qureg to modify to be the result of applyling the weighted Pauli sum operator to the state in <code>inQureg</code> </td></tr>
  </table>
  </dd>
</dl>
<dl class="exception"><dt>Exceptions</dt><dd>
  <table class="exception">
    <tr><td class="paramname">exitWithError</td><td>if any code in <code>allPauliCodes</code> is not in {0,1,2,3}, or if numSumTerms &lt;= 0, or if <code>inQureg</code> is not of the same type and dimensions as <code>outQureg</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#l00806">806</a> of file <a class="el" href="QuEST_8c_source.html">QuEST.c</a>.</p>
<div class="fragment"><div class="line"><a name="l00806"></a><span class="lineno">  806</span>&#160;                                                                                                                       {</div>
<div class="line"><a name="l00807"></a><span class="lineno">  807</span>&#160;    <a class="code" href="QuEST__validation_8c.html#a031812e1cf2c98d72d795cea7bbe73a5">validateMatchingQuregTypes</a>(inQureg, outQureg, __func__);</div>
<div class="line"><a name="l00808"></a><span class="lineno">  808</span>&#160;    <a class="code" href="QuEST__validation_8c.html#a87d22240ccfd81827a2a34b8d569d347">validateMatchingQuregDims</a>(inQureg, outQureg, __func__);</div>
<div class="line"><a name="l00809"></a><span class="lineno">  809</span>&#160;    <a class="code" href="QuEST__validation_8c.html#a5be128290a7bba9a7f12d32cabe2276b">validateNumPauliSumTerms</a>(numSumTerms, __func__);</div>
<div class="line"><a name="l00810"></a><span class="lineno">  810</span>&#160;    <a class="code" href="QuEST__validation_8c.html#aa194ba5f5c6e19c6caa4c715b3dbefcc">validatePauliCodes</a>(allPauliCodes, numSumTerms*inQureg.<a class="code" href="structQureg.html#ad08dff5316b8937f4b2a1417591543dc">numQubitsRepresented</a>, __func__);</div>
<div class="line"><a name="l00811"></a><span class="lineno">  811</span>&#160;    </div>
<div class="line"><a name="l00812"></a><span class="lineno">  812</span>&#160;    <a class="code" href="QuEST__common_8c.html#af71c2470694795a8d639be8ff9c34ed5">statevec_applyPauliSum</a>(inQureg, allPauliCodes, termCoeffs, numSumTerms, outQureg);</div>
<div class="line"><a name="l00813"></a><span class="lineno">  813</span>&#160;    </div>
<div class="line"><a name="l00814"></a><span class="lineno">  814</span>&#160;    <a class="code" href="QuEST__qasm_8c.html#a9a385fde708958617bbeb599064b8dcb">qasm_recordComment</a>(outQureg, <span class="stringliteral">&quot;Here, the register was modified to an undisclosed and possibly unphysical state (applyPauliSum).&quot;</span>);</div>
<div class="line"><a name="l00815"></a><span class="lineno">  815</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST_8h_source.html#l00165">Qureg::numQubitsRepresented</a>, <a class="el" href="QuEST__qasm_8c_source.html#l00120">qasm_recordComment()</a>, <a class="el" href="QuEST__common_8c_source.html#l00493">statevec_applyPauliSum()</a>, <a class="el" href="QuEST__validation_8c_source.html#l00434">validateMatchingQuregDims()</a>, <a class="el" href="QuEST__validation_8c_source.html#l00438">validateMatchingQuregTypes()</a>, <a class="el" href="QuEST__validation_8c_source.html#l00507">validateNumPauliSumTerms()</a>, and <a class="el" href="QuEST__validation_8c_source.html#l00498">validatePauliCodes()</a>.</p>

<p class="reference">Referenced by <a class="el" href="test__operators_8cpp_source.html#l00015">TEST_CASE()</a>.</p>

</div>
</div>
</div><!-- contents -->
<div class="ttc" id="aQuEST__validation_8c_html_a5be128290a7bba9a7f12d32cabe2276b"><div class="ttname"><a href="QuEST__validation_8c.html#a5be128290a7bba9a7f12d32cabe2276b">validateNumPauliSumTerms</a></div><div class="ttdeci">void validateNumPauliSumTerms(int numTerms, const char *caller)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__validation_8c_source.html#l00507">QuEST_validation.c:507</a></div></div>
<div class="ttc" id="aQuEST__validation_8c_html_a87d22240ccfd81827a2a34b8d569d347"><div class="ttname"><a href="QuEST__validation_8c.html#a87d22240ccfd81827a2a34b8d569d347">validateMatchingQuregDims</a></div><div class="ttdeci">void validateMatchingQuregDims(Qureg qureg1, Qureg qureg2, const char *caller)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__validation_8c_source.html#l00434">QuEST_validation.c:434</a></div></div>
<div class="ttc" id="aQuEST__qasm_8c_html_a9a385fde708958617bbeb599064b8dcb"><div class="ttname"><a href="QuEST__qasm_8c.html#a9a385fde708958617bbeb599064b8dcb">qasm_recordComment</a></div><div class="ttdeci">void qasm_recordComment(Qureg qureg, char *comment,...)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__qasm_8c_source.html#l00120">QuEST_qasm.c:120</a></div></div>
<div class="ttc" id="aQuEST__common_8c_html_af71c2470694795a8d639be8ff9c34ed5"><div class="ttname"><a href="QuEST__common_8c.html#af71c2470694795a8d639be8ff9c34ed5">statevec_applyPauliSum</a></div><div class="ttdeci">void statevec_applyPauliSum(Qureg inQureg, enum pauliOpType *allCodes, qreal *termCoeffs, int numSumTerms, Qureg outQureg)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__common_8c_source.html#l00493">QuEST_common.c:493</a></div></div>
<div class="ttc" id="aQuEST__validation_8c_html_a031812e1cf2c98d72d795cea7bbe73a5"><div class="ttname"><a href="QuEST__validation_8c.html#a031812e1cf2c98d72d795cea7bbe73a5">validateMatchingQuregTypes</a></div><div class="ttdeci">void validateMatchingQuregTypes(Qureg qureg1, Qureg qureg2, const char *caller)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__validation_8c_source.html#l00438">QuEST_validation.c:438</a></div></div>
<div class="ttc" id="astructQureg_html_ad08dff5316b8937f4b2a1417591543dc"><div class="ttname"><a href="structQureg.html#ad08dff5316b8937f4b2a1417591543dc">Qureg::numQubitsRepresented</a></div><div class="ttdeci">int numQubitsRepresented</div><div class="ttdoc">The number of qubits represented in either the state-vector or density matrix.</div><div class="ttdef"><b>Definition:</b> <a href="QuEST_8h_source.html#l00165">QuEST.h:165</a></div></div>
<div class="ttc" id="aQuEST__validation_8c_html_aa194ba5f5c6e19c6caa4c715b3dbefcc"><div class="ttname"><a href="QuEST__validation_8c.html#aa194ba5f5c6e19c6caa4c715b3dbefcc">validatePauliCodes</a></div><div class="ttdeci">void validatePauliCodes(enum pauliOpType *pauliCodes, int numPauliCodes, const char *caller)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__validation_8c_source.html#l00498">QuEST_validation.c:498</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>