average_gate_fidelity_from_unitaries
- average_gate_fidelity_from_unitaries(unitary_1, unitary_2)
Return the average gate fidelity between two unitary matrices.
- Parameters:
unitary_1 (
ndarray
|Array
) – The first unitary matrix, representing the ideal or target quantum operation.unitary_2 (
ndarray
|Array
) – The second unitary matrix, representing the implemented or actual quantum operation. It could be a multidimensional array where the last two dimensions correspond to the unitary matrices themselves.
- Return type:
- Returns:
The average gate fidelity between the two unitaries. If
unitary_2
is multidimensional, it is an array.- Raises:
SimphonyError – If the provided matrices are not of the same shape or are not square matrices.
Note
The formula used for calculating the average gate fidelity \(F\) is:
\[F = \frac{| \text{Tr}(U_1^{\dagger} U_2) |^2 / d + 1}{d + 1},\]where \(d\) is the dimension of the matrices.