State Tomography¶
- class lightworks.tomography.StateTomography(n_qubits: int, base_circuit: PhotonicCircuit)¶
Bases:
_TomographyGenerates the required circuit and performs data processing for the calculation of the density matrix of a state.
- Parameters:
n_qubits (int) – The number of qubits that will be used as part of the tomography.
base_circuit (PhotonicCircuit) – An initial circuit which produces the required output state and can be modified for performing tomography. It is required that the number of circuit input modes equals 2 * the number of qubits.
- check_eigenvalues() ndarray[tuple[Any, ...], dtype[float64]]¶
Determines the eigenvalues of the calculated density matrix, if the matrix is physical then these should all be non-negative.
- Returns:
- An array of the calculated eigenvalues, ranging from
smallest to largest.
- Return type:
np.ndarray
- fidelity(rho_exp: ndarray[tuple[Any, ...], dtype[complex128]]) float¶
Calculates the fidelity of the calculated quantum state against the expected density matrix for the state.
- Parameters:
rho_exp (np.ndarray) – The expected density matrix.
- Returns:
The calculated fidelity value.
- Return type:
float
- get_experiments() StateTomographyList¶
Generates all required tomography experiments for performing a process tomography algorithm.
- process(data: list[dict[State, int]] | dict[str, dict[State, int]], project_to_physical: bool = False) ndarray[tuple[Any, ...], dtype[complex128]]¶
Performs the state tomography process with the configured elements to calculate the density matrix of the output state.
- Parameters:
data (list | dict) – The collected measurement data. If a list then this should match the order the experiments were provided, and if a dictionary, then each key should be the corresponding measurement basis.
project_to_physical (bool) – Controls whether the calculated density matrix is projected to a physical space. Defaults to False.
- Returns:
- The calculated density matrix from the state tomography
process.
- Return type:
np.ndarray
- property rho: ndarray[tuple[Any, ...], dtype[complex128]]¶
The most recently calculated density matrix.