Function calcDensityInnerProduct

Source
pub unsafe extern "C" fn calcDensityInnerProduct(
    rho1: Qureg,
    rho2: Qureg,
) -> f64
Expand description

Computes the Hilbert-Schmidt scalar product (which is equivalent to the Frobenius inner product of matrices) of two density matrices \p rho1 and \p rho2 of equivalent size. That is, we define the Hilbert-Schmidt scalar product \f[ ((\rho_1, \rho_2)){HS} := \text{Tr}[ \rho_1^\dagger \rho_2 ], \f] which is equivalent to the sum of products of matrix elemets, i.e., \f[ ((\rho_1, \rho_2)){HS} = \sum\limits_i \sum\limits_j (\rho_1){ij}^* (\rho_2){ij} \f] Assuming that both density matrices are Hermitian, the resulting scalar product is real and invariant under reordering its arguments as \f[ ((\rho_1, \rho_2)){HS} = ((\rho_2, \rho_1)){HS} = \text{Tr}[\rho_1 \rho_2] \f] If both \p rho1 and \p rho2 are density matrices of pure states \p bra and \p ket, then the equality holds \f[ ((\rho_1, \rho_2)){HS} = |\langle \text{bra} | \text{ket} \rangle|^2. \f] If either or both of \p rho1 and \p rho2 are non Hermitian (i.e. invalid density matrices), then this function returns the real component of the scalar product, and discards the imaginary component. That is, it returns \f[ \text{Re}{ \text{Tr}[ \rho_1^\dagger \rho_2 ] } = \text{Re}{ \text{Tr}[ \rho_2^\dagger \rho_1 ] }. \f] This is still sometimes useful, e.g. in calculating the inner product with an anti-commutator, e.g. (for Hermitian \f$ \sigma \f$, \f$ \rho \f$, \f$ H \f$) \f[ ((\sigma, H \rho + \rho H)){HS} = 2 ; \text{Re} { ((\sigma, H \rho))_{HS} } \f] where \f$ H \rho \f$ could be a weighted sum of Pauli products applied to \f$ \rho \f$ through applyPauliSum().

@see

  • calcInnerProduct()
  • calcHilbertSchmidtDistance()

@ingroup calc @param[in] rho1 qureg as a density matrix (to have its values conjugate transposed) @param[in] rho2 qureg as a density matrix @returns the real Hilbert-Schmidt scalar product of density matrices \p rho1 and \p rho2 (assuming Hermiticity) @throws invalidQuESTInputError()

  • if \p rho1 and \p rho2 are not both density matrices
  • if \p rho1 and \p rho2 have mismatching dimensions @author Balint Koczor (CPU) @author Tyson Jones (GPU)