![]() |
The Quantum Exact Simulation Toolkit v4.2.0
|
Functions for calculating single-state properties like normalisation and purity. More...
Functions | |
qreal | calcPurity (Qureg qureg) |
qreal | calcTotalProb (Qureg qureg) |
Functions for calculating single-state properties like normalisation and purity.
qreal calcPurity | ( | Qureg | qureg | ) |
Calculates the purity of qureg
, which is a measure of its mixedness.
Let \(N\) be the number of qubits in qureg
.
When qureg
is a density matrix \( \dmrho \) (as expected), this function returns
\[ \tr{ \dmrho^2 } = \sum\limits_{i,j} \left| \dmrho_{ij} \right|^2 \]
where \( \dmrho_{ij} \) is the \((i,j)\)-th element of \( \dmrho \).
A purity of 1
indicates that the matrix is pure and can be expressed as
\[ \dmrho \equiv \ketbra{\phi}{\phi} \]
where \( \ket{\phi} \) is some pure state expressible as a statevector.
In contrast, a purity less than 1
indicates the matrix is mixed and can be understood as a convex combination of multiple (at least two) pure states. That is,
\[ \dmrho \equiv \sum\limits_n p_n \ketbra{\phi}{\phi}_n, \]
where \(p_n \in [0,1]\) and sum to 1
whenever \(\dmrho\) is a valid and correctly normalised density matrix. Mixedness can result, for example, from Decoherence.
The minimum purity of an \(N\)-qubit density matrix is \( 1/2^N \), which is admitted only by the maximally-mixed state \( \dmrho = \hat{\id} / 2^N \).
qureg
is a statevector \( \svpsi \), this function returns \[ \tr{ \ketbra{\psi}{\psi} \; \ketbra{\psi}{\psi} } = \left( \sum\limits_i |\psi_i|^2 \right)^2 \]
where \(\psi_i\) is the \(i\)-th amplitude of \(\svpsi\). This is always1
for any valid statevector, and is otherwise equivalent to the output of calcTotalProb(), squared.qureg
is correctly normalised. For example, an invalid density matrix can return a purity of 1
, such as the \(N\)-qubit maximally-mixed state scaled by factor \( 2^N \). Note that the function calcTotalProb() alone cannot be used to validate validity since it only consults diagonal elements, whereas the purity is informed by all elements.qureg
is a valid density matrix (specifically, Hermitian), this function is faster than, but mathematically equivalent to, calling calcInnerProduct() and passing qureg
twice. qureg
is a statevector, this function returns the output of calcTotalProb(), squared.[in] | qureg | the reference state, which is unchanged. |
qureg
. error |
|
Definition at line 293 of file calculations.cpp.
Referenced by TEST_CASE(), TEST_CASE(), TEST_CASE(), and TEST_CASE().
qreal calcTotalProb | ( | Qureg | qureg | ) |
Calculates the probability normalisation of the given qureg
. This is the probability of the qureg
being in any outcome state, which is expected to equal 1
.
Let \(N\) be the number of qubits in qureg
.
qureg
is a statevector \( \svpsi \) with \(i\)-th amplitude \(\psi_i\), this function returns \[ \sum\limits_{i=0}^{2^N-1} |\psi_i|^2. \]
qureg
is a density matrix \( \dmrho \) with \(i\)-th diagonal element \( \dmrho_{ii} \), this function returns \[ \sum\limits_{i=0}^{2^N-1} \re{ \rho_{ii} } \]
[in] | qureg | the reference state, which is unchanged. |
qureg
. error |
|
Definition at line 278 of file calculations.cpp.
Referenced by setQuregToRenormalized(), TEST_CASE(), TEST_CASE(), TEST_CASE(), and TEST_CASE().