toqito.state_metrics.hilbert_schmidt_inner_product

toqito.state_metrics.hilbert_schmidt_inner_product(a_mat, b_mat)[source]

Compute the Hilbert-Schmidt inner product between two matrices [WikHSO].

The Hilbert-Schmidt inner product between \(a_mat\) and \(b_mat\) is defined as

\[HS = (A|B) = Tr[A^\dagger B]\]

where \(|B> = vec(B)\) and \(<A|\) is the dual vector to \(|A>\).

Note: This function has been adapted from [Rigetti21].

Examples

One may consider taking the Hilbert-Schmidt distance between the Hadamard matrix and itself matrix.

>>> from toqito.matrices import hadamard
>>> from toqito.matrices import pauli
>>> h = hadamard(1)
>>> hilbert_schmidt_inner_product(h, h)
2

References

[WikHSO]

Wikipedia: Hilbert-Schmidt operator. https://en.wikipedia.org/wiki/Hilbert%E2%80%93Schmidt_operator

Parameters:
  • a_mat – An input matrix provided as a numpy array.

  • b_mat – An input matrix provided as a numpy array.

Returns:

The Hilbert-Schmidt inner product between a_mat and b_mat.