Fidelity of two quantum states.
cirq.qis.fidelity(
state1: 'cirq.QUANTUM_STATE_LIKE',
state2: 'cirq.QUANTUM_STATE_LIKE',
qid_shape: Optional[Tuple[int, ...]] = None,
validate: bool = True,
atol: float = 1e-07
) -> float
The fidelity of two density matrices ρ and σ is defined as
trace(sqrt(sqrt(ρ) σ sqrt(ρ)))^2.
The given states can be state vectors or density matrices.
Args |
state1
|
The first state.
|
state2
|
The second state.
|
qid_shape
|
The qid shape of the given states.
|
validate
|
Whether to check if the given states are valid quantum states.
|
atol
|
Absolute numerical tolerance to use for validation.
|
Raises |
ValueError
|
The qid shape of the given states was not specified and
could not be inferred.
|
ValueError
|
Invalid quantum state.
|