![]() |
The Quantum Exact Simulation Toolkit v4.2.0
|
Functions for calculating reduced density matrices, creating a new output Qureg. More...
Functions | |
Qureg | calcPartialTrace (Qureg qureg, int *traceOutQubits, int numTraceQubits) |
Qureg | calcReducedDensityMatrix (Qureg qureg, int *retainQubits, int numRetainQubits) |
Functions for calculating reduced density matrices, creating a new output Qureg.
Creates and populates a new Qureg which is a reduced density matrix resulting from tracing out the specified qubits of qureg
. This should be later freed by the user like all Qureg.
Note that the deployments of the output Qureg (i.e. whether multithreaded, GPU-accelerated and distributed) will match those of qureg
. It is ergo intended that this function is used to trace out few qubits, and may show worsening performance when tracing many qubits.
The ordering of traceOutQubits
has no effect, and the ordering of the remaining qubits in the output Qureg match their original relative ordering in qureg
.
Let \(\dmrho_{\text{in}} = \) qureg
and let \(\vec{t} = \) traceOutQubits
which is a list of length \(n = \) numTraceQubits
.
This function returns a new Qureg \(\dmrho_{\text{out}}\) which satisfies
\[ \dmrho_{\text{out}} = \text{Tr}_{\vec{t}} \left( \dmrho_{\text{in}} \right) = \sum\limits_i^{2^n} (\hat{\id} \otimes \bra{i}_{\vec{t}} ) \, \dmrho_{\text{in}} \, (\hat{\id} \otimes \ket{i}_{\vec{t}} ) \]
where \(\ket{i}_{\vec{t}}\) notates the \(i\)-th basis state (in any orthonormal basis) of the targeted qubits, and \((\hat{\id} \otimes \ket{i}_{\vec{t}})\) notates interleaved identity operators upon the non-targeted qubits.
Given an \(N\)-qubit Qureg \(\dmrho_{\text{in}}\), the output \(\dmrho_{\text{out}}\) contains \(N-n\) qubits.
qureg
must be a density matrix. It is however straightforward to prepare a density matrix from a statevector. qureg
is distributed, the returned Qureg will also be distributed, which imposes a minimum on the number of qubits contained within; \(\log_2(W)\) where \(W\) is the number of distributed nodes (or "world size"). This imposes a maximum upon traceOutQubits
of [in] | qureg | a density matrix which is not modified. |
[in] | traceOutQubits | a list of qubits to trace out and ergo from the output Qureg. |
[in] | numTraceQubits | the length of traceOutQubits . |
qureg
. error |
|
seg-fault |
|
Definition at line 373 of file calculations.cpp.
Referenced by calcPartialTrace(), calcReducedDensityMatrix(), and TEST_CASE().
Creates and populates a new Qureg which is a reduced density matrix of qureg
, retaining only the specified qubits and tracing out all others.
Note that the deployments of the output Qureg (i.e. whether multithreaded, GPU-accelerated and distributed) will match those of qureg
. It is ergo intended that this function is used to preserve most qubits of qureg
, and may show worsening performance when retaining only few.
retainQubits
has no effect on the output state. The ordering of the retained qubits will match their original, relative ordering in qureg
.This function is entirely equivalent to calcPartialTrace() except that here the retained qubits are specified, whereas calcPartialTrace() accepts those to be traced out.
Let \(\dmrho_{\text{in}} = \) qureg
, \(\vec{r} = \) retainQubits
, and let \(\vec{q}\) be a list containing all qubits of qureg
. This function partially traces out all qubits in list \(\vec{t} = \vec{q} \setminus \vec{r}\), and returns a new Qureg \(\dmrho_{\text{out}}\) which satisfies
\[ \dmrho_{\text{out}} = \text{Tr}_{\vec{t}} \left( \dmrho_{\text{in}} \right) = \sum\limits_i^{2^n} (\hat{\id} \otimes \bra{i}_{\vec{t}} ) \, \dmrho_{\text{in}} \, (\hat{\id} \otimes \ket{i}_{\vec{t}} ) \]
where \(\ket{i}_{\vec{t}}\) notates the \(i\)-th basis state (in any orthonormal basis) of the qubits in \(\vec{t}\), and \((\hat{\id} \otimes \ket{i}_{\vec{t}})\) notates interleaved identity operators upon the qubits in \(\vec{r}\).
qureg
must be a density matrix. It is however straightforward to prepare a density matrix from a statevector. qureg
is distributed, the returned Qureg will also be distributed, which imposes a minimum on the number of qubits contained within; \(\log_2(W)\) where \(W\) is the number of distributed nodes (or "world size"). This imposes bounds upon numRetainQubits
of [in] | qureg | a density matrix. |
[in] | retainQubits | a list of qubits to retain in the reduced density matrix (at shifted, contiguous indices). |
[in] | numRetainQubits | the length of retainQubits . |
numRetainQubits
qubits, initialised to the reduced density matrix of qureg
. error |
|
seg-fault |
|
Definition at line 393 of file calculations.cpp.
Referenced by calcReducedDensityMatrix(), and TEST_CASE().