kosmos.quantum_logic.quantum_state

Classes

class QuantumState(*, rho: numpy.ndarray | None = None, fidelity: float | None = 0.0)[source]

Representation of a quantum state using a density matrix.

fidelity

Fidelity of a quantum state.

Type:

float | None

Initialize and validate density matrix and validity of state.

Parameters:
  • rho (np.ndarray | None) – Density matrix of a quantum register. Defaults to None.

  • fidelity (float | None) – Fidelity value of a quantum register. Defaults to 0.0.


Properties

property rho

Density matrix of a state.

property dim

Dimension of rho.


Methods

validate_density_matrix(rho: numpy.ndarray, tolerance: float = 1e-10) None[source]

Verify whether the density matrix represents a quantum state.

Parameters:
  • rho (np.ndarray) – Density matrix.

  • tolerance (float) – Tolerance due to inaccurate calculations. Defaults to 1e-10.

fidelity_from_rho(target: QuantumState) float[source]

Compute Uhlmann fidelity between two states.

Parameters:

target (QuantumState) – target quantum state.

Returns:

Fidelity value between 0 and 1.

Return type:

float

fidelity_with_target(target_rho: numpy.ndarray) float[source]

Compute fidelity between this state and an ideal target state.

Measures how close the actual state is to the ideal state.

Parameters:

target_rho (np.ndarray) – Density matrix of the ideal target state.

Returns:

Fidelity value between 0 and 1.

Return type:

float