pub unsafe extern "C" fn calcFidelity(
qureg: Qureg,
pureState: Qureg,
) -> f64Expand description
Calculates the fidelity of \p qureg (a state-vector or density matrix) against a reference pure state (necessarily a state-vector). If \p qureg is a state-vector, this function computes \f[ |\langle \text{qureg} | \text{pureState} \rangle|^2 \f] If \p qureg is a density matrix, this function computes \f[ \langle \text{pureState} | \text{qureg} | \text{pureState} \rangle \f] In either case, the returned fidelity lies in [0, 1] (assuming both input states have valid normalisation). If any of the input \p Quregs are not normalised, this function will return the real component of the correct linear algebra calculation.
The number of qubits represented in \p qureg and \p pureState must match.
In the GPU-accelerated cuQuantum backend, this function further assumes that the density matrix \p qureg is correctly normalised, and otherwise returns the fidelity of the conjugate-transpose of \p qureg.
@see
- calcHilbertSchmidtDistance()
- calcPurity()
@ingroup calc @param[in] qureg a density matrix or state vector @param[in] pureState a state vector @return the fidelity between the input registers @throws invalidQuESTInputError()
- if the second argument (\p pureState) is not a state-vector
- if the number of qubits in \p qureg and \p pureState do not match @author Tyson Jones