# qml.math.frobenius_inner_product¶

frobenius_inner_product(A, B, normalize=False, like=None)[source]

Frobenius inner product between two matrices.

$\langle A, B \rangle_F = \sum_{i,j=1}^n A_{ij} B_{ij} = \operatorname{tr} (A^T B)$

The Frobenius inner product is equivalent to the Hilbert-Schmidt inner product for matrices with real-valued entries.

Parameters
• A (tensor_like[float]) – First matrix, assumed to be a square array.

• B (tensor_like[float]) – Second matrix, assumed to be a square array.

• normalize (bool) – If True, divide the inner product by the Frobenius norms of A and B.

Returns

Frobenius inner product of A and B

Return type

float

Example

>>> A = np.random.random((3,3))
>>> B = np.random.random((3,3))
>>> qml.math.frobenius_inner_product(A, B)
3.091948202943376