![]() |
The Quantum Exact Simulation Toolkit v4.2.0
|
Functions for applying general one-qubit dense matrices, as CompMatr1. More...
Functions | |
| void | applyCompMatr1 (Qureg qureg, int target, CompMatr1 matrix) |
| void | applyControlledCompMatr1 (Qureg qureg, int control, int target, CompMatr1 matrix) |
| void | applyMultiControlledCompMatr1 (Qureg qureg, int *controls, int numControls, int target, CompMatr1 matrix) |
| void | applyMultiStateControlledCompMatr1 (Qureg qureg, int *controls, int *states, int numControls, int target, CompMatr1 matrix) |
Functions for applying general one-qubit dense matrices, as CompMatr1.
Applies a general one-qubit dense unitary matrix to the specified target qubit of qureg.
Let \( \hat{U} = \) matrix, \( t = \) target, and let \(\hat{U}_t\) notate operating \(\hat{U}\) upon the \( t \)-th qubit among \( N \), i.e.
\[ \hat{U}_t \equiv \id^{N-t} \otimes \hat{U} \otimes \id^{t-1}. \]
Then,
qureg is a statevector \( \svpsi \), this function effects \[ \svpsi \rightarrow \hat{U}_t \, \svpsi. \]
qureg is a density matrix \(\dmrho\), this function effects \[ \dmrho \rightarrow \hat{U}_t \, \dmrho \, {\hat{U}_t}^\dagger. \]
matrix requires that \( \hat{U} \hat{U}^\dagger = \id \). Validation will check that matrix is approximately unitary via \[ \max\limits_{ij} \Big|\left(\hat{U} \hat{U}^\dagger - \id\right)_{ij}\Big|^2 \le \valeps \]
where the validation epsilon \( \valeps \) can be adjusted with setValidationEpsilon().| [in,out] | qureg | the state to modify. |
| [in] | target | the index of the target qubit. |
| [in] | matrix | the Z-basis unitary matrix to effect. |
| error |
|
Definition at line 75 of file operations.cpp.
Referenced by TEST_CASE().
Applies a singly-controlled one-qubit dense unitary matrix to the specified target qubit of qureg.
Let \( \hat{U} = \) matrix, \( t = \) target, \( c = \) control, and let \(\hat{O}_q\) denote an operator upon the \(q\)-th qubit. This function effects operator
\[ C_c[\hat{U}_t] = \ketbra{0}{0}_c \otimes \id_t + \ketbra{1}{1}_c \otimes \hat{U}_t, \]
where \(\hat{U}\) is effected upon basis states for which qubit \(c\) has value 1. For illustration, when control=0 and target=1, this function would effect
\[ C_1[\hat{U}_0] \equiv \begin{pmatrix} 1 \\ & 1 \\ & & u_{00} & u_{01} \\ & & u_{10} & u_{11} \end{pmatrix}. \]
This operation can be performed upon statevectors and density matrices.
qureg is a statevector \( \svpsi \), this function effects \[ \svpsi \rightarrow C_c[\hat{U}_t] \, \svpsi. \]
qureg is a density matrix \(\dmrho\), this function effects \[ \dmrho \rightarrow C_c[\hat{U}_t] \, \dmrho \, {C_c[\hat{U}_t]}^\dagger. \]
matrix requires that \( \hat{U} \hat{U}^\dagger = \id \). Validation will check that matrix is approximately unitary via \[ \max\limits_{ij} \Big|\left(\hat{U} \hat{U}^\dagger - \id\right)_{ij}\Big|^2 \le \valeps \]
where the validation epsilon \( \valeps \) can be adjusted with setValidationEpsilon().| [in,out] | qureg | the state to modify. |
| [in] | control | the index of the control qubit. |
| [in] | target | the index of the target qubit. |
| [in] | matrix | the Z-basis unitary matrix to effect. |
| error |
|
Definition at line 80 of file operations.cpp.
| void applyMultiControlledCompMatr1 | ( | Qureg | qureg, |
| int * | controls, | ||
| int | numControls, | ||
| int | target, | ||
| CompMatr1 | matrix ) |
Applies a multiply-controlled one-qubit dense unitary matrix to the specified target qubit of qureg.
Let \( \vec{c} = \) controls, \( t = \) target, and \( \hat{U} = \) matrix. This functions effects operator
\[ C_{\vec{c}}[\hat{U}_t] \]
which is equivalent to applying \( \hat{U}_t \) upon only the computational basis states for which all control qubits are in the \( \ket{1} \) state.
Precisely, let \(n = 2^{|\vec{c}|}-1\). Then
\[ C_{\vec{c}}[\hat{U}_t] = \sum\limits_{i=0}^{n-1} \ketbra{i}{i}_{\vec{c}} \otimes \hat{\id}_t + \ketbra{n}{n}_{\vec{c}} \otimes \hat{U}_t \]
Definition at line 85 of file operations.cpp.
Referenced by applyMultiControlledCompMatr1().
| void applyMultiStateControlledCompMatr1 | ( | Qureg | qureg, |
| int * | controls, | ||
| int * | states, | ||
| int | numControls, | ||
| int | target, | ||
| CompMatr1 | matrix ) |
Applies an arbitrarily-controlled one-qubit dense unitary matrix to the specified target qubit of qureg, conditioned upon the controls being in the given states.
Definition at line 90 of file operations.cpp.
Referenced by applyMultiStateControlledCompMatr1(), and applyMultiStateControlledRotateAroundAxis().