state_metrics.hilbert_schmidt_inner_product

Hilbert-Schmidt Inner Product.

Module Contents

Functions

hilbert_schmidt_inner_product(a_mat, b_mat)

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

state_metrics.hilbert_schmidt_inner_product.hilbert_schmidt_inner_product(a_mat, b_mat)

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

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

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

where \(|B\rangle = \text{vec}(B)\) and \(\langle A|\) is the dual vector to \(|A \rangle\).

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

Examples

One may consider taking the Hilbert-Schmidt distance between two Hadamard matrices.

>>> from toqito.matrices import hadamard
>>> from toqito.state_metrics import hilbert_schmidt_inner_product
>>> h = hadamard(1)
>>> '%.2f' % hilbert_schmidt_inner_product(h, h)
'2.00'

Note

You do not need to use ‘%.2f’ % when you use this function.

We use this to format our output such that doctest compares the calculated output to the expected output upto two decimal points only. The accuracy of the solvers can calculate the float output to a certain amount of precision such that the value deviates after a few digits of accuracy.

References

[1]

Rigetti. Forest benchmarking. https://github.com/rigetti/forest-benchmarking.

[2] (1,2)

Wikipedia. Hilbert-schmidt operator. https://en.wikipedia.org/wiki/Hilbert.

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

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

Returns:

The Hilbert-Schmidt inner product between a_mat and b_mat.

Return type:

complex