Function calcInnerProduct

Source
pub unsafe extern "C" fn calcInnerProduct(
    bra: Qureg,
    ket: Qureg,
) -> Complex
Expand description

Computes the inner product \f$ \langle \text{bra} | \text{ket} \rangle \f$ of two equal-size state vectors, given by \f[ \langle \text{bra} | \text{ket} \rangle = \sum_i {\text{bra}_i}^* ; \times ; \text{ket}_i \f] The same \p qureg may be passed as both \p bra and \p ket, though we recommend users check state-vector normalisation with \p calcTotalProb which employs Kahan summation for greater accuracy. Neither state-vector is modified.

This function returns the correct inner product even if \p bra and \p ket are not correctly normalised states.

@see

  • calcDensityInnerProduct()

@ingroup calc @param[in] bra qureg to be the ‘bra’ (i.e. have its values conjugate transposed) in the inner product @param[in] ket qureg to be the ‘ket’ in the inner product @return the complex inner product of \p bra and \p ket @throws invalidQuESTInputError()

  • if either \p bra and \p ket are not both state-vectors
  • if \p bra and \p ket do not have equal dimensions @author Tyson Jones