Python Module distance¶
Module defines the two basic distance measures Trace Distance and Quantum Infidelity for density matrices. Moreover the maximum distance over two systems can be determined.
- distance.distance(StateA, StateB, dist='Infidelity')[source]¶
Calculate the distance between two quantum states. States can be either pure states or density matrices. Must be defined on a Hilbert space of equal size.
Arguments
- StateA1d or 2d numpy array
Represents the first quantum state as pure state or density matrix.
- StateB1d or 2d numpy array
Represents the second quantum state as pure state or density matrix.
- diststr, optional
Define the measure used, e.g.
Infidelity
orTrace
distance. Default toInfidelity
.
- distance.single_site_rho_max_distance(Out1, Out2, ll, dist='Infidelity')[source]¶
Calculate the maximal distance (infidelity) between the single-site density matrices of two outputs.
Arguments
- Out1dictionary
containing the output of the first simulation.
- Out2dicitionary
containing the output of the second simulation.
- llint
system size
- diststr, optional
Choose which distance should be used. Either ‘Infidelity’ (default) of ‘TraceDistance’.
- distance.two_site_rho_max_distance(Out1, Out2, ll, dist='Infidelity')[source]¶
Calculate the maximal distance (infidelity) between the two-site density matrices of two outputs.
Arguments
- Out1dictionary
containing the output of the first simulation.
- Out2dicitionary
containing the output of the second simulation.
- llint
system size
- diststr, optional
Choose which distance should be used. Either ‘Infidelity’ (default) of ‘TraceDistance’.
- distance.infidelity(StateA, StateB)[source]¶
Calculate the infidelity
Arguments
- StateA1d or 2d numpy array
Represents the first quantum state as pure state or density matrix.
- StateB1d or 2d numpy array
Represents the second quantum state as pure state or density matrix.
- distance.infidelity_psi_psi(psi, phi)[source]¶
Calculate the infidelity of two pure states, which simplifies to .
Arguments
- psi1d numpy array
Represents the first quantum state for the distance measurement.
- phi1d numpy array
Represents the second quantum state for the distance measurement.
- distance.infidelity_psi_rho(psi, rho)[source]¶
Calculate the infidelity of a pure state and a density matrix, which simplifies to .
Arguments
- psi1d numpy array
Represents the first quantum state for the distance measurement, which is a pure state.
- rho2d numpy array
Represents the second quantum state for the distance measurement, which is the density matrix.
- distance.infidelity_rho_rho(rho, sigma)[source]¶
Calculate the infidelity
Arguments
- rho2d numpy array
First density matrix.
- sigma2d numpy array
Second density matrix.
- distance.tracedist(StateA, StateB)[source]¶
Calculate the trace distance with .
Arguments
- StateA1d or 2d numpy array
Represents the first quantum state as pure state or density matrix.
- StateB1d or 2d numpy array
Represents the second quantum state as pure state or density matrix.
- distance.tracedist_psi_psi(psi, phi)[source]¶
Calculate the trace distance for two pure states, which simplifies to
Arguments
- psi1d numpy array
Represents the first quantum state for the distance measurement.
- phi1d numpy array
Represents the second quantum state for the distance measurement.
- distance.tracedist_psi_rho(psi, rho)[source]¶
Calculate the trace distance for a pure state and a density matrix, that is where are the singular values of .
Arguments
- psi1d numpy array
Represents the first quantum state for the distance measurement, which is a pure state.
- rho2d numpy array
Represents the second quantum state for the distance measurement, which is the density matrix.
- distance.tracedist_rho_rho(rho, sigma)[source]¶
Calculate the trace distance with .
Arguments
- rho2d numpy array
First density matrix.
- sigma2d numpy array
Second density matrix.