pub unsafe extern "C" fn calcPurity(qureg: Qureg) -> f64Expand description
Calculates the purity of a density matrix, by the trace of the density matrix squared. Returns \f$\text{Tr}(\rho^2)\f$. For a pure state, this =1. For a mixed state, the purity is less than 1 and is lower bounded by 1/2^n, where n is the number of qubits. The minimum purity is achieved for the maximally mixed state identity/2^n.
This function does not accept state-vectors, which clearly have purity 1.
Note this function will give incorrect results for non-Hermitian Quregs (i.e. invalid density matrices), which will disagree with \f$\text{Tr}(\rho^2)\f$. Instead, this function returns \f$\sum_{ij} |\rho_{ij}|^2 \f$.
@see
- calcFidelity()
- calcHilbertSchmidtDistance()
- calcTotalProb()
@ingroup calc @param[in] qureg a density matrix of which to measure the purity @return the purity @throws invalidQuESTInputError()
- if either \p combineQureg or \p otherQureg are not density matrices
- if the dimensions of \p combineQureg and \p otherQureg do not match
- if \p prob is not in [0, 1] @author Tyson Jones