cirq.qis.fidelity

Fidelity of two quantum states.

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.

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.

The fidelity.

ValueError The qid shape of the given states was not specified and could not be inferred.
ValueError Invalid quantum state.