<!-- 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.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">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:gad2e953390342cd361cfb4064d47715e6"><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="group__operator.html#gad2e953390342cd361cfb4064d47715e6">applyDiagonalOp</a> (<a class="el" href="structQureg.html">Qureg</a> qureg, <a class="el" href="structDiagonalOp.html">DiagonalOp</a> op)</td></tr>
<tr class="memdesc:gad2e953390342cd361cfb4064d47715e6"><td class="mdescLeft"> </td><td class="mdescRight">Apply a diagonal operator, which is possibly non-unitary and non-Hermitian, to the entire <code>qureg</code>. <a href="group__operator.html#gad2e953390342cd361cfb4064d47715e6">More...</a><br /></td></tr>
<tr class="separator:gad2e953390342cd361cfb4064d47715e6"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:gaf26f32c25db760065486188497c1da8b"><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="group__operator.html#gaf26f32c25db760065486188497c1da8b">applyFullQFT</a> (<a class="el" href="structQureg.html">Qureg</a> qureg)</td></tr>
<tr class="memdesc:gaf26f32c25db760065486188497c1da8b"><td class="mdescLeft"> </td><td class="mdescRight">Applies the quantum Fourier transform (QFT) to the entirety of <code>qureg</code>. <a href="group__operator.html#gaf26f32c25db760065486188497c1da8b">More...</a><br /></td></tr>
<tr class="separator:gaf26f32c25db760065486188497c1da8b"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:gadfb5c1d99a22ce666fc715a8da2e0950"><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="group__operator.html#gadfb5c1d99a22ce666fc715a8da2e0950">applyMatrix2</a> (<a class="el" href="structQureg.html">Qureg</a> qureg, int targetQubit, <a class="el" href="structComplexMatrix2.html">ComplexMatrix2</a> u)</td></tr>
<tr class="memdesc:gadfb5c1d99a22ce666fc715a8da2e0950"><td class="mdescLeft"> </td><td class="mdescRight">Apply a general 2-by-2 matrix, which may be non-unitary. <a href="group__operator.html#gadfb5c1d99a22ce666fc715a8da2e0950">More...</a><br /></td></tr>
<tr class="separator:gadfb5c1d99a22ce666fc715a8da2e0950"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:ga74a955ec4bce606d89317bcfc528387f"><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="group__operator.html#ga74a955ec4bce606d89317bcfc528387f">applyMatrix4</a> (<a class="el" href="structQureg.html">Qureg</a> qureg, int targetQubit1, int targetQubit2, <a class="el" href="structComplexMatrix4.html">ComplexMatrix4</a> u)</td></tr>
<tr class="memdesc:ga74a955ec4bce606d89317bcfc528387f"><td class="mdescLeft"> </td><td class="mdescRight">Apply a general 4-by-4 matrix, which may be non-unitary. <a href="group__operator.html#ga74a955ec4bce606d89317bcfc528387f">More...</a><br /></td></tr>
<tr class="separator:ga74a955ec4bce606d89317bcfc528387f"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:ga358e7094a98851afa86d27f0147e32a1"><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="group__operator.html#ga358e7094a98851afa86d27f0147e32a1">applyMatrixN</a> (<a class="el" href="structQureg.html">Qureg</a> qureg, int *targs, int numTargs, <a class="el" href="structComplexMatrixN.html">ComplexMatrixN</a> u)</td></tr>
<tr class="memdesc:ga358e7094a98851afa86d27f0147e32a1"><td class="mdescLeft"> </td><td class="mdescRight">Apply a general N-by-N matrix, which may be non-unitary, on any number of target qubits. <a href="group__operator.html#ga358e7094a98851afa86d27f0147e32a1">More...</a><br /></td></tr>
<tr class="separator:ga358e7094a98851afa86d27f0147e32a1"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:gab52b6315c5520b7d311b0458785eed8e"><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="group__operator.html#gab52b6315c5520b7d311b0458785eed8e">applyMultiControlledMatrixN</a> (<a class="el" href="structQureg.html">Qureg</a> qureg, int *ctrls, int numCtrls, int *targs, int numTargs, <a class="el" href="structComplexMatrixN.html">ComplexMatrixN</a> u)</td></tr>
<tr class="memdesc:gab52b6315c5520b7d311b0458785eed8e"><td class="mdescLeft"> </td><td class="mdescRight">Apply a general N-by-N matrix, which may be non-unitary, with additional controlled qubits. <a href="group__operator.html#gab52b6315c5520b7d311b0458785eed8e">More...</a><br /></td></tr>
<tr class="separator:gab52b6315c5520b7d311b0458785eed8e"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:ga008a46d178a5a9691e2f5d363e3f518f"><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="group__operator.html#ga008a46d178a5a9691e2f5d363e3f518f">applyMultiVarPhaseFunc</a> (<a class="el" href="structQureg.html">Qureg</a> qureg, int *qubits, int *numQubitsPerReg, int numRegs, enum <a class="el" href="group__type.html#ga9c91c41aa42ae537995e89ffc616afe1">bitEncoding</a> encoding, <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> *coeffs, <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> *exponents, int *numTermsPerReg)</td></tr>
<tr class="memdesc:ga008a46d178a5a9691e2f5d363e3f518f"><td class="mdescLeft"> </td><td class="mdescRight">Induces a phase change upon each amplitude of <code>qureg</code>, determined by a multi-variable exponential polynomial "phase function". <a href="group__operator.html#ga008a46d178a5a9691e2f5d363e3f518f">More...</a><br /></td></tr>
<tr class="separator:ga008a46d178a5a9691e2f5d363e3f518f"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:ga8dca543fb4d1ee1cd8b4c5d6028b3075"><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="group__operator.html#ga8dca543fb4d1ee1cd8b4c5d6028b3075">applyMultiVarPhaseFuncOverrides</a> (<a class="el" href="structQureg.html">Qureg</a> qureg, int *qubits, int *numQubitsPerReg, int numRegs, enum <a class="el" href="group__type.html#ga9c91c41aa42ae537995e89ffc616afe1">bitEncoding</a> encoding, <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> *coeffs, <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> *exponents, int *numTermsPerReg, long long int *overrideInds, <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> *overridePhases, int numOverrides)</td></tr>
<tr class="memdesc:ga8dca543fb4d1ee1cd8b4c5d6028b3075"><td class="mdescLeft"> </td><td class="mdescRight">Induces a phase change upon each amplitude of <code>qureg</code>, determined by a multi-variable exponential polynomial "phase function", and an explicit set of 'overriding' values at specific state indices. <a href="group__operator.html#ga8dca543fb4d1ee1cd8b4c5d6028b3075">More...</a><br /></td></tr>
<tr class="separator:ga8dca543fb4d1ee1cd8b4c5d6028b3075"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:gac4df97d8c125c8cc65df720f67b2bf69"><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="group__operator.html#gac4df97d8c125c8cc65df720f67b2bf69">applyNamedPhaseFunc</a> (<a class="el" href="structQureg.html">Qureg</a> qureg, int *qubits, int *numQubitsPerReg, int numRegs, enum <a class="el" href="group__type.html#ga9c91c41aa42ae537995e89ffc616afe1">bitEncoding</a> encoding, enum <a class="el" href="group__type.html#gaa7d869b117ba5024d6b84938e8cdfc65">phaseFunc</a> functionNameCode)</td></tr>
<tr class="memdesc:gac4df97d8c125c8cc65df720f67b2bf69"><td class="mdescLeft"> </td><td class="mdescRight">Induces a phase change upon each amplitude of <code>qureg</code>, determined by a named (and potentially multi-variable) phase function. <a href="group__operator.html#gac4df97d8c125c8cc65df720f67b2bf69">More...</a><br /></td></tr>
<tr class="separator:gac4df97d8c125c8cc65df720f67b2bf69"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:ga2fbaec3bb21cc01f7a2a4ed2aa911ebf"><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="group__operator.html#ga2fbaec3bb21cc01f7a2a4ed2aa911ebf">applyNamedPhaseFuncOverrides</a> (<a class="el" href="structQureg.html">Qureg</a> qureg, int *qubits, int *numQubitsPerReg, int numRegs, enum <a class="el" href="group__type.html#ga9c91c41aa42ae537995e89ffc616afe1">bitEncoding</a> encoding, enum <a class="el" href="group__type.html#gaa7d869b117ba5024d6b84938e8cdfc65">phaseFunc</a> functionNameCode, long long int *overrideInds, <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> *overridePhases, int numOverrides)</td></tr>
<tr class="memdesc:ga2fbaec3bb21cc01f7a2a4ed2aa911ebf"><td class="mdescLeft"> </td><td class="mdescRight">Induces a phase change upon each amplitude of <code>qureg</code>, determined by a named (and potentially multi-variable) phase function, and an explicit set of 'overriding' values at specific state indices. <a href="group__operator.html#ga2fbaec3bb21cc01f7a2a4ed2aa911ebf">More...</a><br /></td></tr>
<tr class="separator:ga2fbaec3bb21cc01f7a2a4ed2aa911ebf"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:ga225b82ff8b8eed1fff312240ec70c731"><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="group__operator.html#ga225b82ff8b8eed1fff312240ec70c731">applyParamNamedPhaseFunc</a> (<a class="el" href="structQureg.html">Qureg</a> qureg, int *qubits, int *numQubitsPerReg, int numRegs, enum <a class="el" href="group__type.html#ga9c91c41aa42ae537995e89ffc616afe1">bitEncoding</a> encoding, enum <a class="el" href="group__type.html#gaa7d869b117ba5024d6b84938e8cdfc65">phaseFunc</a> functionNameCode, <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> *params, int numParams)</td></tr>
<tr class="memdesc:ga225b82ff8b8eed1fff312240ec70c731"><td class="mdescLeft"> </td><td class="mdescRight">Induces a phase change upon each amplitude of <code>qureg</code>, determined by a named, paramaterized (and potentially multi-variable) phase function. <a href="group__operator.html#ga225b82ff8b8eed1fff312240ec70c731">More...</a><br /></td></tr>
<tr class="separator:ga225b82ff8b8eed1fff312240ec70c731"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:gaabd7efa3beebc9f3a525321d41a28989"><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="group__operator.html#gaabd7efa3beebc9f3a525321d41a28989">applyParamNamedPhaseFuncOverrides</a> (<a class="el" href="structQureg.html">Qureg</a> qureg, int *qubits, int *numQubitsPerReg, int numRegs, enum <a class="el" href="group__type.html#ga9c91c41aa42ae537995e89ffc616afe1">bitEncoding</a> encoding, enum <a class="el" href="group__type.html#gaa7d869b117ba5024d6b84938e8cdfc65">phaseFunc</a> functionNameCode, <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> *params, int numParams, long long int *overrideInds, <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> *overridePhases, int numOverrides)</td></tr>
<tr class="memdesc:gaabd7efa3beebc9f3a525321d41a28989"><td class="mdescLeft"> </td><td class="mdescRight">Induces a phase change upon each amplitude of <code>qureg</code>, determined by a named, parameterised (and potentially multi-variable) phase function, and an explicit set of 'overriding' values at specific state indices. <a href="group__operator.html#gaabd7efa3beebc9f3a525321d41a28989">More...</a><br /></td></tr>
<tr class="separator:gaabd7efa3beebc9f3a525321d41a28989"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:ga54d4e589468002bdc998200ae45e7312"><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="group__operator.html#ga54d4e589468002bdc998200ae45e7312">applyPauliHamil</a> (<a class="el" href="structQureg.html">Qureg</a> inQureg, <a class="el" href="structPauliHamil.html">PauliHamil</a> hamil, <a class="el" href="structQureg.html">Qureg</a> outQureg)</td></tr>
<tr class="memdesc:ga54d4e589468002bdc998200ae45e7312"><td class="mdescLeft"> </td><td class="mdescRight">Modifies <code>outQureg</code> to be the result of applying <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> (a Hermitian but not necessarily unitary operator) to <code>inQureg</code>. <a href="group__operator.html#ga54d4e589468002bdc998200ae45e7312">More...</a><br /></td></tr>
<tr class="separator:ga54d4e589468002bdc998200ae45e7312"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:ga6fc26cf857db070e12959e59ecfed8a6"><td class="memItemLeft" align="right" valign="top">void </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"> </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"> </td></tr>
<tr class="memitem:ga467f517abd18dbc3d6fced84c6589161"><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="group__operator.html#ga467f517abd18dbc3d6fced84c6589161">applyPhaseFunc</a> (<a class="el" href="structQureg.html">Qureg</a> qureg, int *qubits, int numQubits, enum <a class="el" href="group__type.html#ga9c91c41aa42ae537995e89ffc616afe1">bitEncoding</a> encoding, <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> *coeffs, <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> *exponents, int numTerms)</td></tr>
<tr class="memdesc:ga467f517abd18dbc3d6fced84c6589161"><td class="mdescLeft"> </td><td class="mdescRight">Induces a phase change upon each amplitude of <code>qureg</code>, determined by the passed exponential polynomial "phase function". <a href="group__operator.html#ga467f517abd18dbc3d6fced84c6589161">More...</a><br /></td></tr>
<tr class="separator:ga467f517abd18dbc3d6fced84c6589161"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:gaf5344129240243ad11d0c081eb9036ab"><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="group__operator.html#gaf5344129240243ad11d0c081eb9036ab">applyPhaseFuncOverrides</a> (<a class="el" href="structQureg.html">Qureg</a> qureg, int *qubits, int numQubits, enum <a class="el" href="group__type.html#ga9c91c41aa42ae537995e89ffc616afe1">bitEncoding</a> encoding, <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> *coeffs, <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> *exponents, int numTerms, long long int *overrideInds, <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> *overridePhases, int numOverrides)</td></tr>
<tr class="memdesc:gaf5344129240243ad11d0c081eb9036ab"><td class="mdescLeft"> </td><td class="mdescRight">Induces a phase change upon each amplitude of <code>qureg</code>, determined by the passed exponential polynomial "phase function", and an explicit set of 'overriding' values at specific state indices. <a href="group__operator.html#gaf5344129240243ad11d0c081eb9036ab">More...</a><br /></td></tr>
<tr class="separator:gaf5344129240243ad11d0c081eb9036ab"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:ga26db8b8a8a242d388c291e50d228ab18"><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="group__operator.html#ga26db8b8a8a242d388c291e50d228ab18">applyProjector</a> (<a class="el" href="structQureg.html">Qureg</a> qureg, int qubit, int outcome)</td></tr>
<tr class="memdesc:ga26db8b8a8a242d388c291e50d228ab18"><td class="mdescLeft"> </td><td class="mdescRight">Force the target <code>qubit</code> of <code>qureg</code> into the given classical <code>outcome</code>, via a non-renormalising projection. <a href="group__operator.html#ga26db8b8a8a242d388c291e50d228ab18">More...</a><br /></td></tr>
<tr class="separator:ga26db8b8a8a242d388c291e50d228ab18"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:ga9bc8c4ab44f8233b5766208a0b1c0776"><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="group__operator.html#ga9bc8c4ab44f8233b5766208a0b1c0776">applyQFT</a> (<a class="el" href="structQureg.html">Qureg</a> qureg, int *qubits, int numQubits)</td></tr>
<tr class="memdesc:ga9bc8c4ab44f8233b5766208a0b1c0776"><td class="mdescLeft"> </td><td class="mdescRight">Applies the quantum Fourier transform (QFT) to a specific subset of qubits of the register <code>qureg</code>. <a href="group__operator.html#ga9bc8c4ab44f8233b5766208a0b1c0776">More...</a><br /></td></tr>
<tr class="separator:ga9bc8c4ab44f8233b5766208a0b1c0776"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:ga35b6321c578a8c69470132b5ee95f930"><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="group__operator.html#ga35b6321c578a8c69470132b5ee95f930">applyTrotterCircuit</a> (<a class="el" href="structQureg.html">Qureg</a> qureg, <a class="el" href="structPauliHamil.html">PauliHamil</a> hamil, <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> time, int order, int reps)</td></tr>
<tr class="memdesc:ga35b6321c578a8c69470132b5ee95f930"><td class="mdescLeft"> </td><td class="mdescRight">Applies a trotterisation of unitary evolution <img class="formulaInl" alt="$ \exp(-i \, \text{hamil} \, \text{time}) $" src="form_235.png"/> to <code>qureg</code>. <a href="group__operator.html#ga35b6321c578a8c69470132b5ee95f930">More...</a><br /></td></tr>
<tr class="separator:ga35b6321c578a8c69470132b5ee95f930"><td class="memSeparator" colspan="2"> </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="gad2e953390342cd361cfb4064d47715e6"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gad2e953390342cd361cfb4064d47715e6">◆ </a></span>applyDiagonalOp()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void applyDiagonalOp </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="structDiagonalOp.html">DiagonalOp</a> </td>
<td class="paramname"><em>op</em> </td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Apply a diagonal operator, which is possibly non-unitary and non-Hermitian, to the entire <code>qureg</code>. </p>
<p>Let <img class="formulaInl" alt="$d_j = \text{op.real}[j] + (\text{op.imag}[j])\,\text{i} $" src="form_36.png"/>, and </p><p class="formulaDsp">
<img class="formulaDsp" alt="\[ \hat{D} = \begin{pmatrix} d_0 \\ & d_1 \\ & & \ddots \\ & & & d_{2^{\text{op.numQubits}}-1} \end{pmatrix}. \]" src="form_37.png"/>
</p>
<p> If <code>qureg</code> is a state-vector <img class="formulaInl" alt="$|\psi\rangle$" src="form_38.png"/>, this function performs <img class="formulaInl" alt="$|\psi\rangle \rightarrow \hat{D} \, |\psi\rangle$" src="form_39.png"/>. <br />
If <code>qureg</code> is a density-matrix <img class="formulaInl" alt="$\rho$" src="form_40.png"/>, this function performs <img class="formulaInl" alt="$\rho \rightarrow \hat{D}\, \rho$" src="form_41.png"/>. Notice this has not applied <img class="formulaInl" alt="$\hat{D}$" src="form_42.png"/> in the fashion of a unitary.</p>
<blockquote class="doxtable">
<p>If your operator is unitary with unit amplitudes, the phases of which can be described by an analytic expression, you should instead use <a class="el" href="group__operator.html#ga467f517abd18dbc3d6fced84c6589161" title="Induces a phase change upon each amplitude of qureg, determined by the passed exponential polynomial ...">applyPhaseFunc()</a> or <a class="el" href="group__operator.html#gac4df97d8c125c8cc65df720f67b2bf69" title="Induces a phase change upon each amplitude of qureg, determined by a named (and potentially multi-var...">applyNamedPhaseFunc()</a> for significant memory and runtime savings. </p>
</blockquote>
<dl class="section see"><dt>See also</dt><dd><ul>
<li><a class="el" href="group__type.html#gaebf896dd8d5eeaf9fd896f6cc8e334fe" title="Creates a DiagonalOp representing a diagonal operator on the full Hilbert space of a Qureg.">createDiagonalOp()</a></li>
<li><a class="el" href="group__calc.html#ga82f17e96a4cb7612fb9c6ef856df3810" title="Computes the expected value of the diagonal operator op for state qureg.">calcExpecDiagonalOp()</a></li>
<li><a class="el" href="group__operator.html#ga467f517abd18dbc3d6fced84c6589161" title="Induces a phase change upon each amplitude of qureg, determined by the passed exponential polynomial ...">applyPhaseFunc()</a></li>
<li><a class="el" href="group__operator.html#gac4df97d8c125c8cc65df720f67b2bf69" title="Induces a phase change upon each amplitude of qureg, determined by a named (and potentially multi-var...">applyNamedPhaseFunc()</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 state to operate the diagonal operator upon </td></tr>
<tr><td class="paramdir">[in]</td><td class="paramname">op</td><td>the diagonal operator to apply </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>if <code>op</code> was not created</li>
<li>if <code>op</code> acts on a different number of qubits than <code>qureg</code> represents </li>
</ul>
</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#l01127">1127</a> of file <a class="el" href="QuEST_8c_source.html">QuEST.c</a>.</p>
<div class="fragment"><div class="line"><a name="l01127"></a><span class="lineno"> 1127</span>  {</div>
<div class="line"><a name="l01128"></a><span class="lineno"> 1128</span>  <a class="code" href="QuEST__validation_8c.html#a8a656a83bf0b44447188d06c2f8114cb">validateDiagonalOp</a>(qureg, op, __func__);</div>
<div class="line"><a name="l01129"></a><span class="lineno"> 1129</span>  </div>
<div class="line"><a name="l01130"></a><span class="lineno"> 1130</span>  <span class="keywordflow">if</span> (qureg.<a class="code" href="structQureg.html#acf78445e9435d09f44f0cc832c6aee79">isDensityMatrix</a>)</div>
<div class="line"><a name="l01131"></a><span class="lineno"> 1131</span>  <a class="code" href="QuEST__internal_8h.html#aedd7ecccf2f09dd2f1c5d191950b51e6">densmatr_applyDiagonalOp</a>(qureg, op);</div>
<div class="line"><a name="l01132"></a><span class="lineno"> 1132</span>  <span class="keywordflow">else</span></div>
<div class="line"><a name="l01133"></a><span class="lineno"> 1133</span>  <a class="code" href="QuEST__internal_8h.html#a27294e3065ebe42a65b3b9e0f85551dd">statevec_applyDiagonalOp</a>(qureg, op);</div>
<div class="line"><a name="l01134"></a><span class="lineno"> 1134</span>  </div>
<div class="line"><a name="l01135"></a><span class="lineno"> 1135</span>  <a class="code" href="QuEST__qasm_8c.html#a9a385fde708958617bbeb599064b8dcb">qasm_recordComment</a>(qureg, <span class="stringliteral">"Here, the register was modified to an undisclosed and possibly unphysical state (via applyDiagonalOp)."</span>);</div>
<div class="line"><a name="l01136"></a><span class="lineno"> 1136</span> }</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST__cpu__distributed_8c_source.html#l01594">densmatr_applyDiagonalOp()</a>, <a class="el" href="QuEST_8h_source.html#l00325">Qureg::isDensityMatrix</a>, <a class="el" href="QuEST__qasm_8c_source.html#l00121">qasm_recordComment()</a>, <a class="el" href="QuEST__cpu_8c_source.html#l04047">statevec_applyDiagonalOp()</a>, and <a class="el" href="QuEST__validation_8c_source.html#l00713">validateDiagonalOp()</a>.</p>
<p class="reference">Referenced by <a class="el" href="test__data__structures_8cpp_source.html#l00768">TEST_CASE()</a>.</p>
</div>
</div>
<a id="gaf26f32c25db760065486188497c1da8b"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gaf26f32c25db760065486188497c1da8b">◆ </a></span>applyFullQFT()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void applyFullQFT </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>Applies the quantum Fourier transform (QFT) to the entirety of <code>qureg</code>. </p>
<p>The effected unitary circuit (shown here for 4 qubits, bottom qubit is <b>0</b>) resembles </p><p class="formulaDsp">
<img class="formulaDsp" alt="\[ \begin{tikzpicture}[scale=.5] \draw (-2, 5) -- (23, 5); \draw (-2, 3) -- (23, 3); \draw (-2, 1) -- (23, 1); \draw (-2, -1) -- (23, -1); \draw[fill=white] (-1, 4) -- (-1, 6) -- (1, 6) -- (1,4) -- cycle; \node[draw=none] at (0, 5) {H}; \draw(2, 5) -- (2, 3); \draw[fill=black] (2, 5) circle (.2); \draw[fill=black] (2, 3) circle (.2); \draw(4, 5) -- (4, 1); \draw[fill=black] (4, 5) circle (.2); \draw[fill=black] (4, 1) circle (.2); \draw(6, 5) -- (6, -1); \draw[fill=black] (6, 5) circle (.2); \draw[fill=black] (6, -1) circle (.2); \draw[fill=white] (-1+8, 4-2) -- (-1+8, 6-2) -- (1+8, 6-2) -- (1+8,4-2) -- cycle; \node[draw=none] at (8, 5-2) {H}; \draw(10, 5-2) -- (10, 3-2); \draw[fill=black] (10, 5-2) circle (.2); \draw[fill=black] (10, 3-2) circle (.2); \draw(12, 5-2) -- (12, 3-4); \draw[fill=black] (12, 5-2) circle (.2); \draw[fill=black] (12, 3-4) circle (.2); \draw[fill=white] (-1+8+6, 4-4) -- (-1+8+6, 6-4) -- (1+8+6, 6-4) -- (1+8+6,4-4) -- cycle; \node[draw=none] at (8+6, 5-4) {H}; \draw(16, 5-2-2) -- (16, 3-4); \draw[fill=black] (16, 5-2-2) circle (.2); \draw[fill=black] (16, 3-4) circle (.2); \draw[fill=white] (-1+8+6+4, 4-4-2) -- (-1+8+6+4, 6-4-2) -- (1+8+6+4, 6-4-2) -- (1+8+6+4,4-4-2) -- cycle; \node[draw=none] at (8+6+4, 5-4-2) {H}; \draw (20, 5) -- (20, -1); \draw (20 - .35, 5 + .35) -- (20 + .35, 5 - .35); \draw (20 - .35, 5 - .35) -- (20 + .35, 5 + .35); \draw (20 - .35, -1 + .35) -- (20 + .35, -1 - .35); \draw (20 - .35, -1 - .35) -- (20 + .35, -1 + .35); \draw (22, 3) -- (22, 1); \draw (22 - .35, 3 + .35) -- (22 + .35, 3 - .35); \draw (22 - .35, 3 - .35) -- (22 + .35, 3 + .35); \draw (22 - .35, 1 + .35) -- (22 + .35, 1 - .35); \draw (22 - .35, 1 - .35) -- (22 + .35, 1 + .35); \end{tikzpicture} \]" src="form_294.png"/>
</p>
<p> though is performed more efficiently.</p>
<ul>
<li>If <code>qureg</code> is a state-vector, the output amplitudes are the discrete Fourier transform (DFT) of the input amplitudes, in the exact ordering. This is true even if <code>qureg</code> is unnormalised. <br />
Precisely, <p class="formulaDsp">
<img class="formulaDsp" alt="\[ \text{QFT} \, \left( \sum\limits_{x=0}^{2^N-1} \alpha_x |x\rangle \right) = \frac{1}{\sqrt{2^N}} \sum\limits_{x=0}^{2^N-1} \left( \sum\limits_{y=0}^{2^N-1} e^{2 \pi \, i \, x \, y / 2^N} \; \alpha_y \right) |x\rangle \]" src="form_295.png"/>
</p>
</li>
<li>If <code>qureg</code> is a density matrix <img class="formulaInl" alt="$\rho$" src="form_40.png"/>, it will be changed under the unitary action of the QFT. This can be imagined as each mixed state-vector undergoing the DFT on its amplitudes. This is true even if <code>qureg</code> is unnormalised. <p class="formulaDsp">
<img class="formulaDsp" alt="\[ \rho \; \rightarrow \; \text{QFT} \; \rho \; \text{QFT}^{\dagger} \]" src="form_296.png"/>
</p>
</li>
</ul>
<blockquote class="doxtable">
<p>This function merges contiguous controlled-phase gates into single invocations of <a class="el" href="group__operator.html#gac4df97d8c125c8cc65df720f67b2bf69" title="Induces a phase change upon each amplitude of qureg, determined by a named (and potentially multi-var...">applyNamedPhaseFunc()</a>, and hence is significantly faster than performing the QFT circuit directly. </p>
</blockquote>
<blockquote class="doxtable">
<p>Furthermore, in distributed mode, this function requires only <img class="formulaInl" alt="$\log_2(\text{\#nodes})$" src="form_297.png"/> rounds of pair-wise communication, and hence is exponentially faster than directly performing the DFT on the amplitudes of <code>qureg</code>. </p>
</blockquote>
<dl class="section see"><dt>See also</dt><dd><ul>
<li><a class="el" href="group__operator.html#ga9bc8c4ab44f8233b5766208a0b1c0776" title="Applies the quantum Fourier transform (QFT) to a specific subset of qubits of the register qureg.">applyQFT()</a> to apply the QFT to a sub-register of <code>qureg</code>.</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>a state-vector or density matrix to modify </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#l00876">876</a> of file <a class="el" href="QuEST_8c_source.html">QuEST.c</a>.</p>
<div class="fragment"><div class="line"><a name="l00876"></a><span class="lineno"> 876</span>  {</div>
<div class="line"><a name="l00877"></a><span class="lineno"> 877</span>  </div>
<div class="line"><a name="l00878"></a><span class="lineno"> 878</span>  <a class="code" href="QuEST__qasm_8c.html#a9a385fde708958617bbeb599064b8dcb">qasm_recordComment</a>(qureg, <span class="stringliteral">"Beginning of QFT circuit"</span>);</div>
<div class="line"><a name="l00879"></a><span class="lineno"> 879</span>  </div>
<div class="line"><a name="l00880"></a><span class="lineno"> 880</span>  <span class="keywordtype">int</span> qubits[100];</div>
<div class="line"><a name="l00881"></a><span class="lineno"> 881</span>  <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i=0; i<qureg.<a class="code" href="structQureg.html#ad08dff5316b8937f4b2a1417591543dc">numQubitsRepresented</a>; i++)</div>
<div class="line"><a name="l00882"></a><span class="lineno"> 882</span>  qubits[i] = i;</div>
<div class="line"><a name="l00883"></a><span class="lineno"> 883</span>  <a class="code" href="QuEST__common_8c.html#a2b78ab7dd04eab615a0d7c796e73ae8c">agnostic_applyQFT</a>(qureg, qubits, qureg.<a class="code" href="structQureg.html#ad08dff5316b8937f4b2a1417591543dc">numQubitsRepresented</a>);</div>
<div class="line"><a name="l00884"></a><span class="lineno"> 884</span>  </div>
<div class="line"><a name="l00885"></a><span class="lineno"> 885</span>  <a class="code" href="QuEST__qasm_8c.html#a9a385fde708958617bbeb599064b8dcb">qasm_recordComment</a>(qureg, <span class="stringliteral">"End of QFT circuit"</span>);</div>
<div class="line"><a name="l00886"></a><span class="lineno"> 886</span> }</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST__common_8c_source.html#l00849">agnostic_applyQFT()</a>, <a class="el" href="QuEST_8h_source.html#l00327">Qureg::numQubitsRepresented</a>, and <a class="el" href="QuEST__qasm_8c_source.html#l00121">qasm_recordComment()</a>.</p>
<p class="reference">Referenced by <a class="el" href="test__operators_8cpp_source.html#l00083">TEST_CASE()</a>.</p>
</div>
</div>
<a id="gadfb5c1d99a22ce666fc715a8da2e0950"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gadfb5c1d99a22ce666fc715a8da2e0950">◆ </a></span>applyMatrix2()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void applyMatrix2 </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">int </td>
<td class="paramname"><em>targetQubit</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype"><a class="el" href="structComplexMatrix2.html">ComplexMatrix2</a> </td>
<td class="paramname"><em>u</em> </td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Apply a general 2-by-2 matrix, which may be non-unitary. </p>
<p>The matrix is left-multiplied onto the state, for both state-vectors and density matrices.</p>
<p>Note this differs from the action of <a class="el" href="group__unitary.html#ga78b814256f851cac70fdf3cbf9cfc206" title="Apply a general single-qubit unitary (including a global phase factor).">unitary()</a> on a density matrix.</p>
<p>This function may leave <code>qureg</code> is an unnormalised state.</p>
<dl class="section see"><dt>See also</dt><dd><ul>
<li><a class="el" href="structComplexMatrix2.html" title="Represents a 2x2 matrix of complex numbers.">ComplexMatrix2</a></li>
<li><a class="el" href="group__unitary.html#ga78b814256f851cac70fdf3cbf9cfc206" title="Apply a general single-qubit unitary (including a global phase factor).">unitary()</a></li>
</ul>
</dd></dl>
<p><br />
</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 all qubits </td></tr>
<tr><td class="paramdir">[in]</td><td class="paramname">targetQubit</td><td>qubit to operate <code>u</code> upon </td></tr>
<tr><td class="paramdir">[in]</td><td class="paramname">u</td><td>matrix to apply </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>if <code>targetQubit</code> is outside [0, <code>qureg.numQubitsRepresented</code>) </li>
</ul>
</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#l01084">1084</a> of file <a class="el" href="QuEST_8c_source.html">QuEST.c</a>.</p>
<div class="fragment"><div class="line"><a name="l01084"></a><span class="lineno"> 1084</span>  {</div>
<div class="line"><a name="l01085"></a><span class="lineno"> 1085</span>  <a class="code" href="QuEST__validation_8c.html#ac31c45c5a31c523be0eb26abba6cf598">validateTarget</a>(qureg, targetQubit, __func__);</div>
<div class="line"><a name="l01086"></a><span class="lineno"> 1086</span>  </div>
<div class="line"><a name="l01087"></a><span class="lineno"> 1087</span>  <span class="comment">// actually just left-multiplies any complex matrix</span></div>
<div class="line"><a name="l01088"></a><span class="lineno"> 1088</span>  <a class="code" href="QuEST__internal_8h.html#ac3735bd959600e57b2ee3a105666cddf">statevec_unitary</a>(qureg, targetQubit, u);</div>
<div class="line"><a name="l01089"></a><span class="lineno"> 1089</span>  </div>
<div class="line"><a name="l01090"></a><span class="lineno"> 1090</span>  <a class="code" href="QuEST__qasm_8c.html#a9a385fde708958617bbeb599064b8dcb">qasm_recordComment</a>(qureg, <span class="stringliteral">"Here, an undisclosed 2-by-2 matrix (possibly non-unitary) was multiplied onto qubit %d"</span>, targetQubit);</div>
<div class="line"><a name="l01091"></a><span class="lineno"> 1091</span> }</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST__qasm_8c_source.html#l00121">qasm_recordComment()</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00895">statevec_unitary()</a>, and <a class="el" href="QuEST__validation_8c_source.html#l00400">validateTarget()</a>.</p>
<p class="reference">Referenced by <a class="el" href="test__operators_8cpp_source.html#l00203">TEST_CASE()</a>.</p>
</div>
</div>
<a id="ga74a955ec4bce606d89317bcfc528387f"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga74a955ec4bce606d89317bcfc528387f">◆ </a></span>applyMatrix4()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void applyMatrix4 </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">int </td>
<td class="paramname"><em>targetQubit1</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int </td>
<td class="paramname"><em>targetQubit2</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype"><a class="el" href="structComplexMatrix4.html">ComplexMatrix4</a> </td>
<td class="paramname"><em>u</em> </td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Apply a general 4-by-4 matrix, which may be non-unitary. </p>
<p>The matrix is left-multiplied onto the state, for both state-vectors and density matrices.</p>
<p>Note this differs from the action of <a class="el" href="group__unitary.html#gab525a42d63233f61afeb6be97d89dd36" title="Apply a general two-qubit unitary (including a global phase factor).">twoQubitUnitary()</a> on a density matrix.</p>
<p><code>targetQubit1</code> is treated as the <code>least</code> significant qubit in <code>u</code>, such that a row in <code>u</code> is dotted with the vector <img class="formulaInl" alt="$ |\text{targetQubit2} \;\; \text{targetQubit1}\rangle : \{ |00\rangle, |01\rangle, |10\rangle, |11\rangle \} $" src="form_211.png"/></p>
<p>For example, </p><div class="fragment"><div class="line"><a class="code" href="group__operator.html#ga74a955ec4bce606d89317bcfc528387f">applyMatrix4</a>(qureg, a, b, u);</div>
</div><!-- fragment --><p>will invoke multiplication </p><p class="formulaDsp">
<img class="formulaDsp" alt="\[ \begin{pmatrix} u_{00} & u_{01} & u_{02} & u_{03} \\ u_{10} & u_{11} & u_{12} & u_{13} \\ u_{20} & u_{21} & u_{22} & u_{23} \\ u_{30} & u_{31} & u_{32} & u_{33} \end{pmatrix} \begin{pmatrix} |ba\rangle = |00\rangle \\ |ba\rangle = |01\rangle \\ |ba\rangle = |10\rangle \\ |ba\rangle = |11\rangle \end{pmatrix} \]" src="form_212.png"/>
</p>
<p>This function may leave <code>qureg</code> is an unnormalised state.</p>
<p>Note that in distributed mode, this routine requires that each node contains at least 4 amplitudes. This means an q-qubit register (state vector or density matrix) can be distributed by at most 2^q/4 nodes.</p>
<dl class="section see"><dt>See also</dt><dd><ul>
<li><a class="el" href="structComplexMatrix4.html" title="Represents a 4x4 matrix of complex numbers.">ComplexMatrix4</a></li>
<li><a class="el" href="group__unitary.html#gab525a42d63233f61afeb6be97d89dd36" title="Apply a general two-qubit unitary (including a global phase factor).">twoQubitUnitary()</a></li>
</ul>
</dd></dl>
<p><br />
</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 all qubits </td></tr>
<tr><td class="paramdir">[in]</td><td class="paramname">targetQubit1</td><td>first qubit to operate on, treated as least significant in <code>u</code> </td></tr>
<tr><td class="paramdir">[in]</td><td class="paramname">targetQubit2</td><td>second qubit to operate on, treated as most significant in <code>u</code> </td></tr>
<tr><td class="paramdir">[in]</td><td class="paramname">u</td><td>matrix to apply </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>if <code>targetQubit1</code> or <code>targetQubit2</code> are outside [0, <code>qureg.numQubitsRepresented</code>)</li>
<li>if <code>targetQubit1</code> equals <code>targetQubit2</code> </li>
<li>if each node cannot fit 4 amplitudes in distributed mode </li>
</ul>
</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#l01093">1093</a> of file <a class="el" href="QuEST_8c_source.html">QuEST.c</a>.</p>
<div class="fragment"><div class="line"><a name="l01093"></a><span class="lineno"> 1093</span>  {</div>
<div class="line"><a name="l01094"></a><span class="lineno"> 1094</span>  <a class="code" href="QuEST__validation_8c.html#a6776217a5f7ba38b56175cf6db0f96e0">validateMultiTargets</a>(qureg, (<span class="keywordtype">int</span> []) {targetQubit1, targetQubit2}, 2, __func__);</div>
<div class="line"><a name="l01095"></a><span class="lineno"> 1095</span>  <a class="code" href="QuEST__validation_8c.html#aa28b7d9c0c3cf9c4be0e324fb9d6bf76">validateMultiQubitMatrixFitsInNode</a>(qureg, 2, __func__);</div>
<div class="line"><a name="l01096"></a><span class="lineno"> 1096</span>  </div>
<div class="line"><a name="l01097"></a><span class="lineno"> 1097</span>  <span class="comment">// actually just left-multiplies any complex matrix</span></div>
<div class="line"><a name="l01098"></a><span class="lineno"> 1098</span>  <a class="code" href="QuEST__common_8c.html#a95abbe0cedf45b1ff2f070dba219fd7f">statevec_twoQubitUnitary</a>(qureg, targetQubit1, targetQubit2, u);</div>
<div class="line"><a name="l01099"></a><span class="lineno"> 1099</span>  </div>
<div class="line"><a name="l01100"></a><span class="lineno"> 1100</span>  <a class="code" href="QuEST__qasm_8c.html#a9a385fde708958617bbeb599064b8dcb">qasm_recordComment</a>(qureg, <span class="stringliteral">"Here, an undisclosed 4-by-4 matrix (possibly non-unitary) was multiplied onto qubits %d and %d"</span>, targetQubit1, targetQubit2);</div>
<div class="line"><a name="l01101"></a><span class="lineno"> 1101</span> }</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST__qasm_8c_source.html#l00121">qasm_recordComment()</a>, <a class="el" href="QuEST__common_8c_source.html#l00561">statevec_twoQubitUnitary()</a>, <a class="el" href="QuEST__validation_8c_source.html#l00473">validateMultiQubitMatrixFitsInNode()</a>, and <a class="el" href="QuEST__validation_8c_source.html#l00428">validateMultiTargets()</a>.</p>
<p class="reference">Referenced by <a class="el" href="test__operators_8cpp_source.html#l00253">TEST_CASE()</a>.</p>
</div>
</div>
<a id="ga358e7094a98851afa86d27f0147e32a1"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga358e7094a98851afa86d27f0147e32a1">◆ </a></span>applyMatrixN()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void applyMatrixN </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">int * </td>
<td class="paramname"><em>targs</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int </td>
<td class="paramname"><em>numTargs</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype"><a class="el" href="structComplexMatrixN.html">ComplexMatrixN</a> </td>
<td class="paramname"><em>u</em> </td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Apply a general N-by-N matrix, which may be non-unitary, on any number of target qubits. </p>
<p>The matrix is left-multiplied onto the state, for both state-vectors and density matrices. Note this differs from the action of <a class="el" href="group__unitary.html#ga20bf9b8a71b8a3ee4651e9497e6d1f4f" title="Apply a general multi-qubit unitary (including a global phase factor) with any number of target qubit...">multiQubitUnitary()</a> on a density matrix.</p>
<p>The first target qubit in <code>targs</code> is treated as <b>least</b> significant in <code>u</code>. For example, </p><div class="fragment"><div class="line"><a class="code" href="group__operator.html#ga358e7094a98851afa86d27f0147e32a1">applyMatrixN</a>(qureg, (<span class="keywordtype">int</span> []) {a, b, c}, 3, u);</div>
</div><!-- fragment --><p>will invoke multiplication </p><p class="formulaDsp">
<img class="formulaDsp" alt="\[ \begin{pmatrix} u_{00} & u_{01} & u_{02} & u_{03} & u_{04} & u_{05} & u_{06} & u_{07} \\ u_{10} & u_{11} & u_{12} & u_{13} & u_{14} & u_{15} & u_{16} & u_{17} \\ u_{20} & u_{21} & u_{22} & u_{23} & u_{24} & u_{25} & u_{26} & u_{27} \\ u_{30} & u_{31} & u_{32} & u_{33} & u_{34} & u_{35} & u_{36} & u_{37} \\ u_{40} & u_{41} & u_{42} & u_{43} & u_{44} & u_{45} & u_{46} & u_{47} \\ u_{50} & u_{51} & u_{52} & u_{53} & u_{54} & u_{55} & u_{56} & u_{57} \\ u_{60} & u_{61} & u_{62} & u_{63} & u_{64} & u_{65} & u_{66} & u_{67} \\ u_{70} & u_{71} & u_{72} & u_{73} & u_{74} & u_{75} & u_{76} & u_{77} \\ \end{pmatrix} \begin{pmatrix} |cba\rangle = |000\rangle \\ |cba\rangle = |001\rangle \\ |cba\rangle = |010\rangle \\ |cba\rangle = |011\rangle \\ |cba\rangle = |100\rangle \\ |cba\rangle = |101\rangle \\ |cba\rangle = |110\rangle \\ |cba\rangle = |111\rangle \end{pmatrix} \]" src="form_217.png"/>
</p>
<p>This function may leave <code>qureg</code> is an unnormalised state.</p>
<p>The passed ComplexMatrix must be a compatible size with the specified number of target qubits, otherwise an error is thrown.</p>
<p>Note that in multithreaded mode, each thread will clone 2^<code>numTargs</code> amplitudes, and store these in the runtime stack. Using t threads, the total memory overhead of this function is t*2^<code>numTargs</code>. For many targets (e.g. 16 qubits), this may cause a stack-overflow / seg-fault (e.g. on a 1 MiB stack).</p>
<p>Note too that in distributed mode, this routine requires that each node contains at least 2^<code>numTargs</code> amplitudes in the register. This means an q-qubit register (state vector or density matrix) can be distributed by at most 2^q / 2^<code>numTargs</code> nodes.</p>
<dl class="section see"><dt>See also</dt><dd><ul>
<li><a class="el" href="group__type.html#ga815103261fb22ea9690e1427571df00e" title="Allocate dynamic memory for a square complex matrix of any size, which can be passed to functions lik...">createComplexMatrixN()</a></li>
<li><a class="el" href="group__type.html#ga927beeee2ba3b110f33ebb440c154ae2" title="Creates a ComplexMatrixN struct which lives in the stack and so does not need freeing,...">getStaticComplexMatrixN()</a></li>
<li><a class="el" href="group__operator.html#gab52b6315c5520b7d311b0458785eed8e" title="Apply a general N-by-N matrix, which may be non-unitary, with additional controlled qubits.">applyMultiControlledMatrixN()</a></li>
<li><a class="el" href="group__unitary.html#ga20bf9b8a71b8a3ee4651e9497e6d1f4f" title="Apply a general multi-qubit unitary (including a global phase factor) with any number of target qubit...">multiQubitUnitary()</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>object representing the set of all qubits </td></tr>
<tr><td class="paramdir">[in]</td><td class="paramname">targs</td><td>a list of the target qubits, ordered least significant to most in <code>u</code> </td></tr>
<tr><td class="paramdir">[in]</td><td class="paramname">numTargs</td><td>the number of target qubits </td></tr>
<tr><td class="paramdir">[in]</td><td class="paramname">u</td><td>matrix to apply </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>if any index in <code>targs</code> is outside of [0, <code>qureg.numQubitsRepresented</code>)</li>
<li>if <code>targs</code> are not unique</li>
<li>if <code>u</code> is not of a compatible size with <code>numTargs</code> </li>
<li>if a node cannot fit the required number of target amplitudes in distributed mode </li>
</ul>
</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#l01103">1103</a> of file <a class="el" href="QuEST_8c_source.html">QuEST.c</a>.</p>
<div class="fragment"><div class="line"><a name="l01103"></a><span class="lineno"> 1103</span>  {</div>
<div class="line"><a name="l01104"></a><span class="lineno"> 1104</span>  <a class="code" href="QuEST__validation_8c.html#a6776217a5f7ba38b56175cf6db0f96e0">validateMultiTargets</a>(qureg, targs, numTargs, __func__);</div>
<div class="line"><a name="l01105"></a><span class="lineno"> 1105</span>  <a class="code" href="QuEST__validation_8c.html#a576519ac36b7cb25bab78d05b5d1975f">validateMultiQubitMatrix</a>(qureg, u, numTargs, __func__);</div>
<div class="line"><a name="l01106"></a><span class="lineno"> 1106</span>  </div>
<div class="line"><a name="l01107"></a><span class="lineno"> 1107</span>  <span class="comment">// actually just left-multiplies any complex matrix</span></div>
<div class="line"><a name="l01108"></a><span class="lineno"> 1108</span>  <a class="code" href="QuEST__common_8c.html#a7a76950824f17e821415070a4bfdad5b">statevec_multiQubitUnitary</a>(qureg, targs, numTargs, u);</div>
<div class="line"><a name="l01109"></a><span class="lineno"> 1109</span>  </div>
<div class="line"><a name="l01110"></a><span class="lineno"> 1110</span>  <span class="keywordtype">int</span> dim = (1 << numTargs);</div>
<div class="line"><a name="l01111"></a><span class="lineno"> 1111</span>  <a class="code" href="QuEST__qasm_8c.html#a9a385fde708958617bbeb599064b8dcb">qasm_recordComment</a>(qureg, <span class="stringliteral">"Here, an undisclosed %d-by-%d matrix (possibly non-unitary) was multiplied onto %d undisclosed qubits"</span>, dim, dim, numTargs);</div>
<div class="line"><a name="l01112"></a><span class="lineno"> 1112</span> }</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST__qasm_8c_source.html#l00121">qasm_recordComment()</a>, <a class="el" href="QuEST__common_8c_source.html#l00573">statevec_multiQubitUnitary()</a>, <a class="el" href="QuEST__validation_8c_source.html#l00496">validateMultiQubitMatrix()</a>, and <a class="el" href="QuEST__validation_8c_source.html#l00428">validateMultiTargets()</a>.</p>
<p class="reference">Referenced by <a class="el" href="test__operators_8cpp_source.html#l00318">TEST_CASE()</a>.</p>
</div>
</div>
<a id="gab52b6315c5520b7d311b0458785eed8e"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gab52b6315c5520b7d311b0458785eed8e">◆ </a></span>applyMultiControlledMatrixN()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void applyMultiControlledMatrixN </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">int * </td>
<td class="paramname"><em>ctrls</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int </td>
<td class="paramname"><em>numCtrls</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int * </td>
<td class="paramname"><em>targs</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int </td>
<td class="paramname"><em>numTargs</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype"><a class="el" href="structComplexMatrixN.html">ComplexMatrixN</a> </td>
<td class="paramname"><em>u</em> </td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Apply a general N-by-N matrix, which may be non-unitary, with additional controlled qubits. </p>
<p>The matrix is left-multiplied onto the state, for both state-vectors and density matrices. Hence, this function differs from <a class="el" href="group__unitary.html#ga3ad6c477edcdbc845fc1143e860fda08" title="Apply a general multi-controlled multi-qubit unitary (including a global phase factor).">multiControlledMultiQubitUnitary()</a> by more than just permitting a non-unitary matrix.</p>
<p>This function may leave <code>qureg</code> is an unnormalised state.</p>
<p>Any number of control and target qubits can be specified. This effects the many-qubit matrix </p><p class="formulaDsp">
<img class="formulaDsp" alt="\[ \begin{pmatrix} 1 \\ & 1 \\\ & & \ddots \\ & & & u_{00} & u_{01} & \dots \\ & & & u_{10} & u_{11} & \dots \\ & & & \vdots & \vdots & \ddots \end{pmatrix} \]" src="form_221.png"/>
</p>
<p> on the control and target qubits.</p>
<p>The target qubits in <code>targs</code> are treated as ordered least significant to most significant in <code>u</code>.</p>
<p>The passed ComplexMatrix must be a compatible size with the specified number of target qubits, otherwise an error is thrown.</p>
<p>Note that in multithreaded mode, each thread will clone 2^<code>numTargs</code> amplitudes, and store these in the runtime stack. Using t threads, the total memory overhead of this function is t*2^<code>numTargs</code>. For many targets (e.g. 16 qubits), this may cause a stack-overflow / seg-fault (e.g. on a 1 MiB stack).</p>
<p>Note that in distributed mode, this routine requires that each node contains at least 2^<code>numTargs</code> amplitudes. This means an q-qubit register (state vector or density matrix) can be distributed by at most 2^q / 2^<code>numTargs</code> nodes.</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 all qubits </td></tr>
<tr><td class="paramdir">[in]</td><td class="paramname">ctrls</td><td>a list of the control qubits </td></tr>
<tr><td class="paramdir">[in]</td><td class="paramname">numCtrls</td><td>the number of control qubits </td></tr>
<tr><td class="paramdir">[in]</td><td class="paramname">targs</td><td>a list of the target qubits, ordered least to most significant </td></tr>
<tr><td class="paramdir">[in]</td><td class="paramname">numTargs</td><td>the number of target qubits </td></tr>
<tr><td class="paramdir">[in]</td><td class="paramname">u</td><td>matrix to apply </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>if any index in <code>ctrls</code> and <code>targs</code> is outside of [0, <code>qureg.numQubitsRepresented</code>)</li>
<li>if <code>ctrls</code> and <code>targs</code> are not unique</li>
<li>if matrix <code>u</code> is not a compatible size with <code>numTargs</code> </li>
<li>if a node cannot fit the required number of target amplitudes in distributed mode </li>
</ul>
</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#l01114">1114</a> of file <a class="el" href="QuEST_8c_source.html">QuEST.c</a>.</p>
<div class="fragment"><div class="line"><a name="l01114"></a><span class="lineno"> 1114</span>  {</div>
<div class="line"><a name="l01115"></a><span class="lineno"> 1115</span>  <a class="code" href="QuEST__validation_8c.html#a5b0392701c555a898403f80ef4a32f62">validateMultiControlsMultiTargets</a>(qureg, ctrls, numCtrls, targs, numTargs, __func__);</div>
<div class="line"><a name="l01116"></a><span class="lineno"> 1116</span>  <a class="code" href="QuEST__validation_8c.html#a576519ac36b7cb25bab78d05b5d1975f">validateMultiQubitMatrix</a>(qureg, u, numTargs, __func__);</div>
<div class="line"><a name="l01117"></a><span class="lineno"> 1117</span>  </div>
<div class="line"><a name="l01118"></a><span class="lineno"> 1118</span>  <span class="comment">// actually just left-multiplies any complex matrix</span></div>
<div class="line"><a name="l01119"></a><span class="lineno"> 1119</span>  <span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> ctrlMask = <a class="code" href="QuEST__common_8c.html#acc45bb8300922ea5933e294921e25ea2">getQubitBitMask</a>(ctrls, numCtrls);</div>
<div class="line"><a name="l01120"></a><span class="lineno"> 1120</span>  <a class="code" href="QuEST__internal_8h.html#a0acfe30083d0bc2a84da196378a36122">statevec_multiControlledMultiQubitUnitary</a>(qureg, ctrlMask, targs, numTargs, u);</div>
<div class="line"><a name="l01121"></a><span class="lineno"> 1121</span>  </div>
<div class="line"><a name="l01122"></a><span class="lineno"> 1122</span>  <span class="keywordtype">int</span> numTot = numTargs + numCtrls;</div>
<div class="line"><a name="l01123"></a><span class="lineno"> 1123</span>  <span class="keywordtype">int</span> dim = (1 << numTot );</div>
<div class="line"><a name="l01124"></a><span class="lineno"> 1124</span>  <a class="code" href="QuEST__qasm_8c.html#a9a385fde708958617bbeb599064b8dcb">qasm_recordComment</a>(qureg, <span class="stringliteral">"Here, an undisclosed %d-by-%d matrix (possibly non-unitary, and including %d controlled qubits) was multiplied onto %d undisclosed qubits"</span>, dim, dim, numCtrls, numTot);</div>
<div class="line"><a name="l01125"></a><span class="lineno"> 1125</span> }</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST__common_8c_source.html#l00050">getQubitBitMask()</a>, <a class="el" href="QuEST__qasm_8c_source.html#l00121">qasm_recordComment()</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l01514">statevec_multiControlledMultiQubitUnitary()</a>, <a class="el" href="QuEST__validation_8c_source.html#l00459">validateMultiControlsMultiTargets()</a>, and <a class="el" href="QuEST__validation_8c_source.html#l00496">validateMultiQubitMatrix()</a>.</p>
<p class="reference">Referenced by <a class="el" href="test__operators_8cpp_source.html#l00429">TEST_CASE()</a>.</p>
</div>
</div>
<a id="ga008a46d178a5a9691e2f5d363e3f518f"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga008a46d178a5a9691e2f5d363e3f518f">◆ </a></span>applyMultiVarPhaseFunc()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void applyMultiVarPhaseFunc </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">int * </td>
<td class="paramname"><em>qubits</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int * </td>
<td class="paramname"><em>numQubitsPerReg</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int </td>
<td class="paramname"><em>numRegs</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">enum <a class="el" href="group__type.html#ga9c91c41aa42ae537995e89ffc616afe1">bitEncoding</a> </td>
<td class="paramname"><em>encoding</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype"><a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> * </td>
<td class="paramname"><em>coeffs</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype"><a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> * </td>
<td class="paramname"><em>exponents</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int * </td>
<td class="paramname"><em>numTermsPerReg</em> </td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Induces a phase change upon each amplitude of <code>qureg</code>, determined by a multi-variable exponential polynomial "phase function". </p>
<p>This is a multi-variable extension of <a class="el" href="group__operator.html#ga467f517abd18dbc3d6fced84c6589161" title="Induces a phase change upon each amplitude of qureg, determined by the passed exponential polynomial ...">applyPhaseFunc()</a>, whereby multiple sub-registers inform separate variables in the exponential polynomial function, and effects a diagonal unitary operator.</p>
<ul>
<li><p class="startli">Arguments <code>coeffs</code>, <code>exponents</code> and <code>numTermsPerReg</code> together specify a real exponential polynomial <img class="formulaInl" alt="$f(\vec{r})$" src="form_262.png"/> of the form </p><p class="formulaDsp">
<img class="formulaDsp" alt="\[ f(r_1, \; \dots, \; r_{\text{numRegs}}) = \sum\limits_j^{\text{numRegs}} \; \sum\limits_{i}^{\text{numTermsPerReg}[j]} \; c_{i,j} \; {r_j}^{\; p_{i,j}}\,, \]" src="form_263.png"/>
</p>
<p> where both coefficients <img class="formulaInl" alt="$c_{i,j}$" src="form_264.png"/> and exponents <img class="formulaInl" alt="$p_{i,j}$" src="form_265.png"/> can be any real number, subject to constraints described below. <br />
<br />
While <code>coeffs</code> and <code>exponents</code> are flat lists, they should be considered grouped into #<code>numRegs</code> sublists with lengths given by <code>numTermsPerReg</code> (which itself has length <code>numRegs</code>). <br />
<br />
For example, </p><div class="fragment"><div class="line"><span class="keywordtype">int</span> numRegs = 3;</div>
<div class="line"><a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> coeffs[] = {1, 2, 4, -3.14};</div>
<div class="line"><a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> exponents[] = {2, 1, 5, 0.5 };</div>
<div class="line"><span class="keywordtype">int</span> numTermsPerReg[] = {1, 2, 1 };</div>
</div><!-- fragment --><p class="startli">constitutes the function </p><p class="formulaDsp">
<img class="formulaDsp" alt="\[ f(\vec{r}) = 1 \, {r_1}^2 + 2 \, {r_2} + 4 \, {r_2}^{5} - 3.14 \, {r_3}^{0.5}. \]" src="form_266.png"/>
</p>
<p> <br />
</p><blockquote class="doxtable">
<p>This means lists <code>coeffs</code> and <code>exponents</code> should both be of length equal to the sum of <code>numTermsPerReg</code>. </p>
</blockquote>
<p>Unlike <a class="el" href="group__operator.html#ga467f517abd18dbc3d6fced84c6589161" title="Induces a phase change upon each amplitude of qureg, determined by the passed exponential polynomial ...">applyPhaseFunc()</a>, <a class="el" href="group__operator.html#ga008a46d178a5a9691e2f5d363e3f518f" title="Induces a phase change upon each amplitude of qureg, determined by a multi-variable exponential polyn...">applyMultiVarPhaseFunc()</a> places additional constraints on the exponents in <img class="formulaInl" alt="$f(\vec{r})$" src="form_262.png"/>, due to the exponentially growing costs of overriding diverging indices. Namely:<br />
</p><ol type="1">
<li><code>exponents</code> must not contain a negative number, since this would result in a divergence when that register is zero, which would need to be overriden for every other register basis state. If <img class="formulaInl" alt="$f(\vec{r})$" src="form_262.png"/> must contain a negative exponent, you should instead call <a class="el" href="group__operator.html#gaf5344129240243ad11d0c081eb9036ab" title="Induces a phase change upon each amplitude of qureg, determined by the passed exponential polynomial ...">applyPhaseFuncOverrides()</a> once for each register/variable, and override the zero index for the relevant variable. This works, because <p class="formulaDsp">
<img class="formulaDsp" alt="\[ \exp( i \sum_j f_j(r_j) ) = \prod_j \exp(i f_j(r_j) ). \]" src="form_267.png"/>
</p>
</li>
<li><code>exponents</code> must not contain a fractional number if <code>endoding</code> <b>=</b> <a class="el" href="group__type.html#gga9c91c41aa42ae537995e89ffc616afe1a9aa2a35d92976c7de970506c4d19a96c">TWOS_COMPLEMENT</a>, because such a term would produce illegal complex values at negative register indices. Similar to the problem above, each negative register index would require overriding at every index of the other registers, and hence require an exponential number of overrides. Therefore, if <img class="formulaInl" alt="$f(\vec{r})$" src="form_262.png"/> must contain a negative exponent, you should instead call <a class="el" href="group__operator.html#gaf5344129240243ad11d0c081eb9036ab" title="Induces a phase change upon each amplitude of qureg, determined by the passed exponential polynomial ...">applyPhaseFuncOverrides()</a> once for each register/variable, and override every negative index of each register in turn. <br />
<br />
</li>
</ol>
</li>
<li><p class="startli">Lists <code>qubits</code> and <code>numQubitsPerReg</code> together describe #<code>numRegs</code> sub-registers of <code>qureg</code>, which can each contain a different number of qubits. <br />
Although <code>qubits</code> is a flat list of unique qubit indices, it should be imagined grouped into #<code>numRegs</code> sub-lists, of lengths given by <code>numQubitsPerReg</code>. <br />
<br />
For example, </p><div class="fragment"><div class="line"><span class="keywordtype">int</span> qubits[] = {0,1, 3,4,5, 7}</div>
<div class="line"><span class="keywordtype">int</span> numQubitsPerReg[] = {2, 3, 1};</div>
<div class="line"><span class="keywordtype">int</span> numRegs = 3;</div>
</div><!-- fragment --><p class="startli">describes three sub-registers, which are bolded below in an eight-qubit zero-state. </p><p class="formulaDsp">
<img class="formulaDsp" alt="\[ |r_3\rangle \; |0\rangle \; |r_2\rangle \; |0\rangle \; |r_1\rangle = |\mathbf{0}\rangle \; |0\rangle \; |\mathbf{000}\rangle \; |0\rangle \; |\mathbf{00}\rangle \]" src="form_268.png"/>
</p>
<p> Note that the qubits need not be ordered increasing, and qubits within each sub-register are assumed ordered least to most significant in that sub-register.<br />
<br />
</p><blockquote class="doxtable">
<p>List <code>qubits</code> should have length equal to the sum of elements in <code>numQubitsPerReg</code>. </p>
</blockquote>
</li>
<li>Each sub-register is associated with a variable <img class="formulaInl" alt="$r_j$" src="form_269.png"/> in phase function <img class="formulaInl" alt="$f(\vec{r})$" src="form_262.png"/>. <br />
For a given computational basis state of <code>qureg</code>, the value of each variable is determined by the binary value in the corresponding sub-register, when intepreted with <a class="el" href="group__type.html#ga9c91c41aa42ae537995e89ffc616afe1" title="Flags for specifying how the bits in sub-register computational basis states are mapped to indices in...">bitEncoding</a> <code>encoding</code>. <br />
See <a class="el" href="group__type.html#ga9c91c41aa42ae537995e89ffc616afe1" title="Flags for specifying how the bits in sub-register computational basis states are mapped to indices in...">bitEncoding</a> for more information.<br />
<br />
</li>
<li>The function <img class="formulaInl" alt="$f(\vec{r})$" src="form_262.png"/> specifies the phase change to induce upon amplitude <img class="formulaInl" alt="$\alpha$" src="form_88.png"/> of computational basis state with the nominated sub-registers encoding values <img class="formulaInl" alt="$r_1, \; \dots$" src="form_270.png"/>. <p class="formulaDsp">
<img class="formulaDsp" alt="\[ \alpha \, |r_{\text{numRegs}}, \; \dots, \; r_2, \; r_1 \rangle \rightarrow \, \exp(i f(\vec{r}\,)) \; \alpha \, |r_{\text{numRegs}}, \; \dots, \; r_2, \; r_1 \rangle. \]" src="form_271.png"/>
</p>
For example, using the sub-registers in the previous example and <code>encoding</code> <b>=</b> <code>UNSIGNED</code>, the following states receive amplitude factors: <p class="formulaDsp">
<img class="formulaDsp" alt="\[ \begin{aligned} |\mathbf{0}\rangle \; |0\rangle \; |\mathbf{000}\rangle \; |0\rangle \; |\mathbf{00}\rangle & \rightarrow \, e^{i f(r_3=0,r_2=0,r_1=0)} \\ |\mathbf{0}\rangle \; |0\rangle \; |\mathbf{000}\rangle \; |0\rangle \; |\mathbf{01}\rangle & \rightarrow \, e^{i f(r_3=0,r_2=0,r_1=1)} \\ |\mathbf{0}\rangle \; |0\rangle \; |\mathbf{000}\rangle \; |0\rangle \; |\mathbf{10}\rangle & \rightarrow \, e^{i f(r_3=0,r_2=0,r_1=2)} \\ |\mathbf{0}\rangle \; |0\rangle \; |\mathbf{000}\rangle \; |0\rangle \; |\mathbf{11}\rangle & \rightarrow \, e^{i f(r_3=0,r_2=0,r_1=3)} \\ |\mathbf{0}\rangle \; |0\rangle \; |\mathbf{000}\rangle \; |1\rangle \; |\mathbf{00}\rangle & \rightarrow \, e^{i f(r_3=0,r_2=0,r_1=0)} \\ & \;\;\;\vdots \\ |\mathbf{0}\rangle \; |0\rangle \; |\mathbf{111}\rangle \; |0\rangle \; |\mathbf{01}\rangle & \rightarrow \, e^{i f(r_3=0,r_2=7,r_1=1)} \\ & \;\;\;\vdots \\ |\mathbf{1}\rangle \; |0\rangle \; |\mathbf{111}\rangle \; |0\rangle \; |\mathbf{11}\rangle & \rightarrow \, e^{i f(r_3=1,r_2=7,r_1=3)} \end{aligned} \]" src="form_272.png"/>
</p>
</li>
<li>If <code>qureg</code> is a density matrix <img class="formulaInl" alt="$\rho$" src="form_40.png"/>, then its elements are modified as <p class="formulaDsp">
<img class="formulaDsp" alt="\[ \alpha \, |j\rangle\langle k| \; \rightarrow \; \exp(i \, (f(\vec{r}_j) - f(\vec{r}_k)) \, ) \; \alpha \, |j\rangle\langle k|, \]" src="form_273.png"/>
</p>
where <img class="formulaInl" alt="$f(\vec{r}_j)$" src="form_274.png"/> and <img class="formulaInl" alt="$f(\vec{r}_k)$" src="form_275.png"/> are determined as above.<br />
<br />
</li>
<li><p class="startli">The interpreted phase function can be previewed in the QASM log, as a comment. <br />
For example: </p><div class="fragment"><div class="line"><a class="code" href="group__qasm.html#ga65bf1906298ca6355e2942f4923d77b6">startRecordingQASM</a>(qureg);</div>
<div class="line"><a class="code" href="group__operator.html#ga008a46d178a5a9691e2f5d363e3f518f">applyMultiVarPhaseFunc</a>(qureg, ...);</div>
<div class="line"><a class="code" href="group__qasm.html#gacf139d0a54b1f9e5c2f2feff742b8c76">printRecordedQASM</a>(qureg);</div>
</div><!-- fragment --><p class="startli">would show, for the above example, </p><div class="fragment"><div class="line"><span class="comment">// Here, applyMultiVarPhaseFunc() multiplied a complex scalar of the form</span></div>
<div class="line"><span class="comment">// exp(i (</span></div>
<div class="line"><span class="comment">// + 1 x^2</span></div>
<div class="line"><span class="comment">// + 2 y + 4 y^(-1)</span></div>
<div class="line"><span class="comment">// - 3.14 z^0.5 ))</span></div>
<div class="line"><span class="comment">// upon substates informed by qubits (under an unsigned binary encoding)</span></div>
<div class="line"><span class="comment">// |x> = {0, 1}</span></div>
<div class="line"><span class="comment">// |y> = {3, 4, 5}</span></div>
<div class="line"><span class="comment">// |z> = {7}</span></div>
</div><!-- fragment --></li>
</ul>
<p><br />
</p>
<dl class="section see"><dt>See also</dt><dd><ul>
<li><a class="el" href="group__operator.html#ga8dca543fb4d1ee1cd8b4c5d6028b3075" title="Induces a phase change upon each amplitude of qureg, determined by a multi-variable exponential polyn...">applyMultiVarPhaseFuncOverrides()</a> to additionally specify explicit phases for specific sub-register values.</li>
<li><a class="el" href="group__operator.html#gac4df97d8c125c8cc65df720f67b2bf69" title="Induces a phase change upon each amplitude of qureg, determined by a named (and potentially multi-var...">applyNamedPhaseFunc()</a> for a set of specific and potentially multi-variable phase functions.</li>
<li><a class="el" href="group__operator.html#ga467f517abd18dbc3d6fced84c6589161" title="Induces a phase change upon each amplitude of qureg, determined by the passed exponential polynomial ...">applyPhaseFunc()</a> for a single-variable polynomial exponential phase function, which is approximately twice as fast.</li>
<li><a class="el" href="group__operator.html#gad2e953390342cd361cfb4064d47715e6" title="Apply a diagonal operator, which is possibly non-unitary and non-Hermitian, to the entire qureg.">applyDiagonalOp()</a> to apply a non-unitary diagonal <a class="el" href="group__operator.html" title="Non-physical operators which may be non-unitary, non-norm-preserving, even non-Hermitian.">Operators</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 state-vector or density matrix to be modified </td></tr>
<tr><td class="paramdir">[in]</td><td class="paramname">qubits</td><td>a list of all the qubit indices contained in each sub-register </td></tr>
<tr><td class="paramdir">[in]</td><td class="paramname">numQubitsPerReg</td><td>a list of the lengths of each sub-list in <code>qubits</code> </td></tr>
<tr><td class="paramdir">[in]</td><td class="paramname">numRegs</td><td>the number of sub-registers, which is the length of both <code>numQubitsPerReg</code> and <code>numTermsPerReg</code> </td></tr>
<tr><td class="paramdir">[in]</td><td class="paramname">encoding</td><td>the <a class="el" href="group__type.html#ga9c91c41aa42ae537995e89ffc616afe1" title="Flags for specifying how the bits in sub-register computational basis states are mapped to indices in...">bitEncoding</a> under which to infer the binary value <img class="formulaInl" alt="$r_j$" src="form_269.png"/> from the bits of a sub-register </td></tr>
<tr><td class="paramdir">[in]</td><td class="paramname">coeffs</td><td>the coefficients of all terms of the exponential polynomial phase function <img class="formulaInl" alt="$f(\vec{r})$" src="form_262.png"/> </td></tr>
<tr><td class="paramdir">[in]</td><td class="paramname">exponents</td><td>the exponents of all terms of the exponential polynomial phase function <img class="formulaInl" alt="$f(\vec{r})$" src="form_262.png"/> </td></tr>
<tr><td class="paramdir">[in]</td><td class="paramname">numTermsPerReg</td><td>a list of the number of <code>coeff</code> and <code>exponent</code> terms supplied for each variable/sub-register </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>if any qubit in <code>qubits</code> has an invalid index (i.e. does not satisfy 0 <= qubit < <code>qureg.numQubitsRepresented</code>)</li>
<li>if the elements of <code>qubits</code> are not unique (including if sub-registers overlap)</li>
<li>if <code>numRegs</code> <= 0 or <code>numRegs</code> > 100 (constrained by <code>MAX_NUM_REGS_APPLY_ARBITRARY_PHASE</code> in <a class="el" href="QuEST__precision_8h.html">QuEST_precision.h</a>)</li>
<li>if <code>encoding</code> is not a valid <a class="el" href="group__type.html#ga9c91c41aa42ae537995e89ffc616afe1" title="Flags for specifying how the bits in sub-register computational basis states are mapped to indices in...">bitEncoding</a></li>
<li>if the size of any sub-register is incompatible with <code>encoding</code> (e.g. contains fewer than two qubits in <code>encoding</code> <b>=</b> <code>TWOS_COMPLEMENT</code>)</li>
<li>if any element of <code>numTermsPerReg</code> is < 1</li>
<li>if <code>exponents</code> contains a negative number</li>
<li>if <code>exponents</code> contains a fractional number despite <code>encoding</code> <b>=</b> <a class="el" href="group__type.html#gga9c91c41aa42ae537995e89ffc616afe1a9aa2a35d92976c7de970506c4d19a96c">TWOS_COMPLEMENT</a> </li>
</ul>
</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#l00761">761</a> of file <a class="el" href="QuEST_8c_source.html">QuEST.c</a>.</p>
<div class="fragment"><div class="line"><a name="l00761"></a><span class="lineno"> 761</span>  {</div>
<div class="line"><a name="l00762"></a><span class="lineno"> 762</span>  <a class="code" href="QuEST__validation_8c.html#a0a45c9c3015af276ff7e624ae207ba7a">validateQubitSubregs</a>(qureg, qubits, numQubitsPerReg, numRegs, __func__);</div>
<div class="line"><a name="l00763"></a><span class="lineno"> 763</span>  <a class="code" href="QuEST__validation_8c.html#a9b348fc98867d01990da93a8de36936c">validateMultiRegBitEncoding</a>(numQubitsPerReg, numRegs, encoding, __func__);</div>
<div class="line"><a name="l00764"></a><span class="lineno"> 764</span>  <a class="code" href="QuEST__validation_8c.html#a14317136bb150eb0d4bdada1d0aac058">validateMultiVarPhaseFuncTerms</a>(numQubitsPerReg, numRegs, encoding, exponents, numTermsPerReg, __func__);</div>
<div class="line"><a name="l00765"></a><span class="lineno"> 765</span>  </div>
<div class="line"><a name="l00766"></a><span class="lineno"> 766</span>  <span class="keywordtype">int</span> conj = 0;</div>
<div class="line"><a name="l00767"></a><span class="lineno"> 767</span>  <a class="code" href="QuEST__internal_8h.html#ab33437d10c1ce1c4b034c7c411db553f">statevec_applyMultiVarPhaseFuncOverrides</a>(qureg, qubits, numQubitsPerReg, numRegs, encoding, coeffs, exponents, numTermsPerReg, NULL, NULL, 0, conj);</div>
<div class="line"><a name="l00768"></a><span class="lineno"> 768</span>  <span class="keywordflow">if</span> (qureg.<a class="code" href="structQureg.html#acf78445e9435d09f44f0cc832c6aee79">isDensityMatrix</a>) {</div>
<div class="line"><a name="l00769"></a><span class="lineno"> 769</span>  conj = 1;</div>
<div class="line"><a name="l00770"></a><span class="lineno"> 770</span>  <a class="code" href="QuEST__common_8c.html#aecc3c36b275c53b321de1611c2f06f78">shiftSubregIndices</a>(qubits, numQubitsPerReg, numRegs, qureg.<a class="code" href="structQureg.html#ad08dff5316b8937f4b2a1417591543dc">numQubitsRepresented</a>);</div>
<div class="line"><a name="l00771"></a><span class="lineno"> 771</span>  <a class="code" href="QuEST__internal_8h.html#ab33437d10c1ce1c4b034c7c411db553f">statevec_applyMultiVarPhaseFuncOverrides</a>(qureg, qubits, numQubitsPerReg, numRegs, encoding, coeffs, exponents, numTermsPerReg, NULL, NULL, 0, conj);</div>
<div class="line"><a name="l00772"></a><span class="lineno"> 772</span>  <a class="code" href="QuEST__common_8c.html#aecc3c36b275c53b321de1611c2f06f78">shiftSubregIndices</a>(qubits, numQubitsPerReg, numRegs, - qureg.<a class="code" href="structQureg.html#ad08dff5316b8937f4b2a1417591543dc">numQubitsRepresented</a>);</div>
<div class="line"><a name="l00773"></a><span class="lineno"> 773</span>  }</div>
<div class="line"><a name="l00774"></a><span class="lineno"> 774</span>  </div>
<div class="line"><a name="l00775"></a><span class="lineno"> 775</span>  <a class="code" href="QuEST__qasm_8c.html#a6d239705dc0400ae75f8715c1f88b79f">qasm_recordMultiVarPhaseFunc</a>(qureg, qubits, numQubitsPerReg, numRegs, encoding, coeffs, exponents, numTermsPerReg, NULL, NULL, 0);</div>
<div class="line"><a name="l00776"></a><span class="lineno"> 776</span> }</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST_8h_source.html#l00325">Qureg::isDensityMatrix</a>, <a class="el" href="QuEST_8h_source.html#l00327">Qureg::numQubitsRepresented</a>, <a class="el" href="QuEST__qasm_8c_source.html#l00666">qasm_recordMultiVarPhaseFunc()</a>, <a class="el" href="QuEST__common_8c_source.html#l00161">shiftSubregIndices()</a>, <a class="el" href="QuEST__cpu_8c_source.html#l04345">statevec_applyMultiVarPhaseFuncOverrides()</a>, <a class="el" href="QuEST__validation_8c_source.html#l00976">validateMultiRegBitEncoding()</a>, <a class="el" href="QuEST__validation_8c_source.html#l00836">validateMultiVarPhaseFuncTerms()</a>, and <a class="el" href="QuEST__validation_8c_source.html#l00757">validateQubitSubregs()</a>.</p>
<p class="reference">Referenced by <a class="el" href="test__operators_8cpp_source.html#l00589">TEST_CASE()</a>.</p>
</div>
</div>
<a id="ga8dca543fb4d1ee1cd8b4c5d6028b3075"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga8dca543fb4d1ee1cd8b4c5d6028b3075">◆ </a></span>applyMultiVarPhaseFuncOverrides()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void applyMultiVarPhaseFuncOverrides </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">int * </td>
<td class="paramname"><em>qubits</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int * </td>
<td class="paramname"><em>numQubitsPerReg</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int </td>
<td class="paramname"><em>numRegs</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">enum <a class="el" href="group__type.html#ga9c91c41aa42ae537995e89ffc616afe1">bitEncoding</a> </td>
<td class="paramname"><em>encoding</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype"><a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> * </td>
<td class="paramname"><em>coeffs</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype"><a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> * </td>
<td class="paramname"><em>exponents</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int * </td>
<td class="paramname"><em>numTermsPerReg</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">long long int * </td>
<td class="paramname"><em>overrideInds</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype"><a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> * </td>
<td class="paramname"><em>overridePhases</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int </td>
<td class="paramname"><em>numOverrides</em> </td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Induces a phase change upon each amplitude of <code>qureg</code>, determined by a multi-variable exponential polynomial "phase function", and an explicit set of 'overriding' values at specific state indices. </p>
<p>See <a class="el" href="group__operator.html#ga008a46d178a5a9691e2f5d363e3f518f" title="Induces a phase change upon each amplitude of qureg, determined by a multi-variable exponential polyn...">applyMultiVarPhaseFunc()</a> first for a full description.</p>
<ul>
<li>As in <a class="el" href="group__operator.html#ga008a46d178a5a9691e2f5d363e3f518f" title="Induces a phase change upon each amplitude of qureg, determined by a multi-variable exponential polyn...">applyMultiVarPhaseFunc()</a>, the arguments <code>coeffs</code> and <code>exponents</code> specify a multi-variable phase function <img class="formulaInl" alt="$f(\vec{r})$" src="form_262.png"/>, where <img class="formulaInl" alt="$\vec{r}$" src="form_276.png"/> is determined by the sub-registers in <code>qubits</code>, and <a class="el" href="group__type.html#ga9c91c41aa42ae537995e89ffc616afe1" title="Flags for specifying how the bits in sub-register computational basis states are mapped to indices in...">bitEncoding</a> <code>encoding</code> for each basis state of <code>qureg</code>.<br />
<br />
</li>
<li><p class="startli">Additionally, <code>overrideInds</code> is a list of length <code>numOverrides</code> which specifies the values of <img class="formulaInl" alt="$\vec{r}$" src="form_276.png"/> for which to explicitly set the induced phase change.<br />
While flat, <code>overrideInds</code> should be imagined grouped into sub-lists of length <code>numRegs</code>, which specify the full <img class="formulaInl" alt="$\{r_1,\; \dots \;r_{\text{numRegs}} \} $" src="form_277.png"/> coordinate to override. <br />
Each sublist corresponds to a single element of <code>overridePhases</code>. <br />
For example, </p><div class="fragment"><div class="line"><span class="keywordtype">int</span> numRegs = 3;</div>
<div class="line"><span class="keywordtype">int</span> numOverrides = 2;</div>
<div class="line"><span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> overrideInds[] = { 0,0,0, 1,2,3 };</div>
<div class="line"><a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> overridePhases[] = { <a class="code" href="QuEST__common_8c.html#ae71449b1cc6e6250b91f539153a7a0d3">M_PI</a>, - <a class="code" href="QuEST__common_8c.html#ae71449b1cc6e6250b91f539153a7a0d3">M_PI</a> };</div>
</div><!-- fragment --><p class="startli">denotes that any basis state of <code>qureg</code> with sub-register values <img class="formulaInl" alt="$\{r_3,r_2,r_1\} = \{0, 0, 0\}$" src="form_278.png"/> (or <img class="formulaInl" alt="$\{r_3,r_2,r_1\} = \{1,2,3\}$" src="form_279.png"/>) should receive phase change <img class="formulaInl" alt="$\pi$" src="form_114.png"/> (or <img class="formulaInl" alt="$-\pi$" src="form_280.png"/>) in lieu of <img class="formulaInl" alt="$\exp(i f(r_3=0,r_2=0,r_1=0))$" src="form_281.png"/>.<br />
<br />
</p><blockquote class="doxtable">
<p>Note that you cannot use <a class="el" href="group__operator.html#ga8dca543fb4d1ee1cd8b4c5d6028b3075" title="Induces a phase change upon each amplitude of qureg, determined by a multi-variable exponential polyn...">applyMultiVarPhaseFuncOverrides()</a> to override divergences in <img class="formulaInl" alt="$f(\vec{r})$" src="form_262.png"/>, since each diverging value <img class="formulaInl" alt="$r_j$" src="form_269.png"/> would need to be overriden as an <img class="formulaInl" alt="$\vec{r}$" src="form_276.png"/> coordinate for every basis state of the other registers; the number of overrides grows exponentially. Ergo, if <code>exponents</code> contains a negative number (diverging at <img class="formulaInl" alt="$r_j=0$" src="form_282.png"/>), or <code>exponents</code> contains a fractional number despite <code>encoding</code> <b>=</b> <a class="el" href="group__type.html#gga9c91c41aa42ae537995e89ffc616afe1a9aa2a35d92976c7de970506c4d19a96c">TWOS_COMPLEMENT</a> (producing complex phases at negative indices), you must instead call <a class="el" href="group__operator.html#gaf5344129240243ad11d0c081eb9036ab" title="Induces a phase change upon each amplitude of qureg, determined by the passed exponential polynomial ...">applyPhaseFuncOverrides()</a> for each variable in turn and override the diverging <img class="formulaInl" alt="$r_j$" src="form_269.png"/> (each independently of the other registers). </p>
</blockquote>
</li>
<li><p class="startli">The interpreted overrides can be previewed in the QASM log, as a comment. <br />
For example: </p><div class="fragment"><div class="line"><a class="code" href="group__qasm.html#ga65bf1906298ca6355e2942f4923d77b6">startRecordingQASM</a>(qureg);</div>
<div class="line"><a class="code" href="group__operator.html#ga8dca543fb4d1ee1cd8b4c5d6028b3075">applyMultiVarPhaseFuncOverrides</a>(qureg, ...);</div>
<div class="line"><a class="code" href="group__qasm.html#gacf139d0a54b1f9e5c2f2feff742b8c76">printRecordedQASM</a>(qureg);</div>
</div><!-- fragment --><p class="startli">may show </p><div class="fragment"><div class="line"><span class="comment">// Here, applyMultiVarPhaseFunc() multiplied ...</span></div>
<div class="line"><span class="comment">// though with overrides</span></div>
<div class="line"><span class="comment">// |x=0, y=0, z=0> -> exp(i 3.14159)</span></div>
<div class="line"><span class="comment">// |x=1, y=2, z=3> -> exp(i (-3.14159))</span></div>
</div><!-- fragment --></li>
</ul>
<p><br />
</p>
<dl class="section see"><dt>See also</dt><dd><ul>
<li><a class="el" href="group__operator.html#gac4df97d8c125c8cc65df720f67b2bf69" title="Induces a phase change upon each amplitude of qureg, determined by a named (and potentially multi-var...">applyNamedPhaseFunc()</a> for a set of specific and potentially multi-variable phase functions.</li>
<li><a class="el" href="group__operator.html#gad2e953390342cd361cfb4064d47715e6" title="Apply a diagonal operator, which is possibly non-unitary and non-Hermitian, to the entire qureg.">applyDiagonalOp()</a> to apply a non-unitary diagonal <a class="el" href="group__operator.html" title="Non-physical operators which may be non-unitary, non-norm-preserving, even non-Hermitian.">Operators</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 state-vector or density-matrix to be modified </td></tr>
<tr><td class="paramdir">[in]</td><td class="paramname">qubits</td><td>a list of all the qubit indices contained in each sub-register </td></tr>
<tr><td class="paramdir">[in]</td><td class="paramname">numQubitsPerReg</td><td>a list of the lengths of each sub-list in <code>qubits</code> </td></tr>
<tr><td class="paramdir">[in]</td><td class="paramname">numRegs</td><td>the number of sub-registers, which is the length of both <code>numQubitsPerReg</code> and <code>numTermsPerReg</code> </td></tr>
<tr><td class="paramdir">[in]</td><td class="paramname">encoding</td><td>the <a class="el" href="group__type.html#ga9c91c41aa42ae537995e89ffc616afe1" title="Flags for specifying how the bits in sub-register computational basis states are mapped to indices in...">bitEncoding</a> under which to infer the binary value <img class="formulaInl" alt="$r_j$" src="form_269.png"/> from the bits of a sub-register </td></tr>
<tr><td class="paramdir">[in]</td><td class="paramname">coeffs</td><td>the coefficients of all terms of the exponential polynomial phase function <img class="formulaInl" alt="$f(\vec{r})$" src="form_262.png"/> </td></tr>
<tr><td class="paramdir">[in]</td><td class="paramname">exponents</td><td>the exponents of all terms of the exponential polynomial phase function <img class="formulaInl" alt="$f(\vec{r})$" src="form_262.png"/> </td></tr>
<tr><td class="paramdir">[in]</td><td class="paramname">numTermsPerReg</td><td>a list of the number of <code>coeff</code> and <code>exponent</code> terms supplied for each variable/sub-register </td></tr>
<tr><td class="paramdir">[in]</td><td class="paramname">overrideInds</td><td>a flattened list of sub-register coordinates (values of <img class="formulaInl" alt="$\vec{r}$" src="form_276.png"/>) of which to explicit set the phase change </td></tr>
<tr><td class="paramdir">[in]</td><td class="paramname">overridePhases</td><td>a list of replacement phase changes, for the corresponding <img class="formulaInl" alt="$\vec{r}$" src="form_276.png"/> values in <code>overrideInds</code> </td></tr>
<tr><td class="paramdir">[in]</td><td class="paramname">numOverrides</td><td>the lengths of list <code>overridePhases</code> (but not necessarily of <code>overrideInds</code>) </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>if any qubit in <code>qubits</code> has an invalid index (i.e. does not satisfy 0 <= qubit < <code>qureg.numQubitsRepresented</code>)</li>
<li>if the elements of <code>qubits</code> are not unique (including if sub-registers overlap)</li>
<li>if <code>numRegs</code> <= 0 or <code>numRegs</code> > 100 (constrained by <code>MAX_NUM_REGS_APPLY_ARBITRARY_PHASE</code> in <a class="el" href="QuEST__precision_8h.html">QuEST_precision.h</a>)</li>
<li>if <code>encoding</code> is not a valid <a class="el" href="group__type.html#ga9c91c41aa42ae537995e89ffc616afe1" title="Flags for specifying how the bits in sub-register computational basis states are mapped to indices in...">bitEncoding</a></li>
<li>if the size of any sub-register is incompatible with <code>encoding</code> (e.g. contains fewer than two qubits in <code>encoding</code> <b>=</b> <code>TWOS_COMPLEMENT</code>)</li>
<li>if any element of <code>numTermsPerReg</code> is < 1</li>
<li>if <code>exponents</code> contains a negative number</li>
<li>if <code>exponents</code> contains a fractional number despite <code>encoding</code> <b>=</b> <a class="el" href="group__type.html#gga9c91c41aa42ae537995e89ffc616afe1a9aa2a35d92976c7de970506c4d19a96c">TWOS_COMPLEMENT</a></li>
<li>if any value in <code>overrideInds</code> is not producible by its corresponding sub-register under the given <code>encoding</code> (e.g. 2 unsigned qubits cannot represent index 9)</li>
<li>if <code>numOverrides</code> < 0 </li>
</ul>
</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#l00778">778</a> of file <a class="el" href="QuEST_8c_source.html">QuEST.c</a>.</p>
<div class="fragment"><div class="line"><a name="l00778"></a><span class="lineno"> 778</span>  {</div>
<div class="line"><a name="l00779"></a><span class="lineno"> 779</span>  <a class="code" href="QuEST__validation_8c.html#a0a45c9c3015af276ff7e624ae207ba7a">validateQubitSubregs</a>(qureg, qubits, numQubitsPerReg, numRegs, __func__);</div>
<div class="line"><a name="l00780"></a><span class="lineno"> 780</span>  <a class="code" href="QuEST__validation_8c.html#a9b348fc98867d01990da93a8de36936c">validateMultiRegBitEncoding</a>(numQubitsPerReg, numRegs, encoding, __func__);</div>
<div class="line"><a name="l00781"></a><span class="lineno"> 781</span>  <a class="code" href="QuEST__validation_8c.html#a14317136bb150eb0d4bdada1d0aac058">validateMultiVarPhaseFuncTerms</a>(numQubitsPerReg, numRegs, encoding, exponents, numTermsPerReg, __func__);</div>
<div class="line"><a name="l00782"></a><span class="lineno"> 782</span>  <a class="code" href="QuEST__validation_8c.html#a0edb4d9df94a40b8ea89c1c14997ee76">validateMultiVarPhaseFuncOverrides</a>(numQubitsPerReg, numRegs, encoding, overrideInds, numOverrides, __func__);</div>
<div class="line"><a name="l00783"></a><span class="lineno"> 783</span>  </div>
<div class="line"><a name="l00784"></a><span class="lineno"> 784</span>  <span class="keywordtype">int</span> conj = 0;</div>
<div class="line"><a name="l00785"></a><span class="lineno"> 785</span>  <a class="code" href="QuEST__internal_8h.html#ab33437d10c1ce1c4b034c7c411db553f">statevec_applyMultiVarPhaseFuncOverrides</a>(qureg, qubits, numQubitsPerReg, numRegs, encoding, coeffs, exponents, numTermsPerReg, overrideInds, overridePhases, numOverrides, conj);</div>
<div class="line"><a name="l00786"></a><span class="lineno"> 786</span>  <span class="keywordflow">if</span> (qureg.<a class="code" href="structQureg.html#acf78445e9435d09f44f0cc832c6aee79">isDensityMatrix</a>) {</div>
<div class="line"><a name="l00787"></a><span class="lineno"> 787</span>  conj = 1;</div>
<div class="line"><a name="l00788"></a><span class="lineno"> 788</span>  <a class="code" href="QuEST__common_8c.html#aecc3c36b275c53b321de1611c2f06f78">shiftSubregIndices</a>(qubits, numQubitsPerReg, numRegs, qureg.<a class="code" href="structQureg.html#ad08dff5316b8937f4b2a1417591543dc">numQubitsRepresented</a>);</div>
<div class="line"><a name="l00789"></a><span class="lineno"> 789</span>  <a class="code" href="QuEST__internal_8h.html#ab33437d10c1ce1c4b034c7c411db553f">statevec_applyMultiVarPhaseFuncOverrides</a>(qureg, qubits, numQubitsPerReg, numRegs, encoding, coeffs, exponents, numTermsPerReg, overrideInds, overridePhases, numOverrides, conj);</div>
<div class="line"><a name="l00790"></a><span class="lineno"> 790</span>  <a class="code" href="QuEST__common_8c.html#aecc3c36b275c53b321de1611c2f06f78">shiftSubregIndices</a>(qubits, numQubitsPerReg, numRegs, - qureg.<a class="code" href="structQureg.html#ad08dff5316b8937f4b2a1417591543dc">numQubitsRepresented</a>);</div>
<div class="line"><a name="l00791"></a><span class="lineno"> 791</span>  }</div>
<div class="line"><a name="l00792"></a><span class="lineno"> 792</span>  </div>
<div class="line"><a name="l00793"></a><span class="lineno"> 793</span>  <a class="code" href="QuEST__qasm_8c.html#a6d239705dc0400ae75f8715c1f88b79f">qasm_recordMultiVarPhaseFunc</a>(qureg, qubits, numQubitsPerReg, numRegs, encoding, coeffs, exponents, numTermsPerReg, overrideInds, overridePhases, numOverrides);</div>
<div class="line"><a name="l00794"></a><span class="lineno"> 794</span> }</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST_8h_source.html#l00325">Qureg::isDensityMatrix</a>, <a class="el" href="QuEST_8h_source.html#l00327">Qureg::numQubitsRepresented</a>, <a class="el" href="QuEST__qasm_8c_source.html#l00666">qasm_recordMultiVarPhaseFunc()</a>, <a class="el" href="QuEST__common_8c_source.html#l00161">shiftSubregIndices()</a>, <a class="el" href="QuEST__cpu_8c_source.html#l04345">statevec_applyMultiVarPhaseFuncOverrides()</a>, <a class="el" href="QuEST__validation_8c_source.html#l00976">validateMultiRegBitEncoding()</a>, <a class="el" href="QuEST__validation_8c_source.html#l00886">validateMultiVarPhaseFuncOverrides()</a>, <a class="el" href="QuEST__validation_8c_source.html#l00836">validateMultiVarPhaseFuncTerms()</a>, and <a class="el" href="QuEST__validation_8c_source.html#l00757">validateQubitSubregs()</a>.</p>
<p class="reference">Referenced by <a class="el" href="test__operators_8cpp_source.html#l00790">TEST_CASE()</a>.</p>
</div>
</div>
<a id="gac4df97d8c125c8cc65df720f67b2bf69"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gac4df97d8c125c8cc65df720f67b2bf69">◆ </a></span>applyNamedPhaseFunc()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void applyNamedPhaseFunc </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">int * </td>
<td class="paramname"><em>qubits</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int * </td>
<td class="paramname"><em>numQubitsPerReg</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int </td>
<td class="paramname"><em>numRegs</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">enum <a class="el" href="group__type.html#ga9c91c41aa42ae537995e89ffc616afe1">bitEncoding</a> </td>
<td class="paramname"><em>encoding</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">enum <a class="el" href="group__type.html#gaa7d869b117ba5024d6b84938e8cdfc65">phaseFunc</a> </td>
<td class="paramname"><em>functionNameCode</em> </td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Induces a phase change upon each amplitude of <code>qureg</code>, determined by a named (and potentially multi-variable) phase function. </p>
<p>This effects a diagonal unitary operator, with a phase function <img class="formulaInl" alt="$f(\vec{r})$" src="form_262.png"/> which may not be simply expressible as an exponential polynomial in functions <a class="el" href="group__operator.html#ga467f517abd18dbc3d6fced84c6589161" title="Induces a phase change upon each amplitude of qureg, determined by the passed exponential polynomial ...">applyPhaseFunc()</a> and <a class="el" href="group__operator.html#ga008a46d178a5a9691e2f5d363e3f518f" title="Induces a phase change upon each amplitude of qureg, determined by a multi-variable exponential polyn...">applyMultiVarPhaseFunc()</a>.</p>
<p>Arguments <code>qubits</code> and <code>numQubitsPerReg</code> encode sub-registers of <code>qureg</code> in the same manner as in <a class="el" href="group__operator.html#ga008a46d178a5a9691e2f5d363e3f518f" title="Induces a phase change upon each amplitude of qureg, determined by a multi-variable exponential polyn...">applyMultiVarPhaseFunc()</a>:</p><ul>
<li><p class="startli">Lists <code>qubits</code> and <code>numQubitsPerReg</code> together describe #<code>numRegs</code> sub-registers of <code>qureg</code>, which can each contain a different number of qubits. <br />
Although <code>qubits</code> is a flat list of unique qubit indices, it should be imagined grouped into #<code>numRegs</code> sub-lists, of lengths given by <code>numQubitsPerReg</code>. <br />
<br />
For example, </p><div class="fragment"><div class="line"><span class="keywordtype">int</span> qubits[] = {0,1, 3,4,5, 7}</div>
<div class="line"><span class="keywordtype">int</span> numQubitsPerReg[] = {2, 3, 1};</div>
<div class="line"><span class="keywordtype">int</span> numRegs = 3;</div>
</div><!-- fragment --><p class="startli">describes three sub-registers, which are bolded below in an eight-qubit zero-state. </p><p class="formulaDsp">
<img class="formulaDsp" alt="\[ |r_3\rangle \; |0\rangle \; |r_2\rangle \; |0\rangle \; |r_1\rangle = |\mathbf{0}\rangle \; |0\rangle \; |\mathbf{000}\rangle \; |0\rangle \; |\mathbf{00}\rangle \]" src="form_268.png"/>
</p>
<p> Note that the qubits need not be ordered increasing, and qubits within each sub-register are assumed ordered least to most significant in that sub-register.<br />
<br />
</p><blockquote class="doxtable">
<p>List <code>qubits</code> should have length equal to the sum of elements in <code>numQubitsPerReg</code>. </p>
</blockquote>
</li>
<li>Each sub-register is associated with a variable <img class="formulaInl" alt="$r_j$" src="form_269.png"/> in phase function <img class="formulaInl" alt="$f(\vec{r})$" src="form_262.png"/>. <br />
For a given computational basis state of <code>qureg</code>, the value of each variable is determined by the binary value in the corresponding sub-register, when intepreted with <a class="el" href="group__type.html#ga9c91c41aa42ae537995e89ffc616afe1" title="Flags for specifying how the bits in sub-register computational basis states are mapped to indices in...">bitEncoding</a> <code>encoding</code>. <br />
See <a class="el" href="group__type.html#ga9c91c41aa42ae537995e89ffc616afe1" title="Flags for specifying how the bits in sub-register computational basis states are mapped to indices in...">bitEncoding</a> for more information.<br />
<br />
</li>
<li><p class="startli">Argument <code>functionNameCode</code> determines the phase function <img class="formulaInl" alt="$f(\vec{r})$" src="form_262.png"/>.<br />
For example, </p><div class="fragment"><div class="line"><span class="keywordtype">int</span> numRegs = 3;</div>
<div class="line"><span class="keyword">enum</span> <a class="code" href="group__type.html#gaa7d869b117ba5024d6b84938e8cdfc65">phaseFunc</a> functionNameCode = <a class="code" href="group__type.html#ggaa7d869b117ba5024d6b84938e8cdfc65ae003ec1158e3a4e295616ced12af154e">NORM</a>;</div>
</div><!-- fragment --><p class="startli">describes phase function </p><p class="formulaDsp">
<img class="formulaDsp" alt="\[ f(\vec{r}) = \sqrt{ {r_1}^2 + {r_2}^2 + {r_3} ^2 }. \]" src="form_283.png"/>
</p>
<p> See <a class="el" href="group__type.html#gaa7d869b117ba5024d6b84938e8cdfc65" title="Flags for specifying named phase functions.">phaseFunc</a> for a list and description of all named phase functions. <br />
Some phase functions, like <code>SCALED_NORM</code>, require passing additional parameters, through the function <a class="el" href="group__operator.html#ga225b82ff8b8eed1fff312240ec70c731" title="Induces a phase change upon each amplitude of qureg, determined by a named, paramaterized (and potent...">applyParamNamedPhaseFunc()</a>.<br />
<br />
</p><blockquote class="doxtable">
<p>If the phase function <img class="formulaInl" alt="$f(\vec{r})$" src="form_262.png"/> diverges at one or more <img class="formulaInl" alt="$\vec{r}$" src="form_276.png"/> values, you should instead use <a class="el" href="group__operator.html#ga2fbaec3bb21cc01f7a2a4ed2aa911ebf" title="Induces a phase change upon each amplitude of qureg, determined by a named (and potentially multi-var...">applyNamedPhaseFuncOverrides()</a> and specify explicit phase changes for these coordinates. Otherwise, the corresponding amplitudes of <code>qureg</code> will become indeterminate (like <code>NaN</code>). <br />
</p>
</blockquote>
</li>
<li>The function <img class="formulaInl" alt="$f(\vec{r})$" src="form_262.png"/> specifies the phase change to induce upon amplitude <img class="formulaInl" alt="$\alpha$" src="form_88.png"/> of computational basis state with the nominated sub-registers encoding values <img class="formulaInl" alt="$r_1, \; \dots$" src="form_270.png"/>. <p class="formulaDsp">
<img class="formulaDsp" alt="\[ \alpha \, |r_{\text{numRegs}}, \; \dots, \; r_2, \; r_1 \rangle \rightarrow \, \exp(i f(\vec{r}\,)) \; \alpha \, |r_{\text{numRegs}}, \; \dots, \; r_2, \; r_1 \rangle. \]" src="form_271.png"/>
</p>
For example, using the sub-registers in the above example and <code>encoding</code> <b>=</b> <code>UNSIGNED</code>, the following states receive amplitude factors: <p class="formulaDsp">
<img class="formulaDsp" alt="\[ \begin{aligned} |\mathbf{0}\rangle \; |0\rangle \; |\mathbf{000}\rangle \; |0\rangle \; |\mathbf{00}\rangle & \rightarrow \, e^{i f(r_3=0,r_2=0,r_1=0)} \\ |\mathbf{0}\rangle \; |0\rangle \; |\mathbf{000}\rangle \; |0\rangle \; |\mathbf{01}\rangle & \rightarrow \, e^{i f(r_3=0,r_2=0,r_1=1)} \\ |\mathbf{0}\rangle \; |0\rangle \; |\mathbf{000}\rangle \; |0\rangle \; |\mathbf{10}\rangle & \rightarrow \, e^{i f(r_3=0,r_2=0,r_1=2)} \\ |\mathbf{0}\rangle \; |0\rangle \; |\mathbf{000}\rangle \; |0\rangle \; |\mathbf{11}\rangle & \rightarrow \, e^{i f(r_3=0,r_2=0,r_1=3)} \\ |\mathbf{0}\rangle \; |0\rangle \; |\mathbf{000}\rangle \; |1\rangle \; |\mathbf{00}\rangle & \rightarrow \, e^{i f(r_3=0,r_2=0,r_1=0)} \\ & \;\;\;\vdots \\ |\mathbf{0}\rangle \; |0\rangle \; |\mathbf{111}\rangle \; |0\rangle \; |\mathbf{01}\rangle & \rightarrow \, e^{i f(r_3=0,r_2=7,r_1=1)} \\ & \;\;\;\vdots \\ |\mathbf{1}\rangle \; |0\rangle \; |\mathbf{111}\rangle \; |0\rangle \; |\mathbf{11}\rangle & \rightarrow \, e^{i f(r_3=1,r_2=7,r_1=3)} \end{aligned} \]" src="form_272.png"/>
</p>
<br />
</li>
<li>If <code>qureg</code> is a density matrix, its elements are modified to <p class="formulaDsp">
<img class="formulaDsp" alt="\[ \alpha \, |j\rangle\langle k| \; \rightarrow \; \exp(i (f(\vec{r}_j) \, - \, f(\vec{r}_k))) \; \alpha \, |j\rangle\langle k| \]" src="form_284.png"/>
</p>
where <img class="formulaInl" alt="$f(\vec{r}_j)$" src="form_274.png"/> and <img class="formulaInl" alt="$f(\vec{r}_k)$" src="form_275.png"/> are determined as above. This is equivalent to modification <p class="formulaDsp">
<img class="formulaDsp" alt="\[ \rho \; \rightarrow \; \hat{D} \, \rho \, \hat{D}^\dagger \]" src="form_285.png"/>
</p>
where <img class="formulaInl" alt="$\hat{D}$" src="form_42.png"/> is the diagonal unitary <p class="formulaDsp">
<img class="formulaDsp" alt="\[ \hat{D} = \text{diag}\, \{ \; e^{i f(\vec{r_0})}, \; e^{i f(\vec{r_1})}, \; \dots \; \}. \]" src="form_286.png"/>
</p>
<br />
</li>
<li><p class="startli">The interpreted phase function can be previewed in the QASM log, as a comment. <br />
For example: </p><div class="fragment"><div class="line"><a class="code" href="group__qasm.html#ga65bf1906298ca6355e2942f4923d77b6">startRecordingQASM</a>(qureg);</div>
<div class="line"><a class="code" href="group__operator.html#gac4df97d8c125c8cc65df720f67b2bf69">applyNamedPhaseFunc</a>(qureg, ..., <a class="code" href="group__type.html#ggaa7d869b117ba5024d6b84938e8cdfc65a6313e6ff48163c11c47866c4fda4bfa0">INVERSE_DISTANCE</a>, ... );</div>
<div class="line"><a class="code" href="group__qasm.html#gacf139d0a54b1f9e5c2f2feff742b8c76">printRecordedQASM</a>(qureg);</div>
</div><!-- fragment --><p class="startli">may show </p><div class="fragment"><div class="line"><span class="comment">// Here, applyNamedPhaseFunc() multiplied a complex scalar of form</span></div>
<div class="line"><span class="comment">// exp(i 1 / sqrt((x-y)^2 + (z-t)^2))</span></div>
</div><!-- fragment --></li>
</ul>
<p><br />
</p>
<dl class="section see"><dt>See also</dt><dd><ul>
<li><a class="el" href="group__operator.html#ga2fbaec3bb21cc01f7a2a4ed2aa911ebf" title="Induces a phase change upon each amplitude of qureg, determined by a named (and potentially multi-var...">applyNamedPhaseFuncOverrides()</a> to additionally specify phase values for specific sub-register indices.</li>
<li><a class="el" href="group__operator.html#ga225b82ff8b8eed1fff312240ec70c731" title="Induces a phase change upon each amplitude of qureg, determined by a named, paramaterized (and potent...">applyParamNamedPhaseFunc()</a> to specify named phase functions which require additional parameters.</li>
<li><a class="el" href="group__operator.html#ga467f517abd18dbc3d6fced84c6589161" title="Induces a phase change upon each amplitude of qureg, determined by the passed exponential polynomial ...">applyPhaseFunc()</a> to specify a general single-variable exponential polynomial phase function.</li>
<li><a class="el" href="group__operator.html#ga008a46d178a5a9691e2f5d363e3f518f" title="Induces a phase change upon each amplitude of qureg, determined by a multi-variable exponential polyn...">applyMultiVarPhaseFunc()</a> to specify a general multi-variable exponential polynomial phase function.</li>
<li><a class="el" href="group__operator.html#gad2e953390342cd361cfb4064d47715e6" title="Apply a diagonal operator, which is possibly non-unitary and non-Hermitian, to the entire qureg.">applyDiagonalOp()</a> to apply a non-unitary diagonal <a class="el" href="group__operator.html" title="Non-physical operators which may be non-unitary, non-norm-preserving, even non-Hermitian.">Operators</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 state-vector or density-matrix to be modified </td></tr>
<tr><td class="paramdir">[in]</td><td class="paramname">qubits</td><td>a list of all the qubit indices contained in each sub-register </td></tr>
<tr><td class="paramdir">[in]</td><td class="paramname">numQubitsPerReg</td><td>a list of the lengths of each sub-list in <code>qubits</code> </td></tr>
<tr><td class="paramdir">[in]</td><td class="paramname">numRegs</td><td>the number of sub-registers, which is the length of both <code>numQubitsPerReg</code> and <code>numTermsPerReg</code> </td></tr>
<tr><td class="paramdir">[in]</td><td class="paramname">encoding</td><td>the <a class="el" href="group__type.html#ga9c91c41aa42ae537995e89ffc616afe1" title="Flags for specifying how the bits in sub-register computational basis states are mapped to indices in...">bitEncoding</a> under which to infer the binary value <img class="formulaInl" alt="$r_j$" src="form_269.png"/> from the bits of a sub-register </td></tr>
<tr><td class="paramdir">[in]</td><td class="paramname">functionNameCode</td><td>the <a class="el" href="group__type.html#gaa7d869b117ba5024d6b84938e8cdfc65" title="Flags for specifying named phase functions.">phaseFunc</a> <img class="formulaInl" alt="$f(\vec{r})$" src="form_262.png"/> </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>if any qubit in <code>qubits</code> has an invalid index (i.e. does not satisfy 0 <= qubit < <code>qureg.numQubitsRepresented</code>)</li>
<li>if the elements of <code>qubits</code> are not unique (including if sub-registers overlap)</li>
<li>if <code>numRegs</code> <= 0 or <code>numRegs</code> > 100 (constrained by <code>MAX_NUM_REGS_APPLY_ARBITRARY_PHASE</code> in <a class="el" href="QuEST__precision_8h.html">QuEST_precision.h</a>)</li>
<li>if <code>encoding</code> is not a valid <a class="el" href="group__type.html#ga9c91c41aa42ae537995e89ffc616afe1" title="Flags for specifying how the bits in sub-register computational basis states are mapped to indices in...">bitEncoding</a></li>
<li>if the size of any sub-register is incompatible with <code>encoding</code> (e.g. contains fewer than two qubits in <code>encoding</code> <b>=</b> <code>TWOS_COMPLEMENT</code>)</li>
<li>if <code>functionNameCode</code> is not a valid <a class="el" href="group__type.html#gaa7d869b117ba5024d6b84938e8cdfc65" title="Flags for specifying named phase functions.">phaseFunc</a></li>
<li>if <code>functionNameCode</code> requires additional parameters, which must instead be passed with <a class="el" href="group__operator.html#ga225b82ff8b8eed1fff312240ec70c731" title="Induces a phase change upon each amplitude of qureg, determined by a named, paramaterized (and potent...">applyParamNamedPhaseFunc()</a> </li>
</ul>
</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#l00796">796</a> of file <a class="el" href="QuEST_8c_source.html">QuEST.c</a>.</p>
<div class="fragment"><div class="line"><a name="l00796"></a><span class="lineno"> 796</span>  {</div>
<div class="line"><a name="l00797"></a><span class="lineno"> 797</span>  <a class="code" href="QuEST__validation_8c.html#a0a45c9c3015af276ff7e624ae207ba7a">validateQubitSubregs</a>(qureg, qubits, numQubitsPerReg, numRegs, __func__);</div>
<div class="line"><a name="l00798"></a><span class="lineno"> 798</span>  <a class="code" href="QuEST__validation_8c.html#a9b348fc98867d01990da93a8de36936c">validateMultiRegBitEncoding</a>(numQubitsPerReg, numRegs, encoding, __func__);</div>
<div class="line"><a name="l00799"></a><span class="lineno"> 799</span>  <a class="code" href="QuEST__validation_8c.html#a99e98bb5d38287fbb51f1e094d1eb68e">validatePhaseFuncName</a>(functionNameCode, numRegs, 0, __func__);</div>
<div class="line"><a name="l00800"></a><span class="lineno"> 800</span>  </div>
<div class="line"><a name="l00801"></a><span class="lineno"> 801</span>  <span class="keywordtype">int</span> conj = 0;</div>
<div class="line"><a name="l00802"></a><span class="lineno"> 802</span>  <a class="code" href="QuEST__internal_8h.html#a7d8a817207847d2646a52044a63fd469">statevec_applyParamNamedPhaseFuncOverrides</a>(qureg, qubits, numQubitsPerReg, numRegs, encoding, functionNameCode, NULL, 0, NULL, NULL, 0, conj);</div>
<div class="line"><a name="l00803"></a><span class="lineno"> 803</span>  <span class="keywordflow">if</span> (qureg.<a class="code" href="structQureg.html#acf78445e9435d09f44f0cc832c6aee79">isDensityMatrix</a>) {</div>
<div class="line"><a name="l00804"></a><span class="lineno"> 804</span>  conj = 1;</div>
<div class="line"><a name="l00805"></a><span class="lineno"> 805</span>  <a class="code" href="QuEST__common_8c.html#aecc3c36b275c53b321de1611c2f06f78">shiftSubregIndices</a>(qubits, numQubitsPerReg, numRegs, qureg.<a class="code" href="structQureg.html#ad08dff5316b8937f4b2a1417591543dc">numQubitsRepresented</a>);</div>
<div class="line"><a name="l00806"></a><span class="lineno"> 806</span>  <a class="code" href="QuEST__internal_8h.html#a7d8a817207847d2646a52044a63fd469">statevec_applyParamNamedPhaseFuncOverrides</a>(qureg, qubits, numQubitsPerReg, numRegs, encoding, functionNameCode, NULL, 0, NULL, NULL, 0, conj);</div>
<div class="line"><a name="l00807"></a><span class="lineno"> 807</span>  <a class="code" href="QuEST__common_8c.html#aecc3c36b275c53b321de1611c2f06f78">shiftSubregIndices</a>(qubits, numQubitsPerReg, numRegs, - qureg.<a class="code" href="structQureg.html#ad08dff5316b8937f4b2a1417591543dc">numQubitsRepresented</a>);</div>
<div class="line"><a name="l00808"></a><span class="lineno"> 808</span>  }</div>
<div class="line"><a name="l00809"></a><span class="lineno"> 809</span>  </div>
<div class="line"><a name="l00810"></a><span class="lineno"> 810</span>  <a class="code" href="QuEST__qasm_8c.html#ab60a4a8af0530cbfa8cba1b02692d448">qasm_recordNamedPhaseFunc</a>(qureg, qubits, numQubitsPerReg, numRegs, encoding, functionNameCode, NULL, 0, NULL, NULL, 0);</div>
<div class="line"><a name="l00811"></a><span class="lineno"> 811</span> }</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST_8h_source.html#l00325">Qureg::isDensityMatrix</a>, <a class="el" href="QuEST_8h_source.html#l00327">Qureg::numQubitsRepresented</a>, <a class="el" href="QuEST__qasm_8c_source.html#l00726">qasm_recordNamedPhaseFunc()</a>, <a class="el" href="QuEST__common_8c_source.html#l00161">shiftSubregIndices()</a>, <a class="el" href="QuEST__cpu_8c_source.html#l04446">statevec_applyParamNamedPhaseFuncOverrides()</a>, <a class="el" href="QuEST__validation_8c_source.html#l00976">validateMultiRegBitEncoding()</a>, <a class="el" href="QuEST__validation_8c_source.html#l00913">validatePhaseFuncName()</a>, and <a class="el" href="QuEST__validation_8c_source.html#l00757">validateQubitSubregs()</a>.</p>
<p class="reference">Referenced by <a class="el" href="test__operators_8cpp_source.html#l01061">TEST_CASE()</a>.</p>
</div>
</div>
<a id="ga2fbaec3bb21cc01f7a2a4ed2aa911ebf"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga2fbaec3bb21cc01f7a2a4ed2aa911ebf">◆ </a></span>applyNamedPhaseFuncOverrides()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void applyNamedPhaseFuncOverrides </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">int * </td>
<td class="paramname"><em>qubits</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int * </td>
<td class="paramname"><em>numQubitsPerReg</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int </td>
<td class="paramname"><em>numRegs</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">enum <a class="el" href="group__type.html#ga9c91c41aa42ae537995e89ffc616afe1">bitEncoding</a> </td>
<td class="paramname"><em>encoding</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">enum <a class="el" href="group__type.html#gaa7d869b117ba5024d6b84938e8cdfc65">phaseFunc</a> </td>
<td class="paramname"><em>functionNameCode</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">long long int * </td>
<td class="paramname"><em>overrideInds</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype"><a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> * </td>
<td class="paramname"><em>overridePhases</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int </td>
<td class="paramname"><em>numOverrides</em> </td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Induces a phase change upon each amplitude of <code>qureg</code>, determined by a named (and potentially multi-variable) phase function, and an explicit set of 'overriding' values at specific state indices. </p>
<p>See <a class="el" href="group__operator.html#gac4df97d8c125c8cc65df720f67b2bf69" title="Induces a phase change upon each amplitude of qureg, determined by a named (and potentially multi-var...">applyNamedPhaseFunc()</a> first for a full description.</p>
<ul>
<li>As in <a class="el" href="group__operator.html#gac4df97d8c125c8cc65df720f67b2bf69" title="Induces a phase change upon each amplitude of qureg, determined by a named (and potentially multi-var...">applyNamedPhaseFunc()</a>, <code>functionNameCode</code> specifies a multi-variable phase function <img class="formulaInl" alt="$f(\vec{r})$" src="form_262.png"/>, where <img class="formulaInl" alt="$\vec{r}$" src="form_276.png"/> is determined by the sub-registers in <code>qubits</code>, and <a class="el" href="group__type.html#ga9c91c41aa42ae537995e89ffc616afe1" title="Flags for specifying how the bits in sub-register computational basis states are mapped to indices in...">bitEncoding</a> <code>encoding</code> for each basis state of <code>qureg</code>.<br />
<br />
</li>
<li><p class="startli">Additionally, <code>overrideInds</code> is a list of length <code>numOverrides</code> which specifies the values of <img class="formulaInl" alt="$\vec{r}$" src="form_276.png"/> for which to explicitly set the induced phase change.<br />
While flat, <code>overrideInds</code> should be imagined grouped into sub-lists of length <code>numRegs</code>, which specify the full <img class="formulaInl" alt="$\{r_1,\; \dots \;r_{\text{numRegs}} \} $" src="form_277.png"/> coordinate to override. <br />
Each sublist corresponds to a single element of <code>overridePhases</code>. <br />
For example, </p><div class="fragment"><div class="line"><span class="keywordtype">int</span> numRegs = 3;</div>
<div class="line"><span class="keywordtype">int</span> numOverrides = 2;</div>
<div class="line"><span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> overrideInds[] = { 0,0,0, 1,2,3 };</div>
<div class="line"><a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> overridePhases[] = { <a class="code" href="QuEST__common_8c.html#ae71449b1cc6e6250b91f539153a7a0d3">M_PI</a>, - <a class="code" href="QuEST__common_8c.html#ae71449b1cc6e6250b91f539153a7a0d3">M_PI</a> };</div>
</div><!-- fragment --><p class="startli">denotes that any basis state of <code>qureg</code> with sub-register values <img class="formulaInl" alt="$\{r_3,r_2,r_1\} = \{0, 0, 0\}$" src="form_278.png"/> (or <img class="formulaInl" alt="$\{r_3,r_2,r_1\} = \{1,2,3\}$" src="form_279.png"/>) should receive phase change <img class="formulaInl" alt="$\pi$" src="form_114.png"/> (or <img class="formulaInl" alt="$-\pi$" src="form_280.png"/>) in lieu of <img class="formulaInl" alt="$\exp(i f(r_3=0,r_2=0,r_1=0))$" src="form_281.png"/>.<br />
<br />
</p>
</li>
<li><p class="startli">The interpreted overrides can be previewed in the QASM log, as a comment. <br />
For example: </p><div class="fragment"><div class="line"><a class="code" href="group__qasm.html#ga65bf1906298ca6355e2942f4923d77b6">startRecordingQASM</a>(qureg);</div>
<div class="line"><a class="code" href="group__operator.html#ga2fbaec3bb21cc01f7a2a4ed2aa911ebf">applyNamedPhaseFuncOverrides</a>(qureg, ...);</div>
<div class="line"><a class="code" href="group__qasm.html#gacf139d0a54b1f9e5c2f2feff742b8c76">printRecordedQASM</a>(qureg);</div>
</div><!-- fragment --><p class="startli">may show </p><div class="fragment"><div class="line"><span class="comment">// Here, applyNamedPhaseFunc() multiplied ...</span></div>
<div class="line"><span class="comment">// though with overrides</span></div>
<div class="line"><span class="comment">// |x=0, y=0, z=0> -> exp(i 3.14159)</span></div>
<div class="line"><span class="comment">// |x=1, y=2, z=3> -> exp(i (-3.14159))</span></div>
</div><!-- fragment --></li>
</ul>
<p><br />
</p>
<dl class="section see"><dt>See also</dt><dd><ul>
<li><a class="el" href="group__operator.html#gaabd7efa3beebc9f3a525321d41a28989" title="Induces a phase change upon each amplitude of qureg, determined by a named, parameterised (and potent...">applyParamNamedPhaseFuncOverrides()</a> to specify <em>parameterised</em> named phase functions, with phase overrides.</li>
<li><a class="el" href="group__operator.html#ga467f517abd18dbc3d6fced84c6589161" title="Induces a phase change upon each amplitude of qureg, determined by the passed exponential polynomial ...">applyPhaseFunc()</a> to specify a general single-variable exponential polynomial phase function.</li>
<li><a class="el" href="group__operator.html#ga008a46d178a5a9691e2f5d363e3f518f" title="Induces a phase change upon each amplitude of qureg, determined by a multi-variable exponential polyn...">applyMultiVarPhaseFunc()</a> to specify a general multi-variable exponential polynomial phase function.</li>
<li><a class="el" href="group__operator.html#gad2e953390342cd361cfb4064d47715e6" title="Apply a diagonal operator, which is possibly non-unitary and non-Hermitian, to the entire qureg.">applyDiagonalOp()</a> to apply a non-unitary diagonal <a class="el" href="group__operator.html" title="Non-physical operators which may be non-unitary, non-norm-preserving, even non-Hermitian.">Operators</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 state-vector pr density-matrix to be modified </td></tr>
<tr><td class="paramdir">[in]</td><td class="paramname">qubits</td><td>a list of all the qubit indices contained in each sub-register </td></tr>
<tr><td class="paramdir">[in]</td><td class="paramname">numQubitsPerReg</td><td>a list of the lengths of each sub-list in <code>qubits</code> </td></tr>
<tr><td class="paramdir">[in]</td><td class="paramname">numRegs</td><td>the number of sub-registers, which is the length of both <code>numQubitsPerReg</code> and <code>numTermsPerReg</code> </td></tr>
<tr><td class="paramdir">[in]</td><td class="paramname">encoding</td><td>the <a class="el" href="group__type.html#ga9c91c41aa42ae537995e89ffc616afe1" title="Flags for specifying how the bits in sub-register computational basis states are mapped to indices in...">bitEncoding</a> under which to infer the binary value <img class="formulaInl" alt="$r_j$" src="form_269.png"/> from the bits of a sub-register </td></tr>
<tr><td class="paramdir">[in]</td><td class="paramname">functionNameCode</td><td>the <a class="el" href="group__type.html#gaa7d869b117ba5024d6b84938e8cdfc65" title="Flags for specifying named phase functions.">phaseFunc</a> <img class="formulaInl" alt="$f(\vec{r})$" src="form_262.png"/> </td></tr>
<tr><td class="paramdir">[in]</td><td class="paramname">overrideInds</td><td>a flattened list of sub-register coordinates (values of <img class="formulaInl" alt="$\vec{r}$" src="form_276.png"/>) of which to explicit set the phase change </td></tr>
<tr><td class="paramdir">[in]</td><td class="paramname">overridePhases</td><td>a list of replacement phase changes, for the corresponding <img class="formulaInl" alt="$\vec{r}$" src="form_276.png"/> values in <code>overrideInds</code> </td></tr>
<tr><td class="paramdir">[in]</td><td class="paramname">numOverrides</td><td>the lengths of list <code>overridePhases</code> (but not necessarily of <code>overrideInds</code>) </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>if any qubit in <code>qubits</code> has an invalid index (i.e. does not satisfy 0 <= qubit < <code>qureg.numQubitsRepresented</code>)</li>
<li>if the elements of <code>qubits</code> are not unique (including if sub-registers overlap)</li>
<li>if <code>numRegs</code> <= 0 or <code>numRegs</code> > 100 (constrained by <code>MAX_NUM_REGS_APPLY_ARBITRARY_PHASE</code> in <a class="el" href="QuEST__precision_8h.html">QuEST_precision.h</a>)</li>
<li>if <code>encoding</code> is not a valid <a class="el" href="group__type.html#ga9c91c41aa42ae537995e89ffc616afe1" title="Flags for specifying how the bits in sub-register computational basis states are mapped to indices in...">bitEncoding</a></li>
<li>if the size of any sub-register is incompatible with <code>encoding</code> (e.g. contains fewer than two qubits in <code>encoding</code> <b>=</b> <code>TWOS_COMPLEMENT</code>)</li>
<li>if <code>functionNameCode</code> is not a valid <a class="el" href="group__type.html#gaa7d869b117ba5024d6b84938e8cdfc65" title="Flags for specifying named phase functions.">phaseFunc</a></li>
<li>if <code>functionNameCode</code> requires additional parameters, which must instead be passed with <a class="el" href="group__operator.html#ga225b82ff8b8eed1fff312240ec70c731" title="Induces a phase change upon each amplitude of qureg, determined by a named, paramaterized (and potent...">applyParamNamedPhaseFunc()</a></li>
<li>if any value in <code>overrideInds</code> is not producible by its corresponding sub-register under the given <code>encoding</code> (e.g. 2 unsigned qubits cannot represent index 9)</li>
<li>if <code>numOverrides</code> < 0 </li>
</ul>
</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#l00813">813</a> of file <a class="el" href="QuEST_8c_source.html">QuEST.c</a>.</p>
<div class="fragment"><div class="line"><a name="l00813"></a><span class="lineno"> 813</span>  {</div>
<div class="line"><a name="l00814"></a><span class="lineno"> 814</span>  <a class="code" href="QuEST__validation_8c.html#a0a45c9c3015af276ff7e624ae207ba7a">validateQubitSubregs</a>(qureg, qubits, numQubitsPerReg, numRegs, __func__);</div>
<div class="line"><a name="l00815"></a><span class="lineno"> 815</span>  <a class="code" href="QuEST__validation_8c.html#a9b348fc98867d01990da93a8de36936c">validateMultiRegBitEncoding</a>(numQubitsPerReg, numRegs, encoding, __func__);</div>
<div class="line"><a name="l00816"></a><span class="lineno"> 816</span>  <a class="code" href="QuEST__validation_8c.html#a99e98bb5d38287fbb51f1e094d1eb68e">validatePhaseFuncName</a>(functionNameCode, numRegs, 0, __func__);</div>
<div class="line"><a name="l00817"></a><span class="lineno"> 817</span>  <a class="code" href="QuEST__validation_8c.html#a0edb4d9df94a40b8ea89c1c14997ee76">validateMultiVarPhaseFuncOverrides</a>(numQubitsPerReg, numRegs, encoding, overrideInds, numOverrides, __func__);</div>
<div class="line"><a name="l00818"></a><span class="lineno"> 818</span>  </div>
<div class="line"><a name="l00819"></a><span class="lineno"> 819</span>  <span class="keywordtype">int</span> conj = 0;</div>
<div class="line"><a name="l00820"></a><span class="lineno"> 820</span>  <a class="code" href="QuEST__internal_8h.html#a7d8a817207847d2646a52044a63fd469">statevec_applyParamNamedPhaseFuncOverrides</a>(qureg, qubits, numQubitsPerReg, numRegs, encoding, functionNameCode, NULL, 0, overrideInds, overridePhases, numOverrides, conj);</div>
<div class="line"><a name="l00821"></a><span class="lineno"> 821</span>  <span class="keywordflow">if</span> (qureg.<a class="code" href="structQureg.html#acf78445e9435d09f44f0cc832c6aee79">isDensityMatrix</a>) {</div>
<div class="line"><a name="l00822"></a><span class="lineno"> 822</span>  conj = 1;</div>
<div class="line"><a name="l00823"></a><span class="lineno"> 823</span>  <a class="code" href="QuEST__common_8c.html#aecc3c36b275c53b321de1611c2f06f78">shiftSubregIndices</a>(qubits, numQubitsPerReg, numRegs, qureg.<a class="code" href="structQureg.html#ad08dff5316b8937f4b2a1417591543dc">numQubitsRepresented</a>);</div>
<div class="line"><a name="l00824"></a><span class="lineno"> 824</span>  <a class="code" href="QuEST__internal_8h.html#a7d8a817207847d2646a52044a63fd469">statevec_applyParamNamedPhaseFuncOverrides</a>(qureg, qubits, numQubitsPerReg, numRegs, encoding, functionNameCode, NULL, 0, overrideInds, overridePhases, numOverrides, conj);</div>
<div class="line"><a name="l00825"></a><span class="lineno"> 825</span>  <a class="code" href="QuEST__common_8c.html#aecc3c36b275c53b321de1611c2f06f78">shiftSubregIndices</a>(qubits, numQubitsPerReg, numRegs, - qureg.<a class="code" href="structQureg.html#ad08dff5316b8937f4b2a1417591543dc">numQubitsRepresented</a>);</div>
<div class="line"><a name="l00826"></a><span class="lineno"> 826</span>  }</div>
<div class="line"><a name="l00827"></a><span class="lineno"> 827</span>  </div>
<div class="line"><a name="l00828"></a><span class="lineno"> 828</span>  <a class="code" href="QuEST__qasm_8c.html#ab60a4a8af0530cbfa8cba1b02692d448">qasm_recordNamedPhaseFunc</a>(qureg, qubits, numQubitsPerReg, numRegs, encoding, functionNameCode, NULL, 0, overrideInds, overridePhases, numOverrides);</div>
<div class="line"><a name="l00829"></a><span class="lineno"> 829</span> }</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST_8h_source.html#l00325">Qureg::isDensityMatrix</a>, <a class="el" href="QuEST_8h_source.html#l00327">Qureg::numQubitsRepresented</a>, <a class="el" href="QuEST__qasm_8c_source.html#l00726">qasm_recordNamedPhaseFunc()</a>, <a class="el" href="QuEST__common_8c_source.html#l00161">shiftSubregIndices()</a>, <a class="el" href="QuEST__cpu_8c_source.html#l04446">statevec_applyParamNamedPhaseFuncOverrides()</a>, <a class="el" href="QuEST__validation_8c_source.html#l00976">validateMultiRegBitEncoding()</a>, <a class="el" href="QuEST__validation_8c_source.html#l00886">validateMultiVarPhaseFuncOverrides()</a>, <a class="el" href="QuEST__validation_8c_source.html#l00913">validatePhaseFuncName()</a>, and <a class="el" href="QuEST__validation_8c_source.html#l00757">validateQubitSubregs()</a>.</p>
<p class="reference">Referenced by <a class="el" href="test__operators_8cpp_source.html#l01273">TEST_CASE()</a>.</p>
</div>
</div>
<a id="ga225b82ff8b8eed1fff312240ec70c731"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga225b82ff8b8eed1fff312240ec70c731">◆ </a></span>applyParamNamedPhaseFunc()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void applyParamNamedPhaseFunc </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">int * </td>
<td class="paramname"><em>qubits</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int * </td>
<td class="paramname"><em>numQubitsPerReg</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int </td>
<td class="paramname"><em>numRegs</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">enum <a class="el" href="group__type.html#ga9c91c41aa42ae537995e89ffc616afe1">bitEncoding</a> </td>
<td class="paramname"><em>encoding</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">enum <a class="el" href="group__type.html#gaa7d869b117ba5024d6b84938e8cdfc65">phaseFunc</a> </td>
<td class="paramname"><em>functionNameCode</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype"><a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> * </td>
<td class="paramname"><em>params</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int </td>
<td class="paramname"><em>numParams</em> </td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Induces a phase change upon each amplitude of <code>qureg</code>, determined by a named, paramaterized (and potentially multi-variable) phase function. </p>
<p>See <a class="el" href="group__operator.html#gac4df97d8c125c8cc65df720f67b2bf69" title="Induces a phase change upon each amplitude of qureg, determined by a named (and potentially multi-var...">applyNamedPhaseFunc()</a> for full documentation. <br />
This function merely accepts additional <a class="el" href="group__type.html#gaa7d869b117ba5024d6b84938e8cdfc65" title="Flags for specifying named phase functions.">phaseFunc</a> names which accept one (or more) parameters.</p>
<ul>
<li><p class="startli">Argument <code>functionNameCode</code>, which determines the phase function <img class="formulaInl" alt="$f(\vec{r}, \vec{\theta})$" src="form_287.png"/>, can include parameterised <a class="el" href="group__type.html#gaa7d869b117ba5024d6b84938e8cdfc65" title="Flags for specifying named phase functions.">phaseFunc</a> names like <code>SCALED_NORM</code>, which require additional parameters <img class="formulaInl" alt="$\vec{\theta}$" src="form_288.png"/> passed via list <code>params</code>.<br />
For example, </p><div class="fragment"><div class="line"><span class="keyword">enum</span> <a class="code" href="group__type.html#gaa7d869b117ba5024d6b84938e8cdfc65">phaseFunc</a> functionNameCode = <a class="code" href="group__type.html#ggaa7d869b117ba5024d6b84938e8cdfc65a31a29a30f92fe34c35098f941adbbc93">SCALED_PRODUCT</a>;</div>
<div class="line"><a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> params[] = {0.5};</div>
<div class="line"><span class="keywordtype">int</span> numParams = 1;</div>
<div class="line"><a class="code" href="group__operator.html#ga225b82ff8b8eed1fff312240ec70c731">applyParamNamedPhaseFunc</a>(..., functionNameCode, params, numParams);</div>
</div><!-- fragment --><p class="startli">invokes phase function </p><p class="formulaDsp">
<img class="formulaDsp" alt="\[ f(\vec{r}, \theta)|_{\theta=0.5} \; = \; 0.5 \prod_j^{\text{numRegs}} \; r_j\,. \]" src="form_289.png"/>
</p>
<p> See <a class="el" href="group__type.html#gaa7d869b117ba5024d6b84938e8cdfc65" title="Flags for specifying named phase functions.">phaseFunc</a> for all named phased functions.</p>
</li>
<li><p class="startli">Functions with divergences, like <code>INVERSE_NORM</code> and <code>SCALED_INVERSE_DISTANCE</code>, must accompany an extra parameter to specify an overriding phase at the divergence. For example, </p><div class="fragment"><div class="line"><span class="keyword">enum</span> <a class="code" href="group__type.html#gaa7d869b117ba5024d6b84938e8cdfc65">phaseFunc</a> functionNameCode = <a class="code" href="group__type.html#ggaa7d869b117ba5024d6b84938e8cdfc65ae8c96906c1ec109d295c491e572d01e2">SCALED_INVERSE_NORM</a>;</div>
<div class="line"><a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> params[] = {0.5, <a class="code" href="QuEST__common_8c.html#ae71449b1cc6e6250b91f539153a7a0d3">M_PI</a>};</div>
<div class="line"><span class="keywordtype">int</span> numParams = 2;</div>
<div class="line"><a class="code" href="group__operator.html#ga225b82ff8b8eed1fff312240ec70c731">applyParamNamedPhaseFunc</a>(..., functionNameCode, params, numParams);</div>
</div><!-- fragment --><p class="startli">invokes phase function </p><p class="formulaDsp">
<img class="formulaDsp" alt="\[ f(\vec{r}, \theta)|_{\theta=0.5} \; = \; \begin{cases} \pi & \;\;\; \vec{r}=\vec{0} \\ \displaystyle 0.5 \left[ \sum_j^{\text{numRegs}} {r_j}^2 \right]^{-1/2} & \;\;\;\text{otherwise} \end{cases}. \]" src="form_290.png"/>
</p>
<p> Notice the order of the parameters matches the order of the words in the <code>phaseFunc</code>. </p><blockquote class="doxtable">
<p>Functions <code>SCALED_INVERSE_SHIFTED_NORM</code> and <code>SCALED_INVERSE_SHIFTED_DISTANCE</code>, which can have denominators arbitrarily close to zero, will invoke the divergence parameter whenever the denominator is smaller than (or equal to) machine precision <code>REAL_EPS</code>. </p>
</blockquote>
</li>
<li><p class="startli">Functions allowing the shifting of sub-register values, which are <code>SCALED_INVERSE_SHIFTED_NORM</code> and <code>SCALED_INVERSE_SHIFTED_DISTANCE</code>, need these shift values to be passed in the <code>params</code> argument <em>after</em> the scaling and divergence override parameters listed above. The function <code>SCALED_INVERSE_SHIFTED_NORM</code> needs as many extra parameters, as there are sub-registers; <code>SCALED_INVERSE_SHIFTED_DISTANCE</code> needs one extra parameter for each pair of sub-registers. For example, </p><div class="fragment"><div class="line"><span class="keyword">enum</span> <a class="code" href="group__type.html#gaa7d869b117ba5024d6b84938e8cdfc65">phaseFunc</a> functionNameCode = <a class="code" href="group__type.html#ggaa7d869b117ba5024d6b84938e8cdfc65aa318172feec5b530e9a7849f2f7b44e7">SCALED_INVERSE_SHIFTED_NORM</a>;</div>
<div class="line"><span class="keywordtype">int</span> qubits[] = {0,1,2,3, 4,5,6,7};</div>
<div class="line"><span class="keywordtype">int</span> qubitsPerReg[] = {4, 4};</div>
<div class="line"><a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> params[] = {0.5, <a class="code" href="QuEST__common_8c.html#ae71449b1cc6e6250b91f539153a7a0d3">M_PI</a>, 0.8, -0.3};</div>
<div class="line"><span class="keywordtype">int</span> numParams = 4;</div>
<div class="line"><a class="code" href="group__operator.html#ga225b82ff8b8eed1fff312240ec70c731">applyParamNamedPhaseFunc</a>(..., qubits, qubitsPerReg, 2, ..., functionNameCode, params, numParams);</div>
</div><!-- fragment --><p class="startli">invokes phase function </p><p class="formulaDsp">
<img class="formulaDsp" alt="\[ f(\vec{r}) \; = \; \begin{cases} \pi & \;\;\; \vec{r}=\vec{0} \\ \displaystyle 0.5 \left[(r_1-0.8)^2 + (r_2+0.3)^2\right]^{-1/2} & \;\;\;\text{otherwise} \end{cases}. \]" src="form_291.png"/>
</p>
<p> and </p><div class="fragment"><div class="line"><span class="keyword">enum</span> <a class="code" href="group__type.html#gaa7d869b117ba5024d6b84938e8cdfc65">phaseFunc</a> functionNameCode = <a class="code" href="group__type.html#ggaa7d869b117ba5024d6b84938e8cdfc65a39111120b79016d6b3e773b711fa63f7">SCALED_INVERSE_SHIFTED_DISTANCE</a>;</div>
<div class="line"><span class="keywordtype">int</span> qubits[] = {0,1, 2,3, 4,5, 6,7};</div>
<div class="line"><span class="keywordtype">int</span> qubitsPerReg[] = {2, 2, 2, 2};</div>
<div class="line"><a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> params[] = {0.5, <a class="code" href="QuEST__common_8c.html#ae71449b1cc6e6250b91f539153a7a0d3">M_PI</a>, 0.8, -0.3};</div>
<div class="line"><span class="keywordtype">int</span> numParams = 4;</div>
<div class="line"><a class="code" href="group__operator.html#ga225b82ff8b8eed1fff312240ec70c731">applyParamNamedPhaseFunc</a>(..., qubits, qubitsPerReg, 4, ..., functionNameCode, params, numParams);</div>
</div><!-- fragment --><p class="startli">invokes phase function </p><p class="formulaDsp">
<img class="formulaDsp" alt="\[ f(\vec{r}) \; = \; \begin{cases} \pi & \;\;\; \vec{r}=\vec{0} \\ \displaystyle 0.5 \left[(r_1-r_2-0.8)^2 + (r_3-r_4+0.3)^2\right]^{-1/2} & \;\;\;\text{otherwise} \end{cases}. \]" src="form_292.png"/>
</p>
</li>
</ul>
<blockquote class="doxtable">
<p>You can further override <img class="formulaInl" alt="$f(\vec{r}, \vec{\theta})$" src="form_287.png"/> at one or more <img class="formulaInl" alt="$\vec{r}$" src="form_276.png"/> values via <a class="el" href="group__operator.html#gaabd7efa3beebc9f3a525321d41a28989" title="Induces a phase change upon each amplitude of qureg, determined by a named, parameterised (and potent...">applyParamNamedPhaseFuncOverrides()</a>. </p>
</blockquote>
<ul>
<li><p class="startli">The interpreted parameterised phase function can be previewed in the QASM log, as a comment. <br />
For example: </p><div class="fragment"><div class="line"><a class="code" href="group__qasm.html#ga65bf1906298ca6355e2942f4923d77b6">startRecordingQASM</a>(qureg);</div>
<div class="line"><a class="code" href="group__operator.html#ga225b82ff8b8eed1fff312240ec70c731">applyParamNamedPhaseFunc</a>(...);</div>
<div class="line"><a class="code" href="group__qasm.html#gacf139d0a54b1f9e5c2f2feff742b8c76">printRecordedQASM</a>(qureg);</div>
</div><!-- fragment --><p class="startli">may show </p><div class="fragment"><div class="line"><span class="comment">// Here, applyNamedPhaseFunc() multiplied a complex scalar of form</span></div>
<div class="line"><span class="comment">// exp(i (-0.5) / (x y z))</span></div>
</div><!-- fragment --></li>
</ul>
<p><br />
</p>
<dl class="section see"><dt>See also</dt><dd><ul>
<li><a class="el" href="group__operator.html#gaabd7efa3beebc9f3a525321d41a28989" title="Induces a phase change upon each amplitude of qureg, determined by a named, parameterised (and potent...">applyParamNamedPhaseFuncOverrides()</a> to additionally specify phase values for specific sub-register indices.</li>
<li><a class="el" href="group__operator.html#ga467f517abd18dbc3d6fced84c6589161" title="Induces a phase change upon each amplitude of qureg, determined by the passed exponential polynomial ...">applyPhaseFunc()</a> to specify a general single-variable exponential polynomial phase function.</li>
<li><a class="el" href="group__operator.html#ga008a46d178a5a9691e2f5d363e3f518f" title="Induces a phase change upon each amplitude of qureg, determined by a multi-variable exponential polyn...">applyMultiVarPhaseFunc()</a> to specify a general multi-variable exponential polynomial phase function.</li>
<li><a class="el" href="group__operator.html#gad2e953390342cd361cfb4064d47715e6" title="Apply a diagonal operator, which is possibly non-unitary and non-Hermitian, to the entire qureg.">applyDiagonalOp()</a> to apply a non-unitary diagonal <a class="el" href="group__operator.html" title="Non-physical operators which may be non-unitary, non-norm-preserving, even non-Hermitian.">Operators</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 state-vector or density-matrix to be modified </td></tr>
<tr><td class="paramdir">[in]</td><td class="paramname">qubits</td><td>a list of all the qubit indices contained in each sub-register </td></tr>
<tr><td class="paramdir">[in]</td><td class="paramname">numQubitsPerReg</td><td>a list of the lengths of each sub-list in <code>qubits</code> </td></tr>
<tr><td class="paramdir">[in]</td><td class="paramname">numRegs</td><td>the number of sub-registers, which is the length of both <code>numQubitsPerReg</code> and <code>numTermsPerReg</code> </td></tr>
<tr><td class="paramdir">[in]</td><td class="paramname">encoding</td><td>the <a class="el" href="group__type.html#ga9c91c41aa42ae537995e89ffc616afe1" title="Flags for specifying how the bits in sub-register computational basis states are mapped to indices in...">bitEncoding</a> under which to infer the binary value <img class="formulaInl" alt="$r_j$" src="form_269.png"/> from the bits of a sub-register </td></tr>
<tr><td class="paramdir">[in]</td><td class="paramname">functionNameCode</td><td>the <a class="el" href="group__type.html#gaa7d869b117ba5024d6b84938e8cdfc65" title="Flags for specifying named phase functions.">phaseFunc</a> <img class="formulaInl" alt="$f(\vec{r}, \vec{\theta})$" src="form_287.png"/> </td></tr>
<tr><td class="paramdir">[in]</td><td class="paramname">params</td><td>a list of any additional parameters needed by the <a class="el" href="group__type.html#gaa7d869b117ba5024d6b84938e8cdfc65" title="Flags for specifying named phase functions.">phaseFunc</a> <code>functionNameCode</code> </td></tr>
<tr><td class="paramdir">[in]</td><td class="paramname">numParams</td><td>the length of list <code>params</code> </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>if any qubit in <code>qubits</code> has an invalid index (i.e. does not satisfy 0 <= qubit < <code>qureg.numQubitsRepresented</code>)</li>
<li>if the elements of <code>qubits</code> are not unique (including if sub-registers overlap)</li>
<li>if <code>numRegs</code> <= 0 or <code>numRegs</code> > 100 (constrained by <code>MAX_NUM_REGS_APPLY_ARBITRARY_PHASE</code> in <a class="el" href="QuEST__precision_8h.html">QuEST_precision.h</a>)</li>
<li>if <code>encoding</code> is not a valid <a class="el" href="group__type.html#ga9c91c41aa42ae537995e89ffc616afe1" title="Flags for specifying how the bits in sub-register computational basis states are mapped to indices in...">bitEncoding</a></li>
<li>if the size of any sub-register is incompatible with <code>encoding</code> (e.g. contains fewer than two qubits in <code>encoding</code> <b>=</b> <code>TWOS_COMPLEMENT</code>)</li>
<li>if <code>functionNameCode</code> is not a valid <a class="el" href="group__type.html#gaa7d869b117ba5024d6b84938e8cdfc65" title="Flags for specifying named phase functions.">phaseFunc</a></li>
<li>if <code>numParams</code> is incompatible with <code>functionNameCode</code> (for example, no parameters were passed to <code>SCALED_PRODUCT</code>) </li>
</ul>
</td></tr>
</table>
</dd>
</dl>
<dl class="section author"><dt>Author</dt><dd>Tyson Jones </dd>
<dd>
Richard Meister (shifted functions) </dd></dl>
<p class="definition">Definition at line <a class="el" href="QuEST_8c_source.html#l00831">831</a> of file <a class="el" href="QuEST_8c_source.html">QuEST.c</a>.</p>
<div class="fragment"><div class="line"><a name="l00831"></a><span class="lineno"> 831</span>  {</div>
<div class="line"><a name="l00832"></a><span class="lineno"> 832</span>  <a class="code" href="QuEST__validation_8c.html#a0a45c9c3015af276ff7e624ae207ba7a">validateQubitSubregs</a>(qureg, qubits, numQubitsPerReg, numRegs, __func__);</div>
<div class="line"><a name="l00833"></a><span class="lineno"> 833</span>  <a class="code" href="QuEST__validation_8c.html#a9b348fc98867d01990da93a8de36936c">validateMultiRegBitEncoding</a>(numQubitsPerReg, numRegs, encoding, __func__);</div>
<div class="line"><a name="l00834"></a><span class="lineno"> 834</span>  <a class="code" href="QuEST__validation_8c.html#a99e98bb5d38287fbb51f1e094d1eb68e">validatePhaseFuncName</a>(functionNameCode, numRegs, numParams, __func__);</div>
<div class="line"><a name="l00835"></a><span class="lineno"> 835</span>  </div>
<div class="line"><a name="l00836"></a><span class="lineno"> 836</span>  <span class="keywordtype">int</span> conj = 0;</div>
<div class="line"><a name="l00837"></a><span class="lineno"> 837</span>  <a class="code" href="QuEST__internal_8h.html#a7d8a817207847d2646a52044a63fd469">statevec_applyParamNamedPhaseFuncOverrides</a>(qureg, qubits, numQubitsPerReg, numRegs, encoding, functionNameCode, params, numParams, NULL, NULL, 0, conj);</div>
<div class="line"><a name="l00838"></a><span class="lineno"> 838</span>  <span class="keywordflow">if</span> (qureg.<a class="code" href="structQureg.html#acf78445e9435d09f44f0cc832c6aee79">isDensityMatrix</a>) {</div>
<div class="line"><a name="l00839"></a><span class="lineno"> 839</span>  conj = 1;</div>
<div class="line"><a name="l00840"></a><span class="lineno"> 840</span>  <a class="code" href="QuEST__common_8c.html#aecc3c36b275c53b321de1611c2f06f78">shiftSubregIndices</a>(qubits, numQubitsPerReg, numRegs, qureg.<a class="code" href="structQureg.html#ad08dff5316b8937f4b2a1417591543dc">numQubitsRepresented</a>);</div>
<div class="line"><a name="l00841"></a><span class="lineno"> 841</span>  <a class="code" href="QuEST__internal_8h.html#a7d8a817207847d2646a52044a63fd469">statevec_applyParamNamedPhaseFuncOverrides</a>(qureg, qubits, numQubitsPerReg, numRegs, encoding, functionNameCode, params, numParams, NULL, NULL, 0, conj);</div>
<div class="line"><a name="l00842"></a><span class="lineno"> 842</span>  <a class="code" href="QuEST__common_8c.html#aecc3c36b275c53b321de1611c2f06f78">shiftSubregIndices</a>(qubits, numQubitsPerReg, numRegs, - qureg.<a class="code" href="structQureg.html#ad08dff5316b8937f4b2a1417591543dc">numQubitsRepresented</a>);</div>
<div class="line"><a name="l00843"></a><span class="lineno"> 843</span>  }</div>
<div class="line"><a name="l00844"></a><span class="lineno"> 844</span>  </div>
<div class="line"><a name="l00845"></a><span class="lineno"> 845</span>  <a class="code" href="QuEST__qasm_8c.html#ab60a4a8af0530cbfa8cba1b02692d448">qasm_recordNamedPhaseFunc</a>(qureg, qubits, numQubitsPerReg, numRegs, encoding, functionNameCode, params, numParams, NULL, NULL, 0);</div>
<div class="line"><a name="l00846"></a><span class="lineno"> 846</span> }</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST_8h_source.html#l00325">Qureg::isDensityMatrix</a>, <a class="el" href="QuEST_8h_source.html#l00327">Qureg::numQubitsRepresented</a>, <a class="el" href="QuEST__qasm_8c_source.html#l00726">qasm_recordNamedPhaseFunc()</a>, <a class="el" href="QuEST__common_8c_source.html#l00161">shiftSubregIndices()</a>, <a class="el" href="QuEST__cpu_8c_source.html#l04446">statevec_applyParamNamedPhaseFuncOverrides()</a>, <a class="el" href="QuEST__validation_8c_source.html#l00976">validateMultiRegBitEncoding()</a>, <a class="el" href="QuEST__validation_8c_source.html#l00913">validatePhaseFuncName()</a>, and <a class="el" href="QuEST__validation_8c_source.html#l00757">validateQubitSubregs()</a>.</p>
<p class="reference">Referenced by <a class="el" href="test__operators_8cpp_source.html#l01552">TEST_CASE()</a>.</p>
</div>
</div>
<a id="gaabd7efa3beebc9f3a525321d41a28989"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gaabd7efa3beebc9f3a525321d41a28989">◆ </a></span>applyParamNamedPhaseFuncOverrides()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void applyParamNamedPhaseFuncOverrides </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">int * </td>
<td class="paramname"><em>qubits</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int * </td>
<td class="paramname"><em>numQubitsPerReg</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int </td>
<td class="paramname"><em>numRegs</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">enum <a class="el" href="group__type.html#ga9c91c41aa42ae537995e89ffc616afe1">bitEncoding</a> </td>
<td class="paramname"><em>encoding</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">enum <a class="el" href="group__type.html#gaa7d869b117ba5024d6b84938e8cdfc65">phaseFunc</a> </td>
<td class="paramname"><em>functionNameCode</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype"><a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> * </td>
<td class="paramname"><em>params</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int </td>
<td class="paramname"><em>numParams</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">long long int * </td>
<td class="paramname"><em>overrideInds</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype"><a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> * </td>
<td class="paramname"><em>overridePhases</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int </td>
<td class="paramname"><em>numOverrides</em> </td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Induces a phase change upon each amplitude of <code>qureg</code>, determined by a named, parameterised (and potentially multi-variable) phase function, and an explicit set of 'overriding' values at specific state indices. </p>
<p>See <a class="el" href="group__operator.html#ga225b82ff8b8eed1fff312240ec70c731" title="Induces a phase change upon each amplitude of qureg, determined by a named, paramaterized (and potent...">applyParamNamedPhaseFunc()</a> and <a class="el" href="group__operator.html#gac4df97d8c125c8cc65df720f67b2bf69" title="Induces a phase change upon each amplitude of qureg, determined by a named (and potentially multi-var...">applyNamedPhaseFunc()</a> first for a full description.</p>
<ul>
<li>As in <a class="el" href="group__operator.html#ga225b82ff8b8eed1fff312240ec70c731" title="Induces a phase change upon each amplitude of qureg, determined by a named, paramaterized (and potent...">applyParamNamedPhaseFunc()</a>, <code>functionNameCode</code> specifies a parameterised multi-variable phase function <img class="formulaInl" alt="$f(\vec{r}, \vec{\theta})$" src="form_287.png"/>, where <img class="formulaInl" alt="$\vec{\theta}$" src="form_288.png"/> is passed in list <code>params</code>, and <img class="formulaInl" alt="$\vec{r}$" src="form_276.png"/> is determined both by the sub-registers in <code>qubits</code>, and <a class="el" href="group__type.html#ga9c91c41aa42ae537995e89ffc616afe1" title="Flags for specifying how the bits in sub-register computational basis states are mapped to indices in...">bitEncoding</a> <code>encoding</code> for each basis state of <code>qureg</code>.<br />
<br />
</li>
<li><p class="startli">Additionally, <code>overrideInds</code> is a list of length <code>numOverrides</code> which specifies the values of <img class="formulaInl" alt="$\vec{r}$" src="form_276.png"/> for which to explicitly set the induced phase change.<br />
While flat, <code>overrideInds</code> should be imagined grouped into sub-lists of length <code>numRegs</code>, which specify the full <img class="formulaInl" alt="$\{r_1,\; \dots \;r_{\text{numRegs}} \} $" src="form_277.png"/> coordinate to override. <br />
Each sublist corresponds to a single element of <code>overridePhases</code>. <br />
For example, </p><div class="fragment"><div class="line"><span class="keywordtype">int</span> numRegs = 3;</div>
<div class="line"><span class="keywordtype">int</span> numOverrides = 2;</div>
<div class="line"><span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> overrideInds[] = { 0,0,0, 1,2,3 };</div>
<div class="line"><a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> overridePhases[] = { <a class="code" href="QuEST__common_8c.html#ae71449b1cc6e6250b91f539153a7a0d3">M_PI</a>, - <a class="code" href="QuEST__common_8c.html#ae71449b1cc6e6250b91f539153a7a0d3">M_PI</a> };</div>
</div><!-- fragment --><p class="startli">denotes that any basis state of <code>qureg</code> with sub-register values <img class="formulaInl" alt="$\{r_3,r_2,r_1\} = \{0, 0, 0\}$" src="form_278.png"/> (or <img class="formulaInl" alt="$\{r_3,r_2,r_1\} = \{1,2,3\}$" src="form_279.png"/>) should receive phase change <img class="formulaInl" alt="$\pi$" src="form_114.png"/> (or <img class="formulaInl" alt="$-\pi$" src="form_280.png"/>) in lieu of <img class="formulaInl" alt="$\exp(i f(r_3=0,r_2=0,r_1=0, \vec{\theta}))$" src="form_293.png"/>.<br />
<br />
</p>
</li>
<li><p class="startli">The interpreted overrides can be previewed in the QASM log, as a comment. <br />
For example: </p><div class="fragment"><div class="line"><a class="code" href="group__qasm.html#ga65bf1906298ca6355e2942f4923d77b6">startRecordingQASM</a>(qureg);</div>
<div class="line"><a class="code" href="group__operator.html#gaabd7efa3beebc9f3a525321d41a28989">applyParamNamedPhaseFuncOverrides</a>(qureg, ...);</div>
<div class="line"><a class="code" href="group__qasm.html#gacf139d0a54b1f9e5c2f2feff742b8c76">printRecordedQASM</a>(qureg);</div>
</div><!-- fragment --><p class="startli">may show </p><div class="fragment"><div class="line"><span class="comment">// Here, applyParamNamedPhaseFunc() multiplied ...</span></div>
<div class="line"><span class="comment">// though with overrides</span></div>
<div class="line"><span class="comment">// |x=0, y=0, z=0> -> exp(i 3.14159)</span></div>
<div class="line"><span class="comment">// |x=1, y=2, z=3> -> exp(i (-3.14159))</span></div>
</div><!-- fragment --></li>
</ul>
<p><br />
</p>
<dl class="section see"><dt>See also</dt><dd><ul>
<li><a class="el" href="group__operator.html#ga467f517abd18dbc3d6fced84c6589161" title="Induces a phase change upon each amplitude of qureg, determined by the passed exponential polynomial ...">applyPhaseFunc()</a> to specify a general single-variable exponential polynomial phase function.</li>
<li><a class="el" href="group__operator.html#ga008a46d178a5a9691e2f5d363e3f518f" title="Induces a phase change upon each amplitude of qureg, determined by a multi-variable exponential polyn...">applyMultiVarPhaseFunc()</a> to specify a general multi-variable exponential polynomial phase function.</li>
<li><a class="el" href="group__operator.html#gad2e953390342cd361cfb4064d47715e6" title="Apply a diagonal operator, which is possibly non-unitary and non-Hermitian, to the entire qureg.">applyDiagonalOp()</a> to apply a non-unitary diagonal <a class="el" href="group__operator.html" title="Non-physical operators which may be non-unitary, non-norm-preserving, even non-Hermitian.">Operators</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 state-vector or density-matrix to be modified </td></tr>
<tr><td class="paramdir">[in]</td><td class="paramname">qubits</td><td>a list of all the qubit indices contained in each sub-register </td></tr>
<tr><td class="paramdir">[in]</td><td class="paramname">numQubitsPerReg</td><td>a list of the lengths of each sub-list in <code>qubits</code> </td></tr>
<tr><td class="paramdir">[in]</td><td class="paramname">numRegs</td><td>the number of sub-registers, which is the length of both <code>numQubitsPerReg</code> and <code>numTermsPerReg</code> </td></tr>
<tr><td class="paramdir">[in]</td><td class="paramname">encoding</td><td>the <a class="el" href="group__type.html#ga9c91c41aa42ae537995e89ffc616afe1" title="Flags for specifying how the bits in sub-register computational basis states are mapped to indices in...">bitEncoding</a> under which to infer the binary value <img class="formulaInl" alt="$r_j$" src="form_269.png"/> from the bits of a sub-register </td></tr>
<tr><td class="paramdir">[in]</td><td class="paramname">functionNameCode</td><td>the <a class="el" href="group__type.html#gaa7d869b117ba5024d6b84938e8cdfc65" title="Flags for specifying named phase functions.">phaseFunc</a> <img class="formulaInl" alt="$f(\vec{r}, \vec{\theta})$" src="form_287.png"/> </td></tr>
<tr><td class="paramdir">[in]</td><td class="paramname">params</td><td>a list of any additional parameters <img class="formulaInl" alt="$\vec{\theta}$" src="form_288.png"/> needed by the <a class="el" href="group__type.html#gaa7d869b117ba5024d6b84938e8cdfc65" title="Flags for specifying named phase functions.">phaseFunc</a> <code>functionNameCode</code> </td></tr>
<tr><td class="paramdir">[in]</td><td class="paramname">numParams</td><td>the length of list <code>params</code> </td></tr>
<tr><td class="paramdir">[in]</td><td class="paramname">overrideInds</td><td>a flattened list of sub-register coordinates (values of <img class="formulaInl" alt="$\vec{r}$" src="form_276.png"/>) of which to explicit set the phase change </td></tr>
<tr><td class="paramdir">[in]</td><td class="paramname">overridePhases</td><td>a list of replacement phase changes, for the corresponding <img class="formulaInl" alt="$\vec{r}$" src="form_276.png"/> values in <code>overrideInds</code> </td></tr>
<tr><td class="paramdir">[in]</td><td class="paramname">numOverrides</td><td>the lengths of list <code>overridePhases</code> (but not necessarily of <code>overrideInds</code>) </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>if any qubit in <code>qubits</code> has an invalid index (i.e. does not satisfy 0 <= qubit < <code>qureg.numQubitsRepresented</code>)</li>
<li>if the elements of <code>qubits</code> are not unique (including if sub-registers overlap)</li>
<li>if <code>numRegs</code> <= 0 or <code>numRegs</code> > 100 (constrained by <code>MAX_NUM_REGS_APPLY_ARBITRARY_PHASE</code> in <a class="el" href="QuEST__precision_8h.html">QuEST_precision.h</a>)</li>
<li>if <code>encoding</code> is not a valid <a class="el" href="group__type.html#ga9c91c41aa42ae537995e89ffc616afe1" title="Flags for specifying how the bits in sub-register computational basis states are mapped to indices in...">bitEncoding</a></li>
<li>if the size of any sub-register is incompatible with <code>encoding</code> (e.g. contains fewer than two qubits in <code>encoding</code> <b>=</b> <code>TWOS_COMPLEMENT</code>)</li>
<li>if <code>functionNameCode</code> is not a valid <a class="el" href="group__type.html#gaa7d869b117ba5024d6b84938e8cdfc65" title="Flags for specifying named phase functions.">phaseFunc</a></li>
<li>if <code>numParams</code> is incompatible with <code>functionNameCode</code> (for example, no parameters were passed to <code>SCALED_PRODUCT</code>)</li>
<li>if any value in <code>overrideInds</code> is not producible by its corresponding sub-register under the given <code>encoding</code> (e.g. 2 unsigned qubits cannot represent index 9)</li>
<li>if <code>numOverrides</code> < 0 </li>
</ul>
</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#l00848">848</a> of file <a class="el" href="QuEST_8c_source.html">QuEST.c</a>.</p>
<div class="fragment"><div class="line"><a name="l00848"></a><span class="lineno"> 848</span>  {</div>
<div class="line"><a name="l00849"></a><span class="lineno"> 849</span>  <a class="code" href="QuEST__validation_8c.html#a0a45c9c3015af276ff7e624ae207ba7a">validateQubitSubregs</a>(qureg, qubits, numQubitsPerReg, numRegs, __func__);</div>
<div class="line"><a name="l00850"></a><span class="lineno"> 850</span>  <a class="code" href="QuEST__validation_8c.html#a9b348fc98867d01990da93a8de36936c">validateMultiRegBitEncoding</a>(numQubitsPerReg, numRegs, encoding, __func__);</div>
<div class="line"><a name="l00851"></a><span class="lineno"> 851</span>  <a class="code" href="QuEST__validation_8c.html#a99e98bb5d38287fbb51f1e094d1eb68e">validatePhaseFuncName</a>(functionNameCode, numRegs, numParams, __func__);</div>
<div class="line"><a name="l00852"></a><span class="lineno"> 852</span>  <a class="code" href="QuEST__validation_8c.html#a0edb4d9df94a40b8ea89c1c14997ee76">validateMultiVarPhaseFuncOverrides</a>(numQubitsPerReg, numRegs, encoding, overrideInds, numOverrides, __func__);</div>
<div class="line"><a name="l00853"></a><span class="lineno"> 853</span>  </div>
<div class="line"><a name="l00854"></a><span class="lineno"> 854</span>  <span class="keywordtype">int</span> conj = 0;</div>
<div class="line"><a name="l00855"></a><span class="lineno"> 855</span>  <a class="code" href="QuEST__internal_8h.html#a7d8a817207847d2646a52044a63fd469">statevec_applyParamNamedPhaseFuncOverrides</a>(qureg, qubits, numQubitsPerReg, numRegs, encoding, functionNameCode, params, numParams, overrideInds, overridePhases, numOverrides, conj);</div>
<div class="line"><a name="l00856"></a><span class="lineno"> 856</span>  <span class="keywordflow">if</span> (qureg.<a class="code" href="structQureg.html#acf78445e9435d09f44f0cc832c6aee79">isDensityMatrix</a>) {</div>
<div class="line"><a name="l00857"></a><span class="lineno"> 857</span>  conj = 1;</div>
<div class="line"><a name="l00858"></a><span class="lineno"> 858</span>  <a class="code" href="QuEST__common_8c.html#aecc3c36b275c53b321de1611c2f06f78">shiftSubregIndices</a>(qubits, numQubitsPerReg, numRegs, qureg.<a class="code" href="structQureg.html#ad08dff5316b8937f4b2a1417591543dc">numQubitsRepresented</a>);</div>
<div class="line"><a name="l00859"></a><span class="lineno"> 859</span>  <a class="code" href="QuEST__internal_8h.html#a7d8a817207847d2646a52044a63fd469">statevec_applyParamNamedPhaseFuncOverrides</a>(qureg, qubits, numQubitsPerReg, numRegs, encoding, functionNameCode, params, numParams, overrideInds, overridePhases, numOverrides, conj);</div>
<div class="line"><a name="l00860"></a><span class="lineno"> 860</span>  <a class="code" href="QuEST__common_8c.html#aecc3c36b275c53b321de1611c2f06f78">shiftSubregIndices</a>(qubits, numQubitsPerReg, numRegs, - qureg.<a class="code" href="structQureg.html#ad08dff5316b8937f4b2a1417591543dc">numQubitsRepresented</a>);</div>
<div class="line"><a name="l00861"></a><span class="lineno"> 861</span>  }</div>
<div class="line"><a name="l00862"></a><span class="lineno"> 862</span>  </div>
<div class="line"><a name="l00863"></a><span class="lineno"> 863</span>  <a class="code" href="QuEST__qasm_8c.html#ab60a4a8af0530cbfa8cba1b02692d448">qasm_recordNamedPhaseFunc</a>(qureg, qubits, numQubitsPerReg, numRegs, encoding, functionNameCode, params, numParams, overrideInds, overridePhases, numOverrides);</div>
<div class="line"><a name="l00864"></a><span class="lineno"> 864</span> }</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST_8h_source.html#l00325">Qureg::isDensityMatrix</a>, <a class="el" href="QuEST_8h_source.html#l00327">Qureg::numQubitsRepresented</a>, <a class="el" href="QuEST__qasm_8c_source.html#l00726">qasm_recordNamedPhaseFunc()</a>, <a class="el" href="QuEST__common_8c_source.html#l00161">shiftSubregIndices()</a>, <a class="el" href="QuEST__cpu_8c_source.html#l04446">statevec_applyParamNamedPhaseFuncOverrides()</a>, <a class="el" href="QuEST__validation_8c_source.html#l00976">validateMultiRegBitEncoding()</a>, <a class="el" href="QuEST__validation_8c_source.html#l00886">validateMultiVarPhaseFuncOverrides()</a>, <a class="el" href="QuEST__validation_8c_source.html#l00913">validatePhaseFuncName()</a>, and <a class="el" href="QuEST__validation_8c_source.html#l00757">validateQubitSubregs()</a>.</p>
<p class="reference">Referenced by <a class="el" href="test__operators_8cpp_source.html#l02079">TEST_CASE()</a>.</p>
</div>
</div>
<a id="ga54d4e589468002bdc998200ae45e7312"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga54d4e589468002bdc998200ae45e7312">◆ </a></span>applyPauliHamil()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void applyPauliHamil </td>
<td>(</td>
<td class="paramtype"><a class="el" href="structQureg.html">Qureg</a> </td>
<td class="paramname"><em>inQureg</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype"><a class="el" href="structPauliHamil.html">PauliHamil</a> </td>
<td class="paramname"><em>hamil</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype"><a class="el" href="structQureg.html">Qureg</a> </td>
<td class="paramname"><em>outQureg</em> </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 <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> (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 state-vector 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>This is merely an encapsulation of <a class="el" href="group__operator.html#ga6fc26cf857db070e12959e59ecfed8a6" title="Modifies outQureg to be the result of applying the weighted sum of Pauli products (a Hermitian but no...">applyPauliSum()</a>, which can refer to for elaborated doc.</p>
<p>Letting <code>hamil</code> be expressed as <img class="formulaInl" alt="$ \alpha = \sum_i c_i \otimes_j^{N} \hat{\sigma}_{i,j} $" src="form_230.png"/> (where <img class="formulaInl" alt="$ c_i \in $" src="form_203.png"/> <code>hamil.termCoeffs</code> and <img class="formulaInl" alt="$ N = $" src="form_204.png"/> <code>hamil.numQubits</code>), this function effects <img class="formulaInl" alt="$ \alpha | \psi \rangle $" src="form_231.png"/> on state-vector <img class="formulaInl" alt="$ |\psi\rangle $" src="form_232.png"/> and <img class="formulaInl" alt="$\alpha \rho$" src="form_233.png"/> (left matrix multiplication) on density matrix <img class="formulaInl" alt="$ \rho $" src="form_47.png"/>.</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 to <code>hamil</code>. <code>inQureg</code> cannot be <code>outQureg</code>.</p>
<p>This function works by applying each Pauli product in <code>hamil</code> 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="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#gaa77376c5e3518186eb085f37826d6008" title="Creates a PauliHamil instance, a real-weighted sum of products of Pauli operators,...">createPauliHamilFromFile()</a></li>
<li><a class="el" href="group__calc.html#ga5544d2833a69941b8820797b79daf79f" title="Computes the expected value of qureg under Hermitian operator hamil.">calcExpecPauliHamil()</a></li>
<li><a class="el" href="group__operator.html#ga35b6321c578a8c69470132b5ee95f930" title="Applies a trotterisation of unitary evolution to qureg.">applyTrotterCircuit()</a></li>
</ul>
</dd></dl>
<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 <code>hamil</code>. <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">hamil</td><td>a weighted sum of products of pauli operators </td></tr>
<tr><td class="paramdir">[out]</td><td class="paramname">outQureg</td><td>the qureg to modify to be the result of applyling <code>hamil</code> 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"><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>if any code in <code>hamil.pauliCodes</code> is not a valid Pauli code</li>
<li>if <code>numSumTerms</code> <= 0</li>
<li>if <code>inQureg</code> is not of the same type and dimensions as <code>outQureg</code> and <code>hamil</code> </li>
</ul>
</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#l01059">1059</a> of file <a class="el" href="QuEST_8c_source.html">QuEST.c</a>.</p>
<div class="fragment"><div class="line"><a name="l01059"></a><span class="lineno"> 1059</span>  {</div>
<div class="line"><a name="l01060"></a><span class="lineno"> 1060</span>  <a class="code" href="QuEST__validation_8c.html#a031812e1cf2c98d72d795cea7bbe73a5">validateMatchingQuregTypes</a>(inQureg, outQureg, __func__);</div>
<div class="line"><a name="l01061"></a><span class="lineno"> 1061</span>  <a class="code" href="QuEST__validation_8c.html#a87d22240ccfd81827a2a34b8d569d347">validateMatchingQuregDims</a>(inQureg, outQureg, __func__);</div>
<div class="line"><a name="l01062"></a><span class="lineno"> 1062</span>  <a class="code" href="QuEST__validation_8c.html#a066b0c4d0b02a0f3b9be7e5c68d9de6a">validatePauliHamil</a>(hamil, __func__);</div>
<div class="line"><a name="l01063"></a><span class="lineno"> 1063</span>  <a class="code" href="QuEST__validation_8c.html#a2b88b068a8242ee28da42c7324cdd078">validateMatchingQuregPauliHamilDims</a>(inQureg, hamil, __func__);</div>
<div class="line"><a name="l01064"></a><span class="lineno"> 1064</span>  </div>
<div class="line"><a name="l01065"></a><span class="lineno"> 1065</span>  <a class="code" href="QuEST__common_8c.html#af71c2470694795a8d639be8ff9c34ed5">statevec_applyPauliSum</a>(inQureg, hamil.<a class="code" href="structPauliHamil.html#a4b8d38c403553c07ceddcd40c46ce6c8">pauliCodes</a>, hamil.<a class="code" href="structPauliHamil.html#ac1c6c9f6299cf83bbba88123216c3cac">termCoeffs</a>, hamil.<a class="code" href="structPauliHamil.html#a737e46b40ef8990cf004d22eb9dbe2e4">numSumTerms</a>, outQureg);</div>
<div class="line"><a name="l01066"></a><span class="lineno"> 1066</span>  </div>
<div class="line"><a name="l01067"></a><span class="lineno"> 1067</span>  <a class="code" href="QuEST__qasm_8c.html#a9a385fde708958617bbeb599064b8dcb">qasm_recordComment</a>(outQureg, <span class="stringliteral">"Here, the register was modified to an undisclosed and possibly unphysical state (applyPauliHamil)."</span>);</div>
<div class="line"><a name="l01068"></a><span class="lineno"> 1068</span> }</div>
</div><!-- fragment -->
<p class="reference">References <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__qasm_8c_source.html#l00121">qasm_recordComment()</a>, <a class="el" href="QuEST__common_8c_source.html#l00538">statevec_applyPauliSum()</a>, <a class="el" href="QuEST_8h_source.html#l00283">PauliHamil::termCoeffs</a>, <a class="el" href="QuEST__validation_8c_source.html#l00531">validateMatchingQuregDims()</a>, <a class="el" href="QuEST__validation_8c_source.html#l00660">validateMatchingQuregPauliHamilDims()</a>, <a class="el" href="QuEST__validation_8c_source.html#l00535">validateMatchingQuregTypes()</a>, and <a class="el" href="QuEST__validation_8c_source.html#l00655">validatePauliHamil()</a>.</p>
<p class="reference">Referenced by <a class="el" href="test__operators_8cpp_source.html#l02675">TEST_CASE()</a>.</p>
</div>
</div>
<a id="ga6fc26cf857db070e12959e59ecfed8a6"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga6fc26cf857db070e12959e59ecfed8a6">◆ </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> </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> * </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> * </td>
<td class="paramname"><em>termCoeffs</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int </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> </td>
<td class="paramname"><em>outQureg</em> </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 state-vector 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_230.png"/> be the operators indicated by <code>allPauliCodes</code> (where <img class="formulaInl" alt="$ c_i \in $" src="form_203.png"/> <code>termCoeffs</code> and <img class="formulaInl" alt="$ N = $" src="form_204.png"/> <code>qureg.numQubitsRepresented</code>), this function effects <img class="formulaInl" alt="$ \alpha | \psi \rangle $" src="form_231.png"/> on state-vector <img class="formulaInl" alt="$ |\psi\rangle $" src="form_232.png"/> and <img class="formulaInl" alt="$\alpha \rho$" src="form_233.png"/> (left matrix multiplication) on density matrix <img class="formulaInl" alt="$ \rho $" src="form_47.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 state-vector, </p><div class="fragment"><div class="line"><span class="keywordtype">int</span> paulis[6] = {<a class="code" href="group__type.html#gga1c703cf89629e4e9c7023cd402d67028a7abac7bb5b71e17382014c443244ad5c">PAULI_X</a>, <a class="code" href="group__type.html#gga1c703cf89629e4e9c7023cd402d67028a63800f45b01ccc2608f754aee850bf4a">PAULI_I</a>, <a class="code" href="group__type.html#gga1c703cf89629e4e9c7023cd402d67028a63800f45b01ccc2608f754aee850bf4a">PAULI_I</a>, <a class="code" href="group__type.html#gga1c703cf89629e4e9c7023cd402d67028a7abac7bb5b71e17382014c443244ad5c">PAULI_X</a>, <a class="code" href="group__type.html#gga1c703cf89629e4e9c7023cd402d67028a2c64a9aaee27f6bcfef894d159e759bd">PAULI_Y</a>, <a class="code" href="group__type.html#gga1c703cf89629e4e9c7023cd402d67028a085c85cff6ba79c52d8b1e61c42ddddf">PAULI_Z</a>};</div>
<div class="line"><a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> coeffs[2] = {1.5, -3.6};</div>
<div class="line"><a class="code" href="group__operator.html#ga6fc26cf857db070e12959e59ecfed8a6">applyPauliSum</a>(inQureg, paulis, coeffs, 2, outQureg);</div>
</div><!-- fragment --><p>will apply Hermitian operation <img class="formulaInl" alt="$ (1.5 X I I - 3.6 X Y Z) $" src="form_234.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="section see"><dt>See also</dt><dd><ul>
<li><a class="el" href="group__calc.html#ga50ee589fd5ceab52fdd70d0082352b41" title="Computes the expected value of a sum of products of Pauli operators.">calcExpecPauliSum()</a></li>
<li><a class="el" href="group__operator.html#ga54d4e589468002bdc998200ae45e7312" title="Modifies outQureg to be the result of applying PauliHamil (a Hermitian but not necessarily unitary op...">applyPauliHamil()</a></li>
</ul>
</dd></dl>
<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"><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>if any code in <code>allPauliCodes</code> is not in {0,1,2,3}</li>
<li>if numSumTerms <= 0</li>
<li>if <code>inQureg</code> is not of the same type and dimensions as <code>outQureg</code> </li>
</ul>
</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#l01048">1048</a> of file <a class="el" href="QuEST_8c_source.html">QuEST.c</a>.</p>
<div class="fragment"><div class="line"><a name="l01048"></a><span class="lineno"> 1048</span>  {</div>
<div class="line"><a name="l01049"></a><span class="lineno"> 1049</span>  <a class="code" href="QuEST__validation_8c.html#a031812e1cf2c98d72d795cea7bbe73a5">validateMatchingQuregTypes</a>(inQureg, outQureg, __func__);</div>
<div class="line"><a name="l01050"></a><span class="lineno"> 1050</span>  <a class="code" href="QuEST__validation_8c.html#a87d22240ccfd81827a2a34b8d569d347">validateMatchingQuregDims</a>(inQureg, outQureg, __func__);</div>
<div class="line"><a name="l01051"></a><span class="lineno"> 1051</span>  <a class="code" href="QuEST__validation_8c.html#a5be128290a7bba9a7f12d32cabe2276b">validateNumPauliSumTerms</a>(numSumTerms, __func__);</div>
<div class="line"><a name="l01052"></a><span class="lineno"> 1052</span>  <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="l01053"></a><span class="lineno"> 1053</span>  </div>
<div class="line"><a name="l01054"></a><span class="lineno"> 1054</span>  <a class="code" href="QuEST__common_8c.html#af71c2470694795a8d639be8ff9c34ed5">statevec_applyPauliSum</a>(inQureg, allPauliCodes, termCoeffs, numSumTerms, outQureg);</div>
<div class="line"><a name="l01055"></a><span class="lineno"> 1055</span>  </div>
<div class="line"><a name="l01056"></a><span class="lineno"> 1056</span>  <a class="code" href="QuEST__qasm_8c.html#a9a385fde708958617bbeb599064b8dcb">qasm_recordComment</a>(outQureg, <span class="stringliteral">"Here, the register was modified to an undisclosed and possibly unphysical state (applyPauliSum)."</span>);</div>
<div class="line"><a name="l01057"></a><span class="lineno"> 1057</span> }</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST_8h_source.html#l00327">Qureg::numQubitsRepresented</a>, <a class="el" href="QuEST__qasm_8c_source.html#l00121">qasm_recordComment()</a>, <a class="el" href="QuEST__common_8c_source.html#l00538">statevec_applyPauliSum()</a>, <a class="el" href="QuEST__validation_8c_source.html#l00531">validateMatchingQuregDims()</a>, <a class="el" href="QuEST__validation_8c_source.html#l00535">validateMatchingQuregTypes()</a>, <a class="el" href="QuEST__validation_8c_source.html#l00606">validateNumPauliSumTerms()</a>, and <a class="el" href="QuEST__validation_8c_source.html#l00599">validatePauliCodes()</a>.</p>
<p class="reference">Referenced by <a class="el" href="test__operators_8cpp_source.html#l02775">TEST_CASE()</a>.</p>
</div>
</div>
<a id="ga467f517abd18dbc3d6fced84c6589161"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga467f517abd18dbc3d6fced84c6589161">◆ </a></span>applyPhaseFunc()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void applyPhaseFunc </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">int * </td>
<td class="paramname"><em>qubits</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int </td>
<td class="paramname"><em>numQubits</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">enum <a class="el" href="group__type.html#ga9c91c41aa42ae537995e89ffc616afe1">bitEncoding</a> </td>
<td class="paramname"><em>encoding</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype"><a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> * </td>
<td class="paramname"><em>coeffs</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype"><a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> * </td>
<td class="paramname"><em>exponents</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int </td>
<td class="paramname"><em>numTerms</em> </td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Induces a phase change upon each amplitude of <code>qureg</code>, determined by the passed exponential polynomial "phase function". </p>
<p>This effects a diagonal unitary of unit complex scalars, targeting the nominated <code>qubits</code>.</p>
<ul>
<li><p class="startli">Arguments <code>coeffs</code> and <code>exponents</code> together specify a real exponential polynomial <img class="formulaInl" alt="$f(r)$" src="form_245.png"/> with <code>numTerms</code> terms, of the form </p><p class="formulaDsp">
<img class="formulaDsp" alt="\[ f(r) = \sum\limits_{i}^{\text{numTerms}} \text{coeffs}[i] \; r^{\, \text{exponents}[i]}\,, \]" src="form_246.png"/>
</p>
<p> where both <code>coeffs</code> and <code>exponents</code> can be negative, positive and fractional. For example, </p><div class="fragment"><div class="line"><a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> coeffs[] = {1, -3.14};</div>
<div class="line"><a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> exponents[] = {2, -5.5};</div>
<div class="line"><span class="keywordtype">int</span> numTerms = 2;</div>
</div><!-- fragment --><p class="startli">constitutes the function </p><p class="formulaDsp">
<img class="formulaDsp" alt="\[ f(r) = 1 \, r^2 - 3.14 \, r^{-5.5}. \]" src="form_247.png"/>
</p>
<p> Note you cannot use fractional exponents with <code>encoding</code> <b>=</b> <a class="el" href="group__type.html#gga9c91c41aa42ae537995e89ffc616afe1a9aa2a35d92976c7de970506c4d19a96c">TWOS_COMPLEMENT</a>, since the negative indices would generate (illegal) complex phases, and must be overriden with <a class="el" href="group__operator.html#gaf5344129240243ad11d0c081eb9036ab" title="Induces a phase change upon each amplitude of qureg, determined by the passed exponential polynomial ...">applyPhaseFuncOverrides()</a>. <br />
</p><blockquote class="doxtable">
<p>If your function <img class="formulaInl" alt="$f(r)$" src="form_245.png"/> diverges at one or more <img class="formulaInl" alt="$r$" src="form_248.png"/> values, you must instead use <a class="el" href="group__operator.html#gaf5344129240243ad11d0c081eb9036ab" title="Induces a phase change upon each amplitude of qureg, determined by the passed exponential polynomial ...">applyPhaseFuncOverrides()</a> and specify explicit phase changes for these values. Otherwise, the corresponding amplitudes of the state-vector will become indeterminate (like <code>NaN</code>). Note that use of any negative exponent will result in divergences at <img class="formulaInl" alt="$r=0$" src="form_249.png"/>. </p>
</blockquote>
</li>
<li>The function <img class="formulaInl" alt="$f(r)$" src="form_245.png"/> specifies the phase change to induce upon amplitude <img class="formulaInl" alt="$\alpha$" src="form_88.png"/> of computational basis state with index <img class="formulaInl" alt="$r$" src="form_248.png"/>, such that <p class="formulaDsp">
<img class="formulaDsp" alt="\[ \alpha \, |r\rangle \rightarrow \, \exp(i f(r)) \; \alpha \, |r\rangle. \]" src="form_250.png"/>
</p>
The index <img class="formulaInl" alt="$r$" src="form_248.png"/> associated with each computational basis state is determined by the binary value of the specified <code>qubits</code> (ordered least to most significant), interpreted under the given <a class="el" href="group__type.html#ga9c91c41aa42ae537995e89ffc616afe1" title="Flags for specifying how the bits in sub-register computational basis states are mapped to indices in...">bitEncoding</a> <code>encoding</code>. <br />
<br />
For example, under <code>encoding</code> <b>=</b> <code>UNSIGNED</code> and <code>qubits</code> <b>= {0,1}</b>, <p class="formulaDsp">
<img class="formulaDsp" alt="\[ \begin{aligned} |0\mathbf{00}\rangle & \rightarrow \, e^{i f(0)}\,|0\mathbf{00}\rangle \\ |0\mathbf{01}\rangle & \rightarrow \, e^{i f(1)}\,|0\mathbf{01}\rangle \\ |0\mathbf{10}\rangle & \rightarrow \, e^{i f(2)}\,|0\mathbf{10}\rangle \\ |0\mathbf{11}\rangle & \rightarrow \, e^{i f(3)}\,|0\mathbf{11}\rangle \\ |1\mathbf{00}\rangle & \rightarrow \, e^{i f(0)}\,|1\mathbf{00}\rangle \\ |1\mathbf{01}\rangle & \rightarrow \, e^{i f(1)}\,|1\mathbf{01}\rangle \\ |1\mathbf{10}\rangle & \rightarrow \, e^{i f(2)}\,|1\mathbf{10}\rangle \\ |1\mathbf{11}\rangle & \rightarrow \, e^{i f(3)}\,|1\mathbf{11}\rangle \end{aligned} \]" src="form_251.png"/>
</p>
</li>
<li>If <code>qureg</code> is a density matrix <img class="formulaInl" alt="$\rho$" src="form_40.png"/>, this function modifies <code>qureg</code> to <p class="formulaDsp">
<img class="formulaDsp" alt="\[ \rho \rightarrow \hat{D} \, \rho \, \hat{D}^\dagger \]" src="form_252.png"/>
</p>
where <img class="formulaInl" alt="$\hat{D}$" src="form_42.png"/> is the diagonal unitary operator <p class="formulaDsp">
<img class="formulaDsp" alt="\[ \hat{D} = \text{diag} \, \{ \; e^{i f(r_0)}, \; e^{i f(r_1)}, \; \dots \; \}. \]" src="form_253.png"/>
</p>
This means element <img class="formulaInl" alt="$\rho_{jk}$" src="form_254.png"/> is modified to <p class="formulaDsp">
<img class="formulaDsp" alt="\[ \alpha \, |j\rangle\langle k| \; \rightarrow \; e^{i (f(r_j) - f(r_k))} \; \alpha \, |j\rangle\langle k| \]" src="form_255.png"/>
</p>
<br />
</li>
<li><p class="startli">The interpreted phase function can be previewed in the QASM log, as a comment. <br />
For example: </p><div class="fragment"><div class="line"><a class="code" href="group__qasm.html#ga65bf1906298ca6355e2942f4923d77b6">startRecordingQASM</a>(qureg);</div>
<div class="line"><a class="code" href="group__operator.html#ga467f517abd18dbc3d6fced84c6589161">applyPhaseFunc</a>(qureg, ...);</div>
<div class="line"><a class="code" href="group__qasm.html#gacf139d0a54b1f9e5c2f2feff742b8c76">printRecordedQASM</a>(qureg);</div>
</div><!-- fragment --><p class="startli">may show </p><div class="fragment"><div class="line"><span class="comment">// Here, applyPhaseFunc() multiplied a complex scalar of the form</span></div>
<div class="line"><span class="comment">// exp(i (1 x^3))</span></div>
<div class="line"><span class="comment">// upon every substate |x>, informed by qubits (under an unsigned binary encoding)</span></div>
<div class="line"><span class="comment">// {4, 1, 2, 0}</span></div>
</div><!-- fragment --></li>
</ul>
<blockquote class="doxtable">
<p>This function may become numerically imprecise for quickly growing phase functions which admit very large phases, for example of 10^10. </p>
</blockquote>
<dl class="section see"><dt>See also</dt><dd><ul>
<li><a class="el" href="group__operator.html#gaf5344129240243ad11d0c081eb9036ab" title="Induces a phase change upon each amplitude of qureg, determined by the passed exponential polynomial ...">applyPhaseFuncOverrides()</a> to override the phase function for specific states.</li>
<li><a class="el" href="group__operator.html#ga008a46d178a5a9691e2f5d363e3f518f" title="Induces a phase change upon each amplitude of qureg, determined by a multi-variable exponential polyn...">applyMultiVarPhaseFunc()</a> for multi-variable exponential polynomial phase functions.</li>
<li><a class="el" href="group__operator.html#gac4df97d8c125c8cc65df720f67b2bf69" title="Induces a phase change upon each amplitude of qureg, determined by a named (and potentially multi-var...">applyNamedPhaseFunc()</a> for a set of specific phase functions.</li>
<li><a class="el" href="group__operator.html#gad2e953390342cd361cfb4064d47715e6" title="Apply a diagonal operator, which is possibly non-unitary and non-Hermitian, to the entire qureg.">applyDiagonalOp()</a> to apply a non-unitary diagonal <a class="el" href="group__operator.html" title="Non-physical operators which may be non-unitary, non-norm-preserving, even non-Hermitian.">Operators</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 state-vector or density matrix to be modified </td></tr>
<tr><td class="paramdir">[in]</td><td class="paramname">qubits</td><td>a list of the indices of the qubits which will inform <img class="formulaInl" alt="$r$" src="form_248.png"/> for each amplitude in <code>qureg</code> </td></tr>
<tr><td class="paramdir">[in]</td><td class="paramname">numQubits</td><td>the length of list <code>qubits</code> </td></tr>
<tr><td class="paramdir">[in]</td><td class="paramname">encoding</td><td>the <a class="el" href="group__type.html#ga9c91c41aa42ae537995e89ffc616afe1" title="Flags for specifying how the bits in sub-register computational basis states are mapped to indices in...">bitEncoding</a> under which to infer the binary value <img class="formulaInl" alt="$r$" src="form_248.png"/> from the bits of <code>qubits</code> in each basis state of <code>qureg</code> </td></tr>
<tr><td class="paramdir">[in]</td><td class="paramname">coeffs</td><td>the coefficients of the exponential polynomial phase function <img class="formulaInl" alt="$f(r)$" src="form_245.png"/> </td></tr>
<tr><td class="paramdir">[in]</td><td class="paramname">exponents</td><td>the exponents of the exponential polynomial phase function <img class="formulaInl" alt="$f(r)$" src="form_245.png"/> </td></tr>
<tr><td class="paramdir">[in]</td><td class="paramname">numTerms</td><td>the length of list <code>coeffs</code>, which must be the same as that of <code>exponents</code> </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>if any qubit in <code>qubits</code> has an invalid index (i.e. does not satisfy 0 <= qubit < <code>qureg.numQubitsRepresented</code>)</li>
<li>if the elements of <code>qubits</code> are not unique</li>
<li>if <code>numQubits</code> < 0 or <code>numQubits</code> >= <code>qureg.numQubitsRepresented</code></li>
<li>if <code>encoding</code> is not a valid <a class="el" href="group__type.html#ga9c91c41aa42ae537995e89ffc616afe1" title="Flags for specifying how the bits in sub-register computational basis states are mapped to indices in...">bitEncoding</a></li>
<li>if <code>encoding</code> is not compatible with <code>numQubits</code> (e.g. <code>TWOS_COMPLEMENT</code> with only 1 qubit)</li>
<li>if <code>exponents</code> contains a fractional number despite <code>encoding</code> <b>=</b> <a class="el" href="group__type.html#gga9c91c41aa42ae537995e89ffc616afe1a9aa2a35d92976c7de970506c4d19a96c">TWOS_COMPLEMENT</a> (you must instead use <a class="el" href="group__operator.html#gaf5344129240243ad11d0c081eb9036ab" title="Induces a phase change upon each amplitude of qureg, determined by the passed exponential polynomial ...">applyPhaseFuncOverrides()</a> and override all negative indices)</li>
<li>if <code>exponents</code> contains a negative power (you must instead use <a class="el" href="group__operator.html#gaf5344129240243ad11d0c081eb9036ab" title="Induces a phase change upon each amplitude of qureg, determined by the passed exponential polynomial ...">applyPhaseFuncOverrides()</a> and override the zero index)</li>
<li>if <code>numTerms</code> <= 0 </li>
</ul>
</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#l00726">726</a> of file <a class="el" href="QuEST_8c_source.html">QuEST.c</a>.</p>
<div class="fragment"><div class="line"><a name="l00726"></a><span class="lineno"> 726</span>  {</div>
<div class="line"><a name="l00727"></a><span class="lineno"> 727</span>  <a class="code" href="QuEST__validation_8c.html#a9e7e85cfc36e3ce1f456a840a217bfd9">validateMultiQubits</a>(qureg, qubits, numQubits, __func__);</div>
<div class="line"><a name="l00728"></a><span class="lineno"> 728</span>  <a class="code" href="QuEST__validation_8c.html#aa8a0654753645b30d6fed4ed0f4e7d16">validateBitEncoding</a>(numQubits, encoding, __func__);</div>
<div class="line"><a name="l00729"></a><span class="lineno"> 729</span>  <a class="code" href="QuEST__validation_8c.html#a91dad925cb9383384f135b936e5a7f43">validatePhaseFuncTerms</a>(numQubits, encoding, coeffs, exponents, numTerms, NULL, 0, __func__);</div>
<div class="line"><a name="l00730"></a><span class="lineno"> 730</span>  </div>
<div class="line"><a name="l00731"></a><span class="lineno"> 731</span>  <span class="keywordtype">int</span> conj = 0;</div>
<div class="line"><a name="l00732"></a><span class="lineno"> 732</span>  <a class="code" href="QuEST__internal_8h.html#a9d7928473aca695a614e9c24d903e578">statevec_applyPhaseFuncOverrides</a>(qureg, qubits, numQubits, encoding, coeffs, exponents, numTerms, NULL, NULL, 0, conj);</div>
<div class="line"><a name="l00733"></a><span class="lineno"> 733</span>  <span class="keywordflow">if</span> (qureg.<a class="code" href="structQureg.html#acf78445e9435d09f44f0cc832c6aee79">isDensityMatrix</a>) {</div>
<div class="line"><a name="l00734"></a><span class="lineno"> 734</span>  conj = 1;</div>
<div class="line"><a name="l00735"></a><span class="lineno"> 735</span>  <a class="code" href="QuEST__common_8c.html#acf1c651a4359a370a2d9b3e1e1ebd430">shiftIndices</a>(qubits, numQubits, qureg.<a class="code" href="structQureg.html#ad08dff5316b8937f4b2a1417591543dc">numQubitsRepresented</a>);</div>
<div class="line"><a name="l00736"></a><span class="lineno"> 736</span>  <a class="code" href="QuEST__internal_8h.html#a9d7928473aca695a614e9c24d903e578">statevec_applyPhaseFuncOverrides</a>(qureg, qubits, numQubits, encoding, coeffs, exponents, numTerms, NULL, NULL, 0, conj);</div>
<div class="line"><a name="l00737"></a><span class="lineno"> 737</span>  <a class="code" href="QuEST__common_8c.html#acf1c651a4359a370a2d9b3e1e1ebd430">shiftIndices</a>(qubits, numQubits, - qureg.<a class="code" href="structQureg.html#ad08dff5316b8937f4b2a1417591543dc">numQubitsRepresented</a>);</div>
<div class="line"><a name="l00738"></a><span class="lineno"> 738</span>  }</div>
<div class="line"><a name="l00739"></a><span class="lineno"> 739</span>  </div>
<div class="line"><a name="l00740"></a><span class="lineno"> 740</span>  <a class="code" href="QuEST__qasm_8c.html#a383ddaecc94e1ce4a6fdbdbabeaa3131">qasm_recordPhaseFunc</a>(qureg, qubits, numQubits, encoding, coeffs, exponents, numTerms, NULL, NULL, 0);</div>
<div class="line"><a name="l00741"></a><span class="lineno"> 741</span> }</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST_8h_source.html#l00325">Qureg::isDensityMatrix</a>, <a class="el" href="QuEST_8h_source.html#l00327">Qureg::numQubitsRepresented</a>, <a class="el" href="QuEST__qasm_8c_source.html#l00490">qasm_recordPhaseFunc()</a>, <a class="el" href="QuEST__common_8c_source.html#l00156">shiftIndices()</a>, <a class="el" href="QuEST__cpu_8c_source.html#l04268">statevec_applyPhaseFuncOverrides()</a>, <a class="el" href="QuEST__validation_8c_source.html#l00966">validateBitEncoding()</a>, <a class="el" href="QuEST__validation_8c_source.html#l00444">validateMultiQubits()</a>, and <a class="el" href="QuEST__validation_8c_source.html#l00773">validatePhaseFuncTerms()</a>.</p>
<p class="reference">Referenced by <a class="el" href="test__operators_8cpp_source.html#l02871">TEST_CASE()</a>.</p>
</div>
</div>
<a id="gaf5344129240243ad11d0c081eb9036ab"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gaf5344129240243ad11d0c081eb9036ab">◆ </a></span>applyPhaseFuncOverrides()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void applyPhaseFuncOverrides </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">int * </td>
<td class="paramname"><em>qubits</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int </td>
<td class="paramname"><em>numQubits</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">enum <a class="el" href="group__type.html#ga9c91c41aa42ae537995e89ffc616afe1">bitEncoding</a> </td>
<td class="paramname"><em>encoding</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype"><a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> * </td>
<td class="paramname"><em>coeffs</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype"><a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> * </td>
<td class="paramname"><em>exponents</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int </td>
<td class="paramname"><em>numTerms</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">long long int * </td>
<td class="paramname"><em>overrideInds</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype"><a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> * </td>
<td class="paramname"><em>overridePhases</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int </td>
<td class="paramname"><em>numOverrides</em> </td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Induces a phase change upon each amplitude of <code>qureg</code>, determined by the passed exponential polynomial "phase function", and an explicit set of 'overriding' values at specific state indices. </p>
<p>See <a class="el" href="group__operator.html#ga467f517abd18dbc3d6fced84c6589161" title="Induces a phase change upon each amplitude of qureg, determined by the passed exponential polynomial ...">applyPhaseFunc()</a> first for a full description.</p>
<ul>
<li>As in <a class="el" href="group__operator.html#ga467f517abd18dbc3d6fced84c6589161" title="Induces a phase change upon each amplitude of qureg, determined by the passed exponential polynomial ...">applyPhaseFunc()</a>, the arguments <code>coeffs</code> and <code>exponents</code> specify a phase function <img class="formulaInl" alt="$f(r)$" src="form_245.png"/>, where <img class="formulaInl" alt="$r$" src="form_248.png"/> is determined by <code>qubits</code> and <code>encoding</code> for each basis state of <code>qureg</code>.<br />
<br />
</li>
<li><p class="startli">Additionally, <code>overrideInds</code> is a list of length <code>numOverrides</code> which specifies the values of <img class="formulaInl" alt="$r$" src="form_248.png"/> for which to explicitly set the induced phase change.<br />
The overriding phase changes are specified in the corresponding elements of <code>overridePhases</code>.<br />
<br />
For example, </p><div class="fragment"><div class="line"><span class="keywordtype">int</span> qubits[] = {0,1};</div>
<div class="line"><span class="keyword">enum</span> <a class="code" href="group__type.html#ga9c91c41aa42ae537995e89ffc616afe1">bitEncoding</a> encoding = <a class="code" href="group__type.html#gga9c91c41aa42ae537995e89ffc616afe1a7165f9a47792f47c718ca128556fb3ae">UNSIGNED</a>;</div>
<div class="line"> </div>
<div class="line"><span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> overrideInds[] = {2};</div>
<div class="line"><a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> overridePhases[] = {<a class="code" href="QuEST__common_8c.html#ae71449b1cc6e6250b91f539153a7a0d3">M_PI</a>};</div>
<div class="line"> </div>
<div class="line"><a class="code" href="group__operator.html#gaf5344129240243ad11d0c081eb9036ab">applyPhaseFuncOverrides</a>(...);</div>
</div><!-- fragment --><p class="startli">would effect the same diagonal unitary of <a class="el" href="group__operator.html#ga467f517abd18dbc3d6fced84c6589161" title="Induces a phase change upon each amplitude of qureg, determined by the passed exponential polynomial ...">applyPhaseFunc()</a>, <em>except</em> that all instance of <img class="formulaInl" alt="$f(r=2)$" src="form_256.png"/> are overriden with phase <img class="formulaInl" alt="$\pi$" src="form_114.png"/>. <br />
I.e. </p><p class="formulaDsp">
<img class="formulaDsp" alt="\[ \begin{aligned} |0\mathbf{00}\rangle & \rightarrow \, e^{i f(0)}\,|0\mathbf{00}\rangle \\ |0\mathbf{01}\rangle & \rightarrow \, e^{i f(1)}\,|0\mathbf{01}\rangle \\ |0\mathbf{10}\rangle & \rightarrow \, e^{i \pi} \hspace{12pt} |0\mathbf{10}\rangle \\ |0\mathbf{11}\rangle & \rightarrow \, e^{i f(3)}\,|0\mathbf{11}\rangle \\ |1\mathbf{00}\rangle & \rightarrow \, e^{i f(0)}\,|1\mathbf{00}\rangle \\ |1\mathbf{01}\rangle & \rightarrow \, e^{i f(1)}\,|1\mathbf{01}\rangle \\ |1\mathbf{10}\rangle & \rightarrow \, e^{i \pi} \hspace{12pt} |1\mathbf{10}\rangle \\ |1\mathbf{11}\rangle & \rightarrow \, e^{i f(3)}\,|1\mathbf{11}\rangle \end{aligned} \]" src="form_257.png"/>
</p>
<p> Note that if <code>encoding</code> <b>=</b> <a class="el" href="group__type.html#gga9c91c41aa42ae537995e89ffc616afe1a9aa2a35d92976c7de970506c4d19a96c">TWOS_COMPLEMENT</a>, <em>and</em> <img class="formulaInl" alt="$f(r)$" src="form_245.png"/> features a fractional exponent, then every negative phase index must be overriden. This is checked and enforced by QuEST's validation, <em>unless</em> there are more than 16 targeted qubits, in which case valid input is assumed (due to an otherwise prohibitive performance overhead). <br />
</p><blockquote class="doxtable">
<p>Overriding phases are checked at each computational basis state of <code>qureg</code> <em>before</em> evaluating the phase function <img class="formulaInl" alt="$f(r)$" src="form_245.png"/>, and hence are useful for avoiding singularities or errors at diverging values of <img class="formulaInl" alt="$r$" src="form_248.png"/>. </p>
</blockquote>
</li>
<li>If <code>qureg</code> is a density matrix <img class="formulaInl" alt="$\rho$" src="form_40.png"/>, the overrides determine the diagonal unitary matrix <img class="formulaInl" alt="$\hat{D}$" src="form_42.png"/>, which is then applied to <code>qureg</code> as <p class="formulaDsp">
<img class="formulaDsp" alt="\[ \rho \; \rightarrow \; \hat{D} \, \rho \hat{D}^\dagger. \]" src="form_258.png"/>
</p>
This means that with overrides <img class="formulaInl" alt="$f(r_j) \rightarrow \theta$" src="form_259.png"/> and <img class="formulaInl" alt="$f(r_k) \rightarrow \phi$" src="form_260.png"/>, element <img class="formulaInl" alt="$\rho_{jk}$" src="form_254.png"/> is modified to <p class="formulaDsp">
<img class="formulaDsp" alt="\[ \alpha \, |j\rangle\langle k| \; \rightarrow \; \exp(\, i \, (\theta - \phi) \, ) \; \alpha \, |j\rangle\langle k|. \]" src="form_261.png"/>
</p>
<br />
</li>
<li><p class="startli">The interpreted phase function and list of overrides can be previewed in the QASM log, as a comment. <br />
For example: </p><div class="fragment"><div class="line"><a class="code" href="group__qasm.html#ga65bf1906298ca6355e2942f4923d77b6">startRecordingQASM</a>(qureg);</div>
<div class="line"><a class="code" href="group__operator.html#ga467f517abd18dbc3d6fced84c6589161">applyPhaseFunc</a>(qureg, ...);</div>
<div class="line"><a class="code" href="group__qasm.html#gacf139d0a54b1f9e5c2f2feff742b8c76">printRecordedQASM</a>(qureg);</div>
</div><!-- fragment --><p class="startli">may show </p><div class="fragment"><div class="line"><span class="comment">// Here, applyPhaseFunc() multiplied a complex scalar of the form</span></div>
<div class="line"><span class="comment">// exp(i (0.3 x^(-5) + 4 x^1 + 1 x^3))</span></div>
<div class="line"><span class="comment">// upon every substate |x>, informed by qubits (under a two's complement binary encoding)</span></div>
<div class="line"><span class="comment">// {4, 1, 2, 0}</span></div>
<div class="line"><span class="comment">// though with overrides</span></div>
<div class="line"><span class="comment">// |0> -> exp(i 3.14159)</span></div>
<div class="line"><span class="comment">// |1> -> exp(i (-3.14159))</span></div>
<div class="line"><span class="comment">// |2> -> exp(i 0)</span></div>
</div><!-- fragment --></li>
</ul>
<p><br />
</p>
<dl class="section see"><dt>See also</dt><dd><ul>
<li><a class="el" href="group__operator.html#ga467f517abd18dbc3d6fced84c6589161" title="Induces a phase change upon each amplitude of qureg, determined by the passed exponential polynomial ...">applyPhaseFunc()</a> for full doc on how <img class="formulaInl" alt="$f(r)$" src="form_245.png"/> is evaluated.</li>
<li><a class="el" href="group__operator.html#ga008a46d178a5a9691e2f5d363e3f518f" title="Induces a phase change upon each amplitude of qureg, determined by a multi-variable exponential polyn...">applyMultiVarPhaseFunc()</a> for multi-variable exponential polynomial phase functions.</li>
<li><a class="el" href="group__operator.html#gac4df97d8c125c8cc65df720f67b2bf69" title="Induces a phase change upon each amplitude of qureg, determined by a named (and potentially multi-var...">applyNamedPhaseFunc()</a> for a set of specific phase functions.</li>
<li><a class="el" href="group__operator.html#gad2e953390342cd361cfb4064d47715e6" title="Apply a diagonal operator, which is possibly non-unitary and non-Hermitian, to the entire qureg.">applyDiagonalOp()</a> to apply a non-unitary diagonal <a class="el" href="group__operator.html" title="Non-physical operators which may be non-unitary, non-norm-preserving, even non-Hermitian.">Operators</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 state-vector or density matrix to be modified </td></tr>
<tr><td class="paramdir">[in]</td><td class="paramname">qubits</td><td>a list of the indices of the qubits which will inform <img class="formulaInl" alt="$r$" src="form_248.png"/> for each amplitude in <code>qureg</code> </td></tr>
<tr><td class="paramdir">[in]</td><td class="paramname">numQubits</td><td>the length of list <code>qubits</code> </td></tr>
<tr><td class="paramdir">[in]</td><td class="paramname">encoding</td><td>the <a class="el" href="group__type.html#ga9c91c41aa42ae537995e89ffc616afe1" title="Flags for specifying how the bits in sub-register computational basis states are mapped to indices in...">bitEncoding</a> under which to infer the binary value <img class="formulaInl" alt="$r$" src="form_248.png"/> from the bits of <code>qubits</code> in each basis state of <code>qureg</code> </td></tr>
<tr><td class="paramdir">[in]</td><td class="paramname">coeffs</td><td>the coefficients of the exponential polynomial phase function <img class="formulaInl" alt="$f(r)$" src="form_245.png"/> </td></tr>
<tr><td class="paramdir">[in]</td><td class="paramname">exponents</td><td>the exponents of the exponential polynomial phase function <img class="formulaInl" alt="$f(r)$" src="form_245.png"/> </td></tr>
<tr><td class="paramdir">[in]</td><td class="paramname">numTerms</td><td>the length of list <code>coeffs</code>, which must be the same as that of <code>exponents</code> </td></tr>
<tr><td class="paramdir">[in]</td><td class="paramname">overrideInds</td><td>a list of sub-state indices (values of <img class="formulaInl" alt="$r$" src="form_248.png"/>) of which to explicit set the phase change </td></tr>
<tr><td class="paramdir">[in]</td><td class="paramname">overridePhases</td><td>a list of replacement phase changes, for the corresponding <img class="formulaInl" alt="$r$" src="form_248.png"/> values in <code>overrideInds</code> (one to one) </td></tr>
<tr><td class="paramdir">[in]</td><td class="paramname">numOverrides</td><td>the lengths of lists <code>overrideInds</code> and <code>overridePhases</code> </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>if any qubit in <code>qubits</code> has an invalid index (i.e. does not satisfy 0 <= qubit < <code>qureg.numQubitsRepresented</code>)</li>
<li>if the elements of <code>qubits</code> are not unique</li>
<li>if <code>numQubits</code> < 0 or <code>numQubits</code> >= <code>qureg.numQubitsRepresented</code></li>
<li>if <code>encoding</code> is not a valid <a class="el" href="group__type.html#ga9c91c41aa42ae537995e89ffc616afe1" title="Flags for specifying how the bits in sub-register computational basis states are mapped to indices in...">bitEncoding</a></li>
<li>if <code>encoding</code> is not compatible with <code>numQubits</code> (i.e. <code>TWOS_COMPLEMENT</code> with 1 qubit)</li>
<li>if <code>numTerms</code> <= 0</li>
<li>if any value in <code>overrideInds</code> is not producible by <code>qubits</code> under the given <code>encoding</code> (e.g. 2 unsigned qubits cannot represent index 9)</li>
<li>if <code>numOverrides</code> < 0</li>
<li>if <code>exponents</code> contains a negative power and the (consequently diverging) zero index is not contained in <code>overrideInds</code> </li>
<li>if <code>encoding</code> is <a class="el" href="group__type.html#gga9c91c41aa42ae537995e89ffc616afe1a9aa2a35d92976c7de970506c4d19a96c">TWOS_COMPLEMENT</a>, and <code>exponents</code> contains a fractional number, but <code>overrideInds</code> does not contain every possible negative index (checked only up to 16 targeted qubits) </li>
</ul>
</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#l00743">743</a> of file <a class="el" href="QuEST_8c_source.html">QuEST.c</a>.</p>
<div class="fragment"><div class="line"><a name="l00743"></a><span class="lineno"> 743</span>  {</div>
<div class="line"><a name="l00744"></a><span class="lineno"> 744</span>  <a class="code" href="QuEST__validation_8c.html#a9e7e85cfc36e3ce1f456a840a217bfd9">validateMultiQubits</a>(qureg, qubits, numQubits, __func__);</div>
<div class="line"><a name="l00745"></a><span class="lineno"> 745</span>  <a class="code" href="QuEST__validation_8c.html#aa8a0654753645b30d6fed4ed0f4e7d16">validateBitEncoding</a>(numQubits, encoding, __func__);</div>
<div class="line"><a name="l00746"></a><span class="lineno"> 746</span>  <a class="code" href="QuEST__validation_8c.html#a12511cc6d45e137de6542d4721f1fa4e">validatePhaseFuncOverrides</a>(numQubits, encoding, overrideInds, numOverrides, __func__);</div>
<div class="line"><a name="l00747"></a><span class="lineno"> 747</span>  <a class="code" href="QuEST__validation_8c.html#a91dad925cb9383384f135b936e5a7f43">validatePhaseFuncTerms</a>(numQubits, encoding, coeffs, exponents, numTerms, overrideInds, numOverrides, __func__);</div>
<div class="line"><a name="l00748"></a><span class="lineno"> 748</span>  </div>
<div class="line"><a name="l00749"></a><span class="lineno"> 749</span>  <span class="keywordtype">int</span> conj = 0;</div>
<div class="line"><a name="l00750"></a><span class="lineno"> 750</span>  <a class="code" href="QuEST__internal_8h.html#a9d7928473aca695a614e9c24d903e578">statevec_applyPhaseFuncOverrides</a>(qureg, qubits, numQubits, encoding, coeffs, exponents, numTerms, overrideInds, overridePhases, numOverrides, conj);</div>
<div class="line"><a name="l00751"></a><span class="lineno"> 751</span>  <span class="keywordflow">if</span> (qureg.<a class="code" href="structQureg.html#acf78445e9435d09f44f0cc832c6aee79">isDensityMatrix</a>) {</div>
<div class="line"><a name="l00752"></a><span class="lineno"> 752</span>  conj = 1;</div>
<div class="line"><a name="l00753"></a><span class="lineno"> 753</span>  <a class="code" href="QuEST__common_8c.html#acf1c651a4359a370a2d9b3e1e1ebd430">shiftIndices</a>(qubits, numQubits, qureg.<a class="code" href="structQureg.html#ad08dff5316b8937f4b2a1417591543dc">numQubitsRepresented</a>);</div>
<div class="line"><a name="l00754"></a><span class="lineno"> 754</span>  <a class="code" href="QuEST__internal_8h.html#a9d7928473aca695a614e9c24d903e578">statevec_applyPhaseFuncOverrides</a>(qureg, qubits, numQubits, encoding, coeffs, exponents, numTerms, overrideInds, overridePhases, numOverrides, conj);</div>
<div class="line"><a name="l00755"></a><span class="lineno"> 755</span>  <a class="code" href="QuEST__common_8c.html#acf1c651a4359a370a2d9b3e1e1ebd430">shiftIndices</a>(qubits, numQubits, - qureg.<a class="code" href="structQureg.html#ad08dff5316b8937f4b2a1417591543dc">numQubitsRepresented</a>);</div>
<div class="line"><a name="l00756"></a><span class="lineno"> 756</span>  }</div>
<div class="line"><a name="l00757"></a><span class="lineno"> 757</span>  </div>
<div class="line"><a name="l00758"></a><span class="lineno"> 758</span>  <a class="code" href="QuEST__qasm_8c.html#a383ddaecc94e1ce4a6fdbdbabeaa3131">qasm_recordPhaseFunc</a>(qureg, qubits, numQubits, encoding, coeffs, exponents, numTerms, overrideInds, overridePhases, numOverrides);</div>
<div class="line"><a name="l00759"></a><span class="lineno"> 759</span> }</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST_8h_source.html#l00325">Qureg::isDensityMatrix</a>, <a class="el" href="QuEST_8h_source.html#l00327">Qureg::numQubitsRepresented</a>, <a class="el" href="QuEST__qasm_8c_source.html#l00490">qasm_recordPhaseFunc()</a>, <a class="el" href="QuEST__common_8c_source.html#l00156">shiftIndices()</a>, <a class="el" href="QuEST__cpu_8c_source.html#l04268">statevec_applyPhaseFuncOverrides()</a>, <a class="el" href="QuEST__validation_8c_source.html#l00966">validateBitEncoding()</a>, <a class="el" href="QuEST__validation_8c_source.html#l00444">validateMultiQubits()</a>, <a class="el" href="QuEST__validation_8c_source.html#l00862">validatePhaseFuncOverrides()</a>, and <a class="el" href="QuEST__validation_8c_source.html#l00773">validatePhaseFuncTerms()</a>.</p>
<p class="reference">Referenced by <a class="el" href="test__operators_8cpp_source.html#l03001">TEST_CASE()</a>.</p>
</div>
</div>
<a id="ga26db8b8a8a242d388c291e50d228ab18"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga26db8b8a8a242d388c291e50d228ab18">◆ </a></span>applyProjector()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void applyProjector </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">int </td>
<td class="paramname"><em>qubit</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int </td>
<td class="paramname"><em>outcome</em> </td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Force the target <code>qubit</code> of <code>qureg</code> into the given classical <code>outcome</code>, via a non-renormalising projection. </p>
<p>This function zeroes all amplitudes in the state-vector or density-matrix which correspond to the opposite <code>outcome</code> given. Unlike <a class="el" href="group__normgate.html#ga34457f7f62ccd75fb7d3fe67cd2f815a" title="Updates qureg to be consistent with measuring measureQubit in the given outcome (0 or 1),...">collapseToOutcome()</a>, it does not thereafter normalise <code>qureg</code>, and hence may leave it in a non-physical state.</p>
<p>Note there is no requirement that the <code>outcome</code> state has a non-zero proability, and hence this function may leave <code>qureg</code> in a blank state, like that produced by <a class="el" href="group__init.html#gada7230491a50cd409f8b00f5ee1db953" title="Initialises a qureg to have all-zero-amplitudes.">initBlankState()</a>.</p>
<dl class="section see"><dt>See also</dt><dd><ul>
<li><a class="el" href="group__normgate.html#ga34457f7f62ccd75fb7d3fe67cd2f815a" title="Updates qureg to be consistent with measuring measureQubit in the given outcome (0 or 1),...">collapseToOutcome()</a> for a norm-preserving equivalent, like a forced measurement</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>a state-vector or density matrix to modify </td></tr>
<tr><td class="paramdir">[in]</td><td class="paramname">qubit</td><td>the qubit to which to apply the projector </td></tr>
<tr><td class="paramdir">[in]</td><td class="paramname">the</td><td>single-qubit outcome (<code>0</code> or <code>1</code>) to project <code>qubit</code> into </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>if <code>qubit</code> is outside [0, <code>qureg.numQubitsRepresented</code>)</li>
<li>if <code>outcome</code> is not in {0,1} </li>
</ul>
</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#l00888">888</a> of file <a class="el" href="QuEST_8c_source.html">QuEST.c</a>.</p>
<div class="fragment"><div class="line"><a name="l00888"></a><span class="lineno"> 888</span>  {</div>
<div class="line"><a name="l00889"></a><span class="lineno"> 889</span>  <a class="code" href="QuEST__validation_8c.html#ac31c45c5a31c523be0eb26abba6cf598">validateTarget</a>(qureg, qubit, __func__);</div>
<div class="line"><a name="l00890"></a><span class="lineno"> 890</span>  <a class="code" href="QuEST__validation_8c.html#ad613c75ff252a88e54f911053bd2032c">validateOutcome</a>(outcome, __func__);</div>
<div class="line"><a name="l00891"></a><span class="lineno"> 891</span>  </div>
<div class="line"><a name="l00892"></a><span class="lineno"> 892</span>  <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> renorm = 1;</div>
<div class="line"><a name="l00893"></a><span class="lineno"> 893</span>  </div>
<div class="line"><a name="l00894"></a><span class="lineno"> 894</span>  <span class="keywordflow">if</span> (qureg.<a class="code" href="structQureg.html#acf78445e9435d09f44f0cc832c6aee79">isDensityMatrix</a>)</div>
<div class="line"><a name="l00895"></a><span class="lineno"> 895</span>  <a class="code" href="QuEST__internal_8h.html#a5658f2ecbbd4ea425db5f7dc7fc4ba92">densmatr_collapseToKnownProbOutcome</a>(qureg, qubit, outcome, renorm);</div>
<div class="line"><a name="l00896"></a><span class="lineno"> 896</span>  <span class="keywordflow">else</span></div>
<div class="line"><a name="l00897"></a><span class="lineno"> 897</span>  <a class="code" href="QuEST__internal_8h.html#a008becc4a18f868340836e0ab9fd6df6">statevec_collapseToKnownProbOutcome</a>(qureg, qubit, outcome, renorm);</div>
<div class="line"><a name="l00898"></a><span class="lineno"> 898</span>  </div>
<div class="line"><a name="l00899"></a><span class="lineno"> 899</span>  <a class="code" href="QuEST__qasm_8c.html#a9a385fde708958617bbeb599064b8dcb">qasm_recordComment</a>(qureg, <span class="stringliteral">"Here, qubit %d was un-physically projected into outcome %d"</span>, qubit, outcome);</div>
<div class="line"><a name="l00900"></a><span class="lineno"> 900</span> }</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST__cpu_8c_source.html#l00791">densmatr_collapseToKnownProbOutcome()</a>, <a class="el" href="QuEST_8h_source.html#l00325">Qureg::isDensityMatrix</a>, <a class="el" href="QuEST__qasm_8c_source.html#l00121">qasm_recordComment()</a>, <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l01368">statevec_collapseToKnownProbOutcome()</a>, <a class="el" href="QuEST__validation_8c_source.html#l00523">validateOutcome()</a>, and <a class="el" href="QuEST__validation_8c_source.html#l00400">validateTarget()</a>.</p>
<p class="reference">Referenced by <a class="el" href="test__operators_8cpp_source.html#l03214">TEST_CASE()</a>.</p>
</div>
</div>
<a id="ga9bc8c4ab44f8233b5766208a0b1c0776"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga9bc8c4ab44f8233b5766208a0b1c0776">◆ </a></span>applyQFT()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void applyQFT </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">int * </td>
<td class="paramname"><em>qubits</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int </td>
<td class="paramname"><em>numQubits</em> </td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Applies the quantum Fourier transform (QFT) to a specific subset of qubits of the register <code>qureg</code>. </p>
<p>The order of <code>qubits</code> affects the ultimate unitary. The canonical full-state QFT (<a class="el" href="group__operator.html#gaf26f32c25db760065486188497c1da8b" title="Applies the quantum Fourier transform (QFT) to the entirety of qureg.">applyFullQFT()</a>) is achieved by targeting every qubit in increasing order.</p>
<p>The effected unitary circuit (shown here for <code>numQubits</code> <b>= 4</b>) resembles </p><p class="formulaDsp">
<img class="formulaDsp" alt="\[ \begin{tikzpicture}[scale=.5] \draw (-2, 5) -- (23, 5); \node[draw=none] at (-4,5) {qubits[3]}; \draw (-2, 3) -- (23, 3); \node[draw=none] at (-4,3) {qubits[2]}; \draw (-2, 1) -- (23, 1); \node[draw=none] at (-4,1) {qubits[1]}; \draw (-2, -1) -- (23, -1); \node[draw=none] at (-4,-1) {qubits[0]}; \draw[fill=white] (-1, 4) -- (-1, 6) -- (1, 6) -- (1,4) -- cycle; \node[draw=none] at (0, 5) {H}; \draw(2, 5) -- (2, 3); \draw[fill=black] (2, 5) circle (.2); \draw[fill=black] (2, 3) circle (.2); \draw(4, 5) -- (4, 1); \draw[fill=black] (4, 5) circle (.2); \draw[fill=black] (4, 1) circle (.2); \draw(6, 5) -- (6, -1); \draw[fill=black] (6, 5) circle (.2); \draw[fill=black] (6, -1) circle (.2); \draw[fill=white] (-1+8, 4-2) -- (-1+8, 6-2) -- (1+8, 6-2) -- (1+8,4-2) -- cycle; \node[draw=none] at (8, 5-2) {H}; \draw(10, 5-2) -- (10, 3-2); \draw[fill=black] (10, 5-2) circle (.2); \draw[fill=black] (10, 3-2) circle (.2); \draw(12, 5-2) -- (12, 3-4); \draw[fill=black] (12, 5-2) circle (.2); \draw[fill=black] (12, 3-4) circle (.2); \draw[fill=white] (-1+8+6, 4-4) -- (-1+8+6, 6-4) -- (1+8+6, 6-4) -- (1+8+6,4-4) -- cycle; \node[draw=none] at (8+6, 5-4) {H}; \draw(16, 5-2-2) -- (16, 3-4); \draw[fill=black] (16, 5-2-2) circle (.2); \draw[fill=black] (16, 3-4) circle (.2); \draw[fill=white] (-1+8+6+4, 4-4-2) -- (-1+8+6+4, 6-4-2) -- (1+8+6+4, 6-4-2) -- (1+8+6+4,4-4-2) -- cycle; \node[draw=none] at (8+6+4, 5-4-2) {H}; \draw (20, 5) -- (20, -1); \draw (20 - .35, 5 + .35) -- (20 + .35, 5 - .35); \draw (20 - .35, 5 - .35) -- (20 + .35, 5 + .35); \draw (20 - .35, -1 + .35) -- (20 + .35, -1 - .35); \draw (20 - .35, -1 - .35) -- (20 + .35, -1 + .35); \draw (22, 3) -- (22, 1); \draw (22 - .35, 3 + .35) -- (22 + .35, 3 - .35); \draw (22 - .35, 3 - .35) -- (22 + .35, 3 + .35); \draw (22 - .35, 1 + .35) -- (22 + .35, 1 - .35); \draw (22 - .35, 1 - .35) -- (22 + .35, 1 + .35); \end{tikzpicture} \]" src="form_298.png"/>
</p>
<p> though is performed more efficiently.</p>
<ul>
<li>If <code>qureg</code> is a state-vector, the output amplitudes are a kronecker product of the discrete Fourier transform (DFT) acting upon the targeted amplitudes, and the remaining. <br />
Precisely,<ul>
<li>let <img class="formulaInl" alt="$|x,r\rangle$" src="form_299.png"/> represent a computational basis state where <img class="formulaInl" alt="$x$" src="form_300.png"/> is the binary value of the targeted qubits, and <img class="formulaInl" alt="$r$" src="form_248.png"/> is the binary value of the remaining qubits.</li>
<li>let <img class="formulaInl" alt="$|x_j,r_j\rangle$" src="form_301.png"/> be the <img class="formulaInl" alt="$j\text{th}$" src="form_302.png"/> such state.</li>
<li>let <img class="formulaInl" alt="$n =$" src="form_303.png"/> <code>numQubits</code>, and <img class="formulaInl" alt="$N =$" src="form_304.png"/> <code>qureg.numQubitsRepresented</code>.<br />
Then, this function effects <p class="formulaDsp">
<img class="formulaDsp" alt="\[ (\text{QFT}\otimes 1) \, \left( \sum\limits_{j=0}^{2^N-1} \alpha_j \, |x_j,r_j\rangle \right) = \frac{1}{\sqrt{2^n}} \sum\limits_{j=0}^{2^N-1} \alpha_j \left( \sum\limits_{y=0}^{2^n-1} e^{2 \pi \, i \, x_j \, y / 2^n} \; |y,r_j \rangle \right) \]" src="form_305.png"/>
</p>
</li>
</ul>
</li>
<li>If <code>qureg</code> is a density matrix <img class="formulaInl" alt="$\rho$" src="form_40.png"/>, it will be changed under the unitary action of the QFT. This can be imagined as each mixed state-vector undergoing the DFT on its amplitudes. This is true even if <code>qureg</code> is unnormalised. <p class="formulaDsp">
<img class="formulaDsp" alt="\[ \rho \; \rightarrow \; \text{QFT} \; \rho \; \text{QFT}^{\dagger} \]" src="form_296.png"/>
</p>
</li>
</ul>
<blockquote class="doxtable">
<p>This function merges contiguous controlled-phase gates into single invocations of <a class="el" href="group__operator.html#gac4df97d8c125c8cc65df720f67b2bf69" title="Induces a phase change upon each amplitude of qureg, determined by a named (and potentially multi-var...">applyNamedPhaseFunc()</a>, and hence is significantly faster than performing the QFT circuit directly. </p>
</blockquote>
<blockquote class="doxtable">
<p>Furthermore, in distributed mode, this function requires only <img class="formulaInl" alt="$\log_2(\text{\#nodes})$" src="form_297.png"/> rounds of pair-wise communication, and hence is exponentially faster than directly performing the DFT on the amplitudes of <code>qureg</code>. </p>
</blockquote>
<dl class="section see"><dt>See also</dt><dd><ul>
<li><a class="el" href="group__operator.html#gaf26f32c25db760065486188497c1da8b" title="Applies the quantum Fourier transform (QFT) to the entirety of qureg.">applyFullQFT()</a> to apply the QFT to the entirety of <code>qureg</code>.</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>a state-vector or density matrix to modify </td></tr>
<tr><td class="paramdir">[in]</td><td class="paramname">qubits</td><td>a list of the qubits to operate the QFT upon </td></tr>
<tr><td class="paramdir">[in]</td><td class="paramname">numQubits</td><td>the length of list <code>qubits</code> </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>if any qubit in <code>qubits</code> is invalid, i.e. outside <b>[0, </b><code>qureg.numQubitsRepresented</code><b>)</b></li>
<li>if <code>qubits</code> contain any repetitions</li>
<li>if <code>numQubits</code> <b>< 1</b></li>
<li>if <code>numQubits</code> <b>></b><code>qureg.numQubitsRepresented</code> </li>
</ul>
</td></tr>
<tr><td class="paramname">segmentation-fault</td><td><ul>
<li>if <code>qubits</code> contains fewer elements than <code>numQubits</code> </li>
</ul>
</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#l00866">866</a> of file <a class="el" href="QuEST_8c_source.html">QuEST.c</a>.</p>
<div class="fragment"><div class="line"><a name="l00866"></a><span class="lineno"> 866</span>  {</div>
<div class="line"><a name="l00867"></a><span class="lineno"> 867</span>  <a class="code" href="QuEST__validation_8c.html#a6776217a5f7ba38b56175cf6db0f96e0">validateMultiTargets</a>(qureg, qubits, numQubits, __func__);</div>
<div class="line"><a name="l00868"></a><span class="lineno"> 868</span>  </div>
<div class="line"><a name="l00869"></a><span class="lineno"> 869</span>  <a class="code" href="QuEST__qasm_8c.html#a9a385fde708958617bbeb599064b8dcb">qasm_recordComment</a>(qureg, <span class="stringliteral">"Beginning of QFT circuit"</span>);</div>
<div class="line"><a name="l00870"></a><span class="lineno"> 870</span>  </div>
<div class="line"><a name="l00871"></a><span class="lineno"> 871</span>  <a class="code" href="QuEST__common_8c.html#a2b78ab7dd04eab615a0d7c796e73ae8c">agnostic_applyQFT</a>(qureg, qubits, numQubits);</div>
<div class="line"><a name="l00872"></a><span class="lineno"> 872</span>  </div>
<div class="line"><a name="l00873"></a><span class="lineno"> 873</span>  <a class="code" href="QuEST__qasm_8c.html#a9a385fde708958617bbeb599064b8dcb">qasm_recordComment</a>(qureg, <span class="stringliteral">"End of QFT circuit"</span>);</div>
<div class="line"><a name="l00874"></a><span class="lineno"> 874</span> }</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST__common_8c_source.html#l00849">agnostic_applyQFT()</a>, <a class="el" href="QuEST__qasm_8c_source.html#l00121">qasm_recordComment()</a>, and <a class="el" href="QuEST__validation_8c_source.html#l00428">validateMultiTargets()</a>.</p>
<p class="reference">Referenced by <a class="el" href="test__operators_8cpp_source.html#l03349">TEST_CASE()</a>.</p>
</div>
</div>
<a id="ga35b6321c578a8c69470132b5ee95f930"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga35b6321c578a8c69470132b5ee95f930">◆ </a></span>applyTrotterCircuit()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void applyTrotterCircuit </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="structPauliHamil.html">PauliHamil</a> </td>
<td class="paramname"><em>hamil</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype"><a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> </td>
<td class="paramname"><em>time</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int </td>
<td class="paramname"><em>order</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int </td>
<td class="paramname"><em>reps</em> </td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Applies a trotterisation of unitary evolution <img class="formulaInl" alt="$ \exp(-i \, \text{hamil} \, \text{time}) $" src="form_235.png"/> to <code>qureg</code>. </p>
<p>This is a sequence of unitary operators, effected by <a class="el" href="group__unitary.html#ga34aa4865c92f9aa5d898c91286c9eca5" title="Apply a multi-qubit multi-Pauli rotation, also known as a Pauli gadget, on a selected number of qubit...">multiRotatePauli()</a>, which together approximate the action of full unitary-time evolution under the given Hamiltonian.</p>
<p>Notate <img class="formulaInl" alt="$ \text{hamil} = \sum_j^N c_j \, \hat \sigma_j $" src="form_236.png"/> where <img class="formulaInl" alt="$c_j$" src="form_237.png"/> is a real coefficient in <code>hamil</code>, <img class="formulaInl" alt="$\hat \sigma_j$" src="form_238.png"/> is the corresponding product of Pauli operators, of which there are a total <img class="formulaInl" alt="$N$" src="form_30.png"/>. Then, <code>order=1</code> performs first-order Trotterisation, whereby </p><p class="formulaDsp">
<img class="formulaDsp" alt="\[ \exp(-i \, \text{hamil} \, \text{time}) \approx \prod\limits^{\text{reps}} \prod\limits_{j=1}^{N} \exp(-i \, c_j \, \text{time} \, \hat\sigma_j / \text{reps}) \]" src="form_239.png"/>
</p>
<p> <code>order=2</code> performs the lowest order "symmetrized" Suzuki decomposition, whereby </p><p class="formulaDsp">
<img class="formulaDsp" alt="\[ \exp(-i \, \text{hamil} \, \text{time}) \approx \prod\limits^{\text{reps}} \left[ \prod\limits_{j=1}^{N} \exp(-i \, c_j \, \text{time} \, \hat\sigma_j / (2 \, \text{reps})) \prod\limits_{j=N}^{1} \exp(-i \, c_j \, \text{time} \, \hat\sigma_j / (2 \, \text{reps})) \right] \]" src="form_240.png"/>
</p>
<p> Greater even values of <code>order</code> specify higher-order symmetrized decompositions <img class="formulaInl" alt="$ S[\text{time}, \text{order}, \text{reps}] $" src="form_241.png"/> which satisfy </p><p class="formulaDsp">
<img class="formulaDsp" alt="\[ S[\text{time}, \text{order}, 1] = \left( \prod\limits^2 S[p \, \text{time}, \text{order}-2, 1] \right) S[ (1-4p)\,\text{time}, \text{order}-2, 1] \left( \prod\limits^2 S[p \, \text{time}, \text{order}-2, 1] \right) \]" src="form_242.png"/>
</p>
<p> and </p><p class="formulaDsp">
<img class="formulaDsp" alt="\[ S[\text{time}, \text{order}, \text{reps}] = \prod\limits^{\text{reps}} S[\text{time}/\text{reps}, \text{order}, 1] \]" src="form_243.png"/>
</p>
<p> where <img class="formulaInl" alt="$ p = \left( 4 - 4^{1/(\text{order}-1)} \right)^{-1} $" src="form_244.png"/>.</p>
<p>These formulations are taken from 'Finding Exponential Product Formulas of Higher Orders', Naomichi Hatano and Masuo Suzuki (2005) (<a href="https://arxiv.org/abs/math-ph/0506007">arXiv</a>).</p>
<p>Note that the applied Trotter circuit is captured by QASM, if QASM logging is enabled on <code>qureg</code>. <br />
For example: </p><div class="fragment"><div class="line"><a class="code" href="group__qasm.html#ga65bf1906298ca6355e2942f4923d77b6">startRecordingQASM</a>(qureg);</div>
<div class="line"><a class="code" href="group__operator.html#ga35b6321c578a8c69470132b5ee95f930">applyTrotterCircuit</a>(qureg, hamil, 1, 2, 1);</div>
<div class="line"><a class="code" href="group__qasm.html#gacf139d0a54b1f9e5c2f2feff742b8c76">printRecordedQASM</a>(qureg);</div>
</div><!-- fragment --><p>may show </p><div class="fragment"><div class="line"><span class="comment">// Beginning of Trotter circuit (time 1, order 2, 1 repetitions).</span></div>
<div class="line"><span class="comment">// Here, a multiRotatePauli with angle 0.5 and paulis X Y I was applied.</span></div>
<div class="line"><span class="comment">// Here, a multiRotatePauli with angle -0.5 and paulis I Z X was applied.</span></div>
<div class="line"><span class="comment">// Here, a multiRotatePauli with angle -0.5 and paulis I Z X was applied.</span></div>
<div class="line"><span class="comment">// Here, a multiRotatePauli with angle 0.5 and paulis X Y I was applied.</span></div>
<div class="line"><span class="comment">// End of Trotter circuit</span></div>
</div><!-- fragment --><p><br />
</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>
</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 register to modify under the approximate unitary-time evolution </td></tr>
<tr><td class="paramdir">[in]</td><td class="paramname">hamil</td><td>the hamiltonian under which to approxiamte unitary-time evolution </td></tr>
<tr><td class="paramdir">[in]</td><td class="paramname">time</td><td>the target evolution time, which is permitted to be both positive and negative. </td></tr>
<tr><td class="paramdir">[in]</td><td class="paramname">order</td><td>the order of Trotter-Suzuki decomposition to use. Higher orders (necessarily even) are more accurate but prescribe an exponentially increasing number of gates. </td></tr>
<tr><td class="paramdir">[in]</td><td class="paramname">reps</td><td>the number of repetitions of the decomposition of the given order. This improves the accuracy but prescribes a linearly increasing number of gates. </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>if <code>qureg.numQubitsRepresented</code> != <code>hamil.numQubits</code> </li>
<li>if <code>hamil</code> contains invalid parameters or Pauli codes,</li>
<li>if <code>order</code> is not in {1, 2, 4, 6, ...}</li>
<li>or if <code>reps</code> <= 0 </li>
</ul>
</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#l01070">1070</a> of file <a class="el" href="QuEST_8c_source.html">QuEST.c</a>.</p>
<div class="fragment"><div class="line"><a name="l01070"></a><span class="lineno"> 1070</span>  {</div>
<div class="line"><a name="l01071"></a><span class="lineno"> 1071</span>  <a class="code" href="QuEST__validation_8c.html#a82b142fe77ba20c87142274f32e57689">validateTrotterParams</a>(order, reps, __func__);</div>
<div class="line"><a name="l01072"></a><span class="lineno"> 1072</span>  <a class="code" href="QuEST__validation_8c.html#a066b0c4d0b02a0f3b9be7e5c68d9de6a">validatePauliHamil</a>(hamil, __func__);</div>
<div class="line"><a name="l01073"></a><span class="lineno"> 1073</span>  <a class="code" href="QuEST__validation_8c.html#a2b88b068a8242ee28da42c7324cdd078">validateMatchingQuregPauliHamilDims</a>(qureg, hamil, __func__);</div>
<div class="line"><a name="l01074"></a><span class="lineno"> 1074</span>  </div>
<div class="line"><a name="l01075"></a><span class="lineno"> 1075</span>  <a class="code" href="QuEST__qasm_8c.html#a9a385fde708958617bbeb599064b8dcb">qasm_recordComment</a>(qureg, </div>
<div class="line"><a name="l01076"></a><span class="lineno"> 1076</span>  <span class="stringliteral">"Beginning of Trotter circuit (time %g, order %d, %d repetitions)."</span>,</div>
<div class="line"><a name="l01077"></a><span class="lineno"> 1077</span>  time, order, reps);</div>
<div class="line"><a name="l01078"></a><span class="lineno"> 1078</span>  </div>
<div class="line"><a name="l01079"></a><span class="lineno"> 1079</span>  <a class="code" href="QuEST__common_8c.html#a8a8e789585651f90fcc587042d4cdfb8">agnostic_applyTrotterCircuit</a>(qureg, hamil, time, order, reps);</div>
<div class="line"><a name="l01080"></a><span class="lineno"> 1080</span>  </div>
<div class="line"><a name="l01081"></a><span class="lineno"> 1081</span>  <a class="code" href="QuEST__qasm_8c.html#a9a385fde708958617bbeb599064b8dcb">qasm_recordComment</a>(qureg, <span class="stringliteral">"End of Trotter circuit"</span>);</div>
<div class="line"><a name="l01082"></a><span class="lineno"> 1082</span> }</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST__common_8c_source.html#l00840">agnostic_applyTrotterCircuit()</a>, <a class="el" href="QuEST__qasm_8c_source.html#l00121">qasm_recordComment()</a>, <a class="el" href="QuEST__validation_8c_source.html#l00660">validateMatchingQuregPauliHamilDims()</a>, <a class="el" href="QuEST__validation_8c_source.html#l00655">validatePauliHamil()</a>, and <a class="el" href="QuEST__validation_8c_source.html#l00703">validateTrotterParams()</a>.</p>
<p class="reference">Referenced by <a class="el" href="test__operators_8cpp_source.html#l03500">TEST_CASE()</a>.</p>
</div>
</div>
</div><!-- contents -->
<div class="ttc" id="agroup__operator_html_ga467f517abd18dbc3d6fced84c6589161"><div class="ttname"><a href="group__operator.html#ga467f517abd18dbc3d6fced84c6589161">applyPhaseFunc</a></div><div class="ttdeci">void applyPhaseFunc(Qureg qureg, int *qubits, int numQubits, enum bitEncoding encoding, qreal *coeffs, qreal *exponents, int numTerms)</div><div class="ttdoc">Induces a phase change upon each amplitude of qureg, determined by the passed exponential polynomial ...</div><div class="ttdef"><b>Definition:</b> <a href="QuEST_8c_source.html#l00726">QuEST.c:726</a></div></div>
<div class="ttc" id="aQuEST__validation_8c_html_ac31c45c5a31c523be0eb26abba6cf598"><div class="ttname"><a href="QuEST__validation_8c.html#ac31c45c5a31c523be0eb26abba6cf598">validateTarget</a></div><div class="ttdeci">void validateTarget(Qureg qureg, int targetQubit, const char *caller)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__validation_8c_source.html#l00400">QuEST_validation.c:400</a></div></div>
<div class="ttc" id="agroup__operator_html_ga2fbaec3bb21cc01f7a2a4ed2aa911ebf"><div class="ttname"><a href="group__operator.html#ga2fbaec3bb21cc01f7a2a4ed2aa911ebf">applyNamedPhaseFuncOverrides</a></div><div class="ttdeci">void applyNamedPhaseFuncOverrides(Qureg qureg, int *qubits, int *numQubitsPerReg, int numRegs, enum bitEncoding encoding, enum phaseFunc functionNameCode, long long int *overrideInds, qreal *overridePhases, int numOverrides)</div><div class="ttdoc">Induces a phase change upon each amplitude of qureg, determined by a named (and potentially multi-var...</div><div class="ttdef"><b>Definition:</b> <a href="QuEST_8c_source.html#l00813">QuEST.c:813</a></div></div>
<div class="ttc" id="aQuEST__common_8c_html_a2b78ab7dd04eab615a0d7c796e73ae8c"><div class="ttname"><a href="QuEST__common_8c.html#a2b78ab7dd04eab615a0d7c796e73ae8c">agnostic_applyQFT</a></div><div class="ttdeci">void agnostic_applyQFT(Qureg qureg, int *qubits, int numQubits)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__common_8c_source.html#l00849">QuEST_common.c:849</a></div></div>
<div class="ttc" id="aQuEST__validation_8c_html_aa8a0654753645b30d6fed4ed0f4e7d16"><div class="ttname"><a href="QuEST__validation_8c.html#aa8a0654753645b30d6fed4ed0f4e7d16">validateBitEncoding</a></div><div class="ttdeci">void validateBitEncoding(int numQubits, enum bitEncoding encoding, const char *caller)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__validation_8c_source.html#l00966">QuEST_validation.c:966</a></div></div>
<div class="ttc" id="aQuEST__validation_8c_html_ad613c75ff252a88e54f911053bd2032c"><div class="ttname"><a href="QuEST__validation_8c.html#ad613c75ff252a88e54f911053bd2032c">validateOutcome</a></div><div class="ttdeci">void validateOutcome(int outcome, const char *caller)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__validation_8c_source.html#l00523">QuEST_validation.c:523</a></div></div>
<div class="ttc" id="aQuEST__validation_8c_html_a9b348fc98867d01990da93a8de36936c"><div class="ttname"><a href="QuEST__validation_8c.html#a9b348fc98867d01990da93a8de36936c">validateMultiRegBitEncoding</a></div><div class="ttdeci">void validateMultiRegBitEncoding(int *numQubitsPerReg, int numRegs, enum bitEncoding encoding, const char *caller)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__validation_8c_source.html#l00976">QuEST_validation.c:976</a></div></div>
<div class="ttc" id="aQuEST__validation_8c_html_a0edb4d9df94a40b8ea89c1c14997ee76"><div class="ttname"><a href="QuEST__validation_8c.html#a0edb4d9df94a40b8ea89c1c14997ee76">validateMultiVarPhaseFuncOverrides</a></div><div class="ttdeci">void validateMultiVarPhaseFuncOverrides(int *numQubitsPerReg, const int numRegs, enum bitEncoding encoding, long long int *overrideInds, int numOverrides, const char *caller)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__validation_8c_source.html#l00886">QuEST_validation.c:886</a></div></div>
<div class="ttc" id="agroup__type_html_gga1c703cf89629e4e9c7023cd402d67028a085c85cff6ba79c52d8b1e61c42ddddf"><div class="ttname"><a href="group__type.html#gga1c703cf89629e4e9c7023cd402d67028a085c85cff6ba79c52d8b1e61c42ddddf">PAULI_Z</a></div><div class="ttdeci">@ PAULI_Z</div><div class="ttdef"><b>Definition:</b> <a href="QuEST_8h_source.html#l00096">QuEST.h:96</a></div></div>
<div class="ttc" id="aQuEST__common_8c_html_acf1c651a4359a370a2d9b3e1e1ebd430"><div class="ttname"><a href="QuEST__common_8c.html#acf1c651a4359a370a2d9b3e1e1ebd430">shiftIndices</a></div><div class="ttdeci">void shiftIndices(int *indices, int numIndices, int shift)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__common_8c_source.html#l00156">QuEST_common.c:156</a></div></div>
<div class="ttc" id="agroup__operator_html_gac4df97d8c125c8cc65df720f67b2bf69"><div class="ttname"><a href="group__operator.html#gac4df97d8c125c8cc65df720f67b2bf69">applyNamedPhaseFunc</a></div><div class="ttdeci">void applyNamedPhaseFunc(Qureg qureg, int *qubits, int *numQubitsPerReg, int numRegs, enum bitEncoding encoding, enum phaseFunc functionNameCode)</div><div class="ttdoc">Induces a phase change upon each amplitude of qureg, determined by a named (and potentially multi-var...</div><div class="ttdef"><b>Definition:</b> <a href="QuEST_8c_source.html#l00796">QuEST.c:796</a></div></div>
<div class="ttc" id="agroup__type_html_gga1c703cf89629e4e9c7023cd402d67028a63800f45b01ccc2608f754aee850bf4a"><div class="ttname"><a href="group__type.html#gga1c703cf89629e4e9c7023cd402d67028a63800f45b01ccc2608f754aee850bf4a">PAULI_I</a></div><div class="ttdeci">@ PAULI_I</div><div class="ttdef"><b>Definition:</b> <a href="QuEST_8h_source.html#l00096">QuEST.h:96</a></div></div>
<div class="ttc" id="aQuEST__validation_8c_html_aa28b7d9c0c3cf9c4be0e324fb9d6bf76"><div class="ttname"><a href="QuEST__validation_8c.html#aa28b7d9c0c3cf9c4be0e324fb9d6bf76">validateMultiQubitMatrixFitsInNode</a></div><div class="ttdeci">void validateMultiQubitMatrixFitsInNode(Qureg qureg, int numTargets, const char *caller)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__validation_8c_source.html#l00473">QuEST_validation.c:473</a></div></div>
<div class="ttc" id="aQuEST__common_8c_html_a95abbe0cedf45b1ff2f070dba219fd7f"><div class="ttname"><a href="QuEST__common_8c.html#a95abbe0cedf45b1ff2f070dba219fd7f">statevec_twoQubitUnitary</a></div><div class="ttdeci">void statevec_twoQubitUnitary(Qureg qureg, int targetQubit1, int targetQubit2, ComplexMatrix4 u)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__common_8c_source.html#l00561">QuEST_common.c:561</a></div></div>
<div class="ttc" id="aQuEST__internal_8h_html_ac3735bd959600e57b2ee3a105666cddf"><div class="ttname"><a href="QuEST__internal_8h.html#ac3735bd959600e57b2ee3a105666cddf">statevec_unitary</a></div><div class="ttdeci">void statevec_unitary(Qureg qureg, int targetQubit, ComplexMatrix2 u)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__cpu__distributed_8c_source.html#l00895">QuEST_cpu_distributed.c:895</a></div></div>
<div class="ttc" id="aQuEST__internal_8h_html_a0acfe30083d0bc2a84da196378a36122"><div class="ttname"><a href="QuEST__internal_8h.html#a0acfe30083d0bc2a84da196378a36122">statevec_multiControlledMultiQubitUnitary</a></div><div class="ttdeci">void statevec_multiControlledMultiQubitUnitary(Qureg qureg, long long int ctrlMask, int *targs, int numTargs, ComplexMatrixN u)</div><div class="ttdoc">This calls swapQubitAmps only when it would involve a distributed communication; if the qubit chunks ...</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__cpu__distributed_8c_source.html#l01514">QuEST_cpu_distributed.c:1514</a></div></div>
<div class="ttc" id="agroup__type_html_ggaa7d869b117ba5024d6b84938e8cdfc65ae003ec1158e3a4e295616ced12af154e"><div class="ttname"><a href="group__type.html#ggaa7d869b117ba5024d6b84938e8cdfc65ae003ec1158e3a4e295616ced12af154e">NORM</a></div><div class="ttdeci">@ NORM</div><div class="ttdef"><b>Definition:</b> <a href="QuEST_8h_source.html#l00232">QuEST.h:232</a></div></div>
<div class="ttc" id="aQuEST__validation_8c_html_a14317136bb150eb0d4bdada1d0aac058"><div class="ttname"><a href="QuEST__validation_8c.html#a14317136bb150eb0d4bdada1d0aac058">validateMultiVarPhaseFuncTerms</a></div><div class="ttdeci">void validateMultiVarPhaseFuncTerms(int *numQubitsPerReg, int numRegs, enum bitEncoding encoding, qreal *exponents, int *numTermsPerReg, const char *caller)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__validation_8c_source.html#l00836">QuEST_validation.c:836</a></div></div>
<div class="ttc" id="aQuEST__validation_8c_html_a12511cc6d45e137de6542d4721f1fa4e"><div class="ttname"><a href="QuEST__validation_8c.html#a12511cc6d45e137de6542d4721f1fa4e">validatePhaseFuncOverrides</a></div><div class="ttdeci">void validatePhaseFuncOverrides(const int numQubits, enum bitEncoding encoding, long long int *overrideInds, int numOverrides, const char *caller)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__validation_8c_source.html#l00862">QuEST_validation.c:862</a></div></div>
<div class="ttc" id="agroup__type_html_gga9c91c41aa42ae537995e89ffc616afe1a7165f9a47792f47c718ca128556fb3ae"><div class="ttname"><a href="group__type.html#gga9c91c41aa42ae537995e89ffc616afe1a7165f9a47792f47c718ca128556fb3ae">UNSIGNED</a></div><div class="ttdeci">@ UNSIGNED</div><div class="ttdef"><b>Definition:</b> <a href="QuEST_8h_source.html#l00269">QuEST.h:269</a></div></div>
<div class="ttc" id="agroup__operator_html_gaf5344129240243ad11d0c081eb9036ab"><div class="ttname"><a href="group__operator.html#gaf5344129240243ad11d0c081eb9036ab">applyPhaseFuncOverrides</a></div><div class="ttdeci">void applyPhaseFuncOverrides(Qureg qureg, int *qubits, int numQubits, enum bitEncoding encoding, qreal *coeffs, qreal *exponents, int numTerms, long long int *overrideInds, qreal *overridePhases, int numOverrides)</div><div class="ttdoc">Induces a phase change upon each amplitude of qureg, determined by the passed exponential polynomial ...</div><div class="ttdef"><b>Definition:</b> <a href="QuEST_8c_source.html#l00743">QuEST.c:743</a></div></div>
<div class="ttc" id="agroup__type_html_ggaa7d869b117ba5024d6b84938e8cdfc65a6313e6ff48163c11c47866c4fda4bfa0"><div class="ttname"><a href="group__type.html#ggaa7d869b117ba5024d6b84938e8cdfc65a6313e6ff48163c11c47866c4fda4bfa0">INVERSE_DISTANCE</a></div><div class="ttdeci">@ INVERSE_DISTANCE</div><div class="ttdef"><b>Definition:</b> <a href="QuEST_8h_source.html#l00234">QuEST.h:234</a></div></div>
<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#l00606">QuEST_validation.c:606</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="agroup__type_html_gga1c703cf89629e4e9c7023cd402d67028a7abac7bb5b71e17382014c443244ad5c"><div class="ttname"><a href="group__type.html#gga1c703cf89629e4e9c7023cd402d67028a7abac7bb5b71e17382014c443244ad5c">PAULI_X</a></div><div class="ttdeci">@ PAULI_X</div><div class="ttdef"><b>Definition:</b> <a href="QuEST_8h_source.html#l00096">QuEST.h:96</a></div></div>
<div class="ttc" id="aQuEST__validation_8c_html_a9e7e85cfc36e3ce1f456a840a217bfd9"><div class="ttname"><a href="QuEST__validation_8c.html#a9e7e85cfc36e3ce1f456a840a217bfd9">validateMultiQubits</a></div><div class="ttdeci">void validateMultiQubits(Qureg qureg, int *qubits, int numQubits, const char *caller)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__validation_8c_source.html#l00444">QuEST_validation.c:444</a></div></div>
<div class="ttc" id="aQuEST__internal_8h_html_a5658f2ecbbd4ea425db5f7dc7fc4ba92"><div class="ttname"><a href="QuEST__internal_8h.html#a5658f2ecbbd4ea425db5f7dc7fc4ba92">densmatr_collapseToKnownProbOutcome</a></div><div class="ttdeci">void densmatr_collapseToKnownProbOutcome(Qureg qureg, int measureQubit, int outcome, qreal outcomeProb)</div><div class="ttdoc">Renorms (/prob) every | * outcome * >< * outcome * | state, setting all others to zero.</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__cpu_8c_source.html#l00791">QuEST_cpu.c:791</a></div></div>
<div class="ttc" id="aQuEST__validation_8c_html_a8a656a83bf0b44447188d06c2f8114cb"><div class="ttname"><a href="QuEST__validation_8c.html#a8a656a83bf0b44447188d06c2f8114cb">validateDiagonalOp</a></div><div class="ttdeci">void validateDiagonalOp(Qureg qureg, DiagonalOp op, const char *caller)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__validation_8c_source.html#l00713">QuEST_validation.c:713</a></div></div>
<div class="ttc" id="aQuEST__internal_8h_html_a7d8a817207847d2646a52044a63fd469"><div class="ttname"><a href="QuEST__internal_8h.html#a7d8a817207847d2646a52044a63fd469">statevec_applyParamNamedPhaseFuncOverrides</a></div><div class="ttdeci">void statevec_applyParamNamedPhaseFuncOverrides(Qureg qureg, int *qubits, int *numQubitsPerReg, int numRegs, enum bitEncoding encoding, enum phaseFunc functionNameCode, qreal *params, int numParams, long long int *overrideInds, qreal *overridePhases, int numOverrides, int conj)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__cpu_8c_source.html#l04446">QuEST_cpu.c:4446</a></div></div>
<div class="ttc" id="agroup__type_html_gaa7d869b117ba5024d6b84938e8cdfc65"><div class="ttname"><a href="group__type.html#gaa7d869b117ba5024d6b84938e8cdfc65">phaseFunc</a></div><div class="ttdeci">phaseFunc</div><div class="ttdoc">Flags for specifying named phase functions.</div><div class="ttdef"><b>Definition:</b> <a href="QuEST_8h_source.html#l00231">QuEST.h:231</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="agroup__operator_html_ga74a955ec4bce606d89317bcfc528387f"><div class="ttname"><a href="group__operator.html#ga74a955ec4bce606d89317bcfc528387f">applyMatrix4</a></div><div class="ttdeci">void applyMatrix4(Qureg qureg, int targetQubit1, int targetQubit2, ComplexMatrix4 u)</div><div class="ttdoc">Apply a general 4-by-4 matrix, which may be non-unitary.</div><div class="ttdef"><b>Definition:</b> <a href="QuEST_8c_source.html#l01093">QuEST.c:1093</a></div></div>
<div class="ttc" id="aQuEST__common_8c_html_a8a8e789585651f90fcc587042d4cdfb8"><div class="ttname"><a href="QuEST__common_8c.html#a8a8e789585651f90fcc587042d4cdfb8">agnostic_applyTrotterCircuit</a></div><div class="ttdeci">void agnostic_applyTrotterCircuit(Qureg qureg, PauliHamil hamil, qreal time, int order, int reps)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__common_8c_source.html#l00840">QuEST_common.c:840</a></div></div>
<div class="ttc" id="aQuEST__internal_8h_html_a9d7928473aca695a614e9c24d903e578"><div class="ttname"><a href="QuEST__internal_8h.html#a9d7928473aca695a614e9c24d903e578">statevec_applyPhaseFuncOverrides</a></div><div class="ttdeci">void statevec_applyPhaseFuncOverrides(Qureg qureg, int *qubits, int numQubits, enum bitEncoding encoding, qreal *coeffs, qreal *exponents, int numTerms, long long int *overrideInds, qreal *overridePhases, int numOverrides, int conj)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__cpu_8c_source.html#l04268">QuEST_cpu.c:4268</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_a27294e3065ebe42a65b3b9e0f85551dd"><div class="ttname"><a href="QuEST__internal_8h.html#a27294e3065ebe42a65b3b9e0f85551dd">statevec_applyDiagonalOp</a></div><div class="ttdeci">void statevec_applyDiagonalOp(Qureg qureg, DiagonalOp op)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__cpu_8c_source.html#l04047">QuEST_cpu.c:4047</a></div></div>
<div class="ttc" id="agroup__type_html_ggaa7d869b117ba5024d6b84938e8cdfc65a31a29a30f92fe34c35098f941adbbc93"><div class="ttname"><a href="group__type.html#ggaa7d869b117ba5024d6b84938e8cdfc65a31a29a30f92fe34c35098f941adbbc93">SCALED_PRODUCT</a></div><div class="ttdeci">@ SCALED_PRODUCT</div><div class="ttdef"><b>Definition:</b> <a href="QuEST_8h_source.html#l00233">QuEST.h:233</a></div></div>
<div class="ttc" id="aQuEST__validation_8c_html_a6776217a5f7ba38b56175cf6db0f96e0"><div class="ttname"><a href="QuEST__validation_8c.html#a6776217a5f7ba38b56175cf6db0f96e0">validateMultiTargets</a></div><div class="ttdeci">void validateMultiTargets(Qureg qureg, int *targetQubits, int numTargetQubits, const char *caller)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__validation_8c_source.html#l00428">QuEST_validation.c:428</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#l00531">QuEST_validation.c:531</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="aQuEST__common_8c_html_acc45bb8300922ea5933e294921e25ea2"><div class="ttname"><a href="QuEST__common_8c.html#acc45bb8300922ea5933e294921e25ea2">getQubitBitMask</a></div><div class="ttdeci">long long int getQubitBitMask(int *qubits, int numQubits)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__common_8c_source.html#l00050">QuEST_common.c:50</a></div></div>
<div class="ttc" id="agroup__type_html_gga1c703cf89629e4e9c7023cd402d67028a2c64a9aaee27f6bcfef894d159e759bd"><div class="ttname"><a href="group__type.html#gga1c703cf89629e4e9c7023cd402d67028a2c64a9aaee27f6bcfef894d159e759bd">PAULI_Y</a></div><div class="ttdeci">@ PAULI_Y</div><div class="ttdef"><b>Definition:</b> <a href="QuEST_8h_source.html#l00096">QuEST.h:96</a></div></div>
<div class="ttc" id="agroup__operator_html_gaabd7efa3beebc9f3a525321d41a28989"><div class="ttname"><a href="group__operator.html#gaabd7efa3beebc9f3a525321d41a28989">applyParamNamedPhaseFuncOverrides</a></div><div class="ttdeci">void applyParamNamedPhaseFuncOverrides(Qureg qureg, int *qubits, int *numQubitsPerReg, int numRegs, enum bitEncoding encoding, enum phaseFunc functionNameCode, qreal *params, int numParams, long long int *overrideInds, qreal *overridePhases, int numOverrides)</div><div class="ttdoc">Induces a phase change upon each amplitude of qureg, determined by a named, parameterised (and potent...</div><div class="ttdef"><b>Definition:</b> <a href="QuEST_8c_source.html#l00848">QuEST.c:848</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#l00121">QuEST_qasm.c:121</a></div></div>
<div class="ttc" id="agroup__type_html_ggaa7d869b117ba5024d6b84938e8cdfc65aa318172feec5b530e9a7849f2f7b44e7"><div class="ttname"><a href="group__type.html#ggaa7d869b117ba5024d6b84938e8cdfc65aa318172feec5b530e9a7849f2f7b44e7">SCALED_INVERSE_SHIFTED_NORM</a></div><div class="ttdeci">@ SCALED_INVERSE_SHIFTED_NORM</div><div class="ttdef"><b>Definition:</b> <a href="QuEST_8h_source.html#l00232">QuEST.h:232</a></div></div>
<div class="ttc" id="aQuEST__common_8c_html_a7a76950824f17e821415070a4bfdad5b"><div class="ttname"><a href="QuEST__common_8c.html#a7a76950824f17e821415070a4bfdad5b">statevec_multiQubitUnitary</a></div><div class="ttdeci">void statevec_multiQubitUnitary(Qureg qureg, int *targets, int numTargets, ComplexMatrixN u)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__common_8c_source.html#l00573">QuEST_common.c:573</a></div></div>
<div class="ttc" id="aQuEST__validation_8c_html_a0a45c9c3015af276ff7e624ae207ba7a"><div class="ttname"><a href="QuEST__validation_8c.html#a0a45c9c3015af276ff7e624ae207ba7a">validateQubitSubregs</a></div><div class="ttdeci">void validateQubitSubregs(Qureg qureg, int *qubits, int *numQubitsPerReg, const int numRegs, const char *caller)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__validation_8c_source.html#l00757">QuEST_validation.c:757</a></div></div>
<div class="ttc" id="agroup__qasm_html_ga65bf1906298ca6355e2942f4923d77b6"><div class="ttname"><a href="group__qasm.html#ga65bf1906298ca6355e2942f4923d77b6">startRecordingQASM</a></div><div class="ttdeci">void startRecordingQASM(Qureg qureg)</div><div class="ttdoc">Enable QASM recording.</div><div class="ttdef"><b>Definition:</b> <a href="QuEST_8c_source.html#l00087">QuEST.c:87</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#l00538">QuEST_common.c:538</a></div></div>
<div class="ttc" id="agroup__operator_html_ga6fc26cf857db070e12959e59ecfed8a6"><div class="ttname"><a href="group__operator.html#ga6fc26cf857db070e12959e59ecfed8a6">applyPauliSum</a></div><div class="ttdeci">void applyPauliSum(Qureg inQureg, enum pauliOpType *allPauliCodes, qreal *termCoeffs, int numSumTerms, Qureg outQureg)</div><div class="ttdoc">Modifies outQureg to be the result of applying the weighted sum of Pauli products (a Hermitian but no...</div><div class="ttdef"><b>Definition:</b> <a href="QuEST_8c_source.html#l01048">QuEST.c:1048</a></div></div>
<div class="ttc" id="agroup__operator_html_ga358e7094a98851afa86d27f0147e32a1"><div class="ttname"><a href="group__operator.html#ga358e7094a98851afa86d27f0147e32a1">applyMatrixN</a></div><div class="ttdeci">void applyMatrixN(Qureg qureg, int *targs, int numTargs, ComplexMatrixN u)</div><div class="ttdoc">Apply a general N-by-N matrix, which may be non-unitary, on any number of target qubits.</div><div class="ttdef"><b>Definition:</b> <a href="QuEST_8c_source.html#l01103">QuEST.c:1103</a></div></div>
<div class="ttc" id="agroup__operator_html_ga008a46d178a5a9691e2f5d363e3f518f"><div class="ttname"><a href="group__operator.html#ga008a46d178a5a9691e2f5d363e3f518f">applyMultiVarPhaseFunc</a></div><div class="ttdeci">void applyMultiVarPhaseFunc(Qureg qureg, int *qubits, int *numQubitsPerReg, int numRegs, enum bitEncoding encoding, qreal *coeffs, qreal *exponents, int *numTermsPerReg)</div><div class="ttdoc">Induces a phase change upon each amplitude of qureg, determined by a multi-variable exponential polyn...</div><div class="ttdef"><b>Definition:</b> <a href="QuEST_8c_source.html#l00761">QuEST.c:761</a></div></div>
<div class="ttc" id="aQuEST__internal_8h_html_a008becc4a18f868340836e0ab9fd6df6"><div class="ttname"><a href="QuEST__internal_8h.html#a008becc4a18f868340836e0ab9fd6df6">statevec_collapseToKnownProbOutcome</a></div><div class="ttdeci">void statevec_collapseToKnownProbOutcome(Qureg qureg, int measureQubit, int outcome, qreal outcomeProb)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__cpu__distributed_8c_source.html#l01368">QuEST_cpu_distributed.c:1368</a></div></div>
<div class="ttc" id="aQuEST__common_8c_html_aecc3c36b275c53b321de1611c2f06f78"><div class="ttname"><a href="QuEST__common_8c.html#aecc3c36b275c53b321de1611c2f06f78">shiftSubregIndices</a></div><div class="ttdeci">void shiftSubregIndices(int *allInds, int *numIndsPerReg, int numRegs, int shift)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__common_8c_source.html#l00161">QuEST_common.c:161</a></div></div>
<div class="ttc" id="aQuEST__validation_8c_html_a99e98bb5d38287fbb51f1e094d1eb68e"><div class="ttname"><a href="QuEST__validation_8c.html#a99e98bb5d38287fbb51f1e094d1eb68e">validatePhaseFuncName</a></div><div class="ttdeci">void validatePhaseFuncName(enum phaseFunc funcCode, int numRegs, int numParams, const char *caller)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__validation_8c_source.html#l00913">QuEST_validation.c:913</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="agroup__operator_html_ga8dca543fb4d1ee1cd8b4c5d6028b3075"><div class="ttname"><a href="group__operator.html#ga8dca543fb4d1ee1cd8b4c5d6028b3075">applyMultiVarPhaseFuncOverrides</a></div><div class="ttdeci">void applyMultiVarPhaseFuncOverrides(Qureg qureg, int *qubits, int *numQubitsPerReg, int numRegs, enum bitEncoding encoding, qreal *coeffs, qreal *exponents, int *numTermsPerReg, long long int *overrideInds, qreal *overridePhases, int numOverrides)</div><div class="ttdoc">Induces a phase change upon each amplitude of qureg, determined by a multi-variable exponential polyn...</div><div class="ttdef"><b>Definition:</b> <a href="QuEST_8c_source.html#l00778">QuEST.c:778</a></div></div>
<div class="ttc" id="aQuEST__validation_8c_html_a2b88b068a8242ee28da42c7324cdd078"><div class="ttname"><a href="QuEST__validation_8c.html#a2b88b068a8242ee28da42c7324cdd078">validateMatchingQuregPauliHamilDims</a></div><div class="ttdeci">void validateMatchingQuregPauliHamilDims(Qureg qureg, PauliHamil hamil, const char *caller)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__validation_8c_source.html#l00660">QuEST_validation.c:660</a></div></div>
<div class="ttc" id="astructQureg_html_acf78445e9435d09f44f0cc832c6aee79"><div class="ttname"><a href="structQureg.html#acf78445e9435d09f44f0cc832c6aee79">Qureg::isDensityMatrix</a></div><div class="ttdeci">int isDensityMatrix</div><div class="ttdoc">Whether this instance is a density-state representation.</div><div class="ttdef"><b>Definition:</b> <a href="QuEST_8h_source.html#l00325">QuEST.h:325</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#l00535">QuEST_validation.c:535</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#l00327">QuEST.h:327</a></div></div>
<div class="ttc" id="aQuEST__validation_8c_html_a5b0392701c555a898403f80ef4a32f62"><div class="ttname"><a href="QuEST__validation_8c.html#a5b0392701c555a898403f80ef4a32f62">validateMultiControlsMultiTargets</a></div><div class="ttdeci">void validateMultiControlsMultiTargets(Qureg qureg, int *controlQubits, int numControlQubits, int *targetQubits, int numTargetQubits, const char *caller)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__validation_8c_source.html#l00459">QuEST_validation.c:459</a></div></div>
<div class="ttc" id="aQuEST__validation_8c_html_a91dad925cb9383384f135b936e5a7f43"><div class="ttname"><a href="QuEST__validation_8c.html#a91dad925cb9383384f135b936e5a7f43">validatePhaseFuncTerms</a></div><div class="ttdeci">void validatePhaseFuncTerms(int numQubits, enum bitEncoding encoding, qreal *coeffs, qreal *exponents, int numTerms, long long int *overrideInds, int numOverrides, const char *caller)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__validation_8c_source.html#l00773">QuEST_validation.c:773</a></div></div>
<div class="ttc" id="aQuEST__validation_8c_html_a576519ac36b7cb25bab78d05b5d1975f"><div class="ttname"><a href="QuEST__validation_8c.html#a576519ac36b7cb25bab78d05b5d1975f">validateMultiQubitMatrix</a></div><div class="ttdeci">void validateMultiQubitMatrix(Qureg qureg, ComplexMatrixN u, int numTargs, const char *caller)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__validation_8c_source.html#l00496">QuEST_validation.c:496</a></div></div>
<div class="ttc" id="aQuEST__qasm_8c_html_a6d239705dc0400ae75f8715c1f88b79f"><div class="ttname"><a href="QuEST__qasm_8c.html#a6d239705dc0400ae75f8715c1f88b79f">qasm_recordMultiVarPhaseFunc</a></div><div class="ttdeci">void qasm_recordMultiVarPhaseFunc(Qureg qureg, int *qubits, int *numQubitsPerReg, int numRegs, enum bitEncoding encoding, qreal *coeffs, qreal *exponents, int *numTermsPerReg, long long int *overrideInds, qreal *overridePhases, int numOverrides)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__qasm_8c_source.html#l00666">QuEST_qasm.c:666</a></div></div>
<div class="ttc" id="agroup__operator_html_ga225b82ff8b8eed1fff312240ec70c731"><div class="ttname"><a href="group__operator.html#ga225b82ff8b8eed1fff312240ec70c731">applyParamNamedPhaseFunc</a></div><div class="ttdeci">void applyParamNamedPhaseFunc(Qureg qureg, int *qubits, int *numQubitsPerReg, int numRegs, enum bitEncoding encoding, enum phaseFunc functionNameCode, qreal *params, int numParams)</div><div class="ttdoc">Induces a phase change upon each amplitude of qureg, determined by a named, paramaterized (and potent...</div><div class="ttdef"><b>Definition:</b> <a href="QuEST_8c_source.html#l00831">QuEST.c:831</a></div></div>
<div class="ttc" id="agroup__type_html_ggaa7d869b117ba5024d6b84938e8cdfc65a39111120b79016d6b3e773b711fa63f7"><div class="ttname"><a href="group__type.html#ggaa7d869b117ba5024d6b84938e8cdfc65a39111120b79016d6b3e773b711fa63f7">SCALED_INVERSE_SHIFTED_DISTANCE</a></div><div class="ttdeci">@ SCALED_INVERSE_SHIFTED_DISTANCE</div><div class="ttdef"><b>Definition:</b> <a href="QuEST_8h_source.html#l00234">QuEST.h:234</a></div></div>
<div class="ttc" id="aQuEST__validation_8c_html_a82b142fe77ba20c87142274f32e57689"><div class="ttname"><a href="QuEST__validation_8c.html#a82b142fe77ba20c87142274f32e57689">validateTrotterParams</a></div><div class="ttdeci">void validateTrotterParams(int order, int reps, const char *caller)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__validation_8c_source.html#l00703">QuEST_validation.c:703</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#l00599">QuEST_validation.c:599</a></div></div>
<div class="ttc" id="aQuEST__common_8c_html_ae71449b1cc6e6250b91f539153a7a0d3"><div class="ttname"><a href="QuEST__common_8c.html#ae71449b1cc6e6250b91f539153a7a0d3">M_PI</a></div><div class="ttdeci">#define M_PI</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__common_8c_source.html#l00041">QuEST_common.c:41</a></div></div>
<div class="ttc" id="agroup__operator_html_ga35b6321c578a8c69470132b5ee95f930"><div class="ttname"><a href="group__operator.html#ga35b6321c578a8c69470132b5ee95f930">applyTrotterCircuit</a></div><div class="ttdeci">void applyTrotterCircuit(Qureg qureg, PauliHamil hamil, qreal time, int order, int reps)</div><div class="ttdoc">Applies a trotterisation of unitary evolution to qureg.</div><div class="ttdef"><b>Definition:</b> <a href="QuEST_8c_source.html#l01070">QuEST.c:1070</a></div></div>
<div class="ttc" id="aQuEST__qasm_8c_html_ab60a4a8af0530cbfa8cba1b02692d448"><div class="ttname"><a href="QuEST__qasm_8c.html#ab60a4a8af0530cbfa8cba1b02692d448">qasm_recordNamedPhaseFunc</a></div><div class="ttdeci">void qasm_recordNamedPhaseFunc(Qureg qureg, int *qubits, int *numQubitsPerReg, int numRegs, enum bitEncoding encoding, enum phaseFunc funcName, qreal *params, int numParams, long long int *overrideInds, qreal *overridePhases, int numOverrides)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__qasm_8c_source.html#l00726">QuEST_qasm.c:726</a></div></div>
<div class="ttc" id="agroup__type_html_ga9c91c41aa42ae537995e89ffc616afe1"><div class="ttname"><a href="group__type.html#ga9c91c41aa42ae537995e89ffc616afe1">bitEncoding</a></div><div class="ttdeci">bitEncoding</div><div class="ttdoc">Flags for specifying how the bits in sub-register computational basis states are mapped to indices in...</div><div class="ttdef"><b>Definition:</b> <a href="QuEST_8h_source.html#l00269">QuEST.h:269</a></div></div>
<div class="ttc" id="agroup__qasm_html_gacf139d0a54b1f9e5c2f2feff742b8c76"><div class="ttname"><a href="group__qasm.html#gacf139d0a54b1f9e5c2f2feff742b8c76">printRecordedQASM</a></div><div class="ttdeci">void printRecordedQASM(Qureg qureg)</div><div class="ttdoc">Print recorded QASM to stdout.</div><div class="ttdef"><b>Definition:</b> <a href="QuEST_8c_source.html#l00099">QuEST.c:99</a></div></div>
<div class="ttc" id="aQuEST__qasm_8c_html_a383ddaecc94e1ce4a6fdbdbabeaa3131"><div class="ttname"><a href="QuEST__qasm_8c.html#a383ddaecc94e1ce4a6fdbdbabeaa3131">qasm_recordPhaseFunc</a></div><div class="ttdeci">void qasm_recordPhaseFunc(Qureg qureg, int *qubits, int numQubits, enum bitEncoding encoding, qreal *coeffs, qreal *exponents, int numTerms, long long int *overrideInds, qreal *overridePhases, int numOverrides)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__qasm_8c_source.html#l00490">QuEST_qasm.c:490</a></div></div>
<div class="ttc" id="aQuEST__internal_8h_html_ab33437d10c1ce1c4b034c7c411db553f"><div class="ttname"><a href="QuEST__internal_8h.html#ab33437d10c1ce1c4b034c7c411db553f">statevec_applyMultiVarPhaseFuncOverrides</a></div><div class="ttdeci">void statevec_applyMultiVarPhaseFuncOverrides(Qureg qureg, int *qubits, int *numQubitsPerReg, int numRegs, enum bitEncoding encoding, qreal *coeffs, qreal *exponents, int *numTermsPerReg, long long int *overrideInds, qreal *overridePhases, int numOverrides, int conj)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__cpu_8c_source.html#l04345">QuEST_cpu.c:4345</a></div></div>
<div class="ttc" id="agroup__type_html_ggaa7d869b117ba5024d6b84938e8cdfc65ae8c96906c1ec109d295c491e572d01e2"><div class="ttname"><a href="group__type.html#ggaa7d869b117ba5024d6b84938e8cdfc65ae8c96906c1ec109d295c491e572d01e2">SCALED_INVERSE_NORM</a></div><div class="ttdeci">@ SCALED_INVERSE_NORM</div><div class="ttdef"><b>Definition:</b> <a href="QuEST_8h_source.html#l00232">QuEST.h:232</a></div></div>
<div class="ttc" id="aQuEST__internal_8h_html_aedd7ecccf2f09dd2f1c5d191950b51e6"><div class="ttname"><a href="QuEST__internal_8h.html#aedd7ecccf2f09dd2f1c5d191950b51e6">densmatr_applyDiagonalOp</a></div><div class="ttdeci">void densmatr_applyDiagonalOp(Qureg qureg, DiagonalOp op)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__cpu__distributed_8c_source.html#l01594">QuEST_cpu_distributed.c:1594</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>