unitary_overlap
class qiskit.circuit.library.unitary_overlap(unitary1, unitary2, prefix1='p1', prefix2='p2', insert_barrier=False)
Bases:
Circuit that returns the overlap between two unitaries .
The input quantum circuits must represent unitary operations, since they must be invertible. If the inputs will have parameters, they are replaced by ParameterVector
s with names “p1” (for circuit unitary1
) and “p2” (for circuit unitary_2
) in the output circuit.
This circuit is usually employed in computing the fidelity:
by computing the probability of being in the all-zeros bit-string, or equivalently, the expectation value of projector .
Reference Circuit:
import numpy as np
from qiskit.circuit.library import EfficientSU2, unitary_overlap
# get two circuit to prepare states of which we compute the overlap
circuit = EfficientSU2(2, reps=1)
unitary1 = circuit.assign_parameters(np.random.random(circuit.num_parameters))
unitary2 = circuit.assign_parameters(np.random.random(circuit.num_parameters))
# create the overlap circuit
overlap = unitary_overlap(unitary1, unitary2)
overlap.draw('mpl')
Parameters
- unitary1 (QuantumCircuit) – Unitary acting on the ket vector.
- unitary2 (QuantumCircuit) – Unitary whose inverse operates on the bra vector.
- prefix1 (str) – The name of the parameter vector associated to
unitary1
, if it is parameterized. Defaults to"p1"
. - prefix2 (str) – The name of the parameter vector associated to
unitary2
, if it is parameterized. Defaults to"p2"
. - insert_barrier (bool) – Whether to insert a barrier between the two unitaries.
Raises
- CircuitError – Number of qubits in
unitary1
andunitary2
does not match. - CircuitError – Inputs contain measurements and/or resets.
Return type
Was this page helpful?
Report a bug or request content on GitHub.