qsttoolkit.quantum Submodule

Miscellaneous functions for quantum state tomography research.

qsttoolkit.quantum.expectation(rho: Tensor, measurement_operators: list[Qobj], numpy: bool = False) Tensor[source]

Computes the expectation values of the given density matrix with respect to the given projective measurement operators using purely TensorFlow operations.

Parameters:
  • rho (tf.Tensor) – Density matrix to compute expectation values for.

  • measurement_operators (list of Qobj) – Projective measurement operators to compute the expectation values for.

  • numpy (bool) – If True, returns the result as a NumPy array. Defaults to False.

Returns:

Expectation values of the density matrix with respect to the measurement operators.

Return type:

tf.Tensor

qsttoolkit.quantum.fidelity(rho: ndarray, sigma: ndarray) float[source]

Computes the fidelity between two density matrices.

Parameters:
  • rho (np.ndarray) – First density matrix.

  • sigma (np.ndarray) – Second density matrix.

Returns:

Fidelity between the two density matrices.

Return type:

float

qsttoolkit.quantum.hadamard() Qobj[source]

Returns the single-qubit Hadamard gate.

Returns:

Hadamard gate as a Qobj.

Return type:

Qobj

qsttoolkit.quantum.maximally_mixed_state_dm(N: int, dim=None) Qobj[source]

Computes the maximally mixed state density matrix in the given Hilbert space dimensionality.

Parameters:

N (int) – Hilbert space dimensionality.

Returns:

Maximally mixed state density matrix.

Return type:

Qobj

qsttoolkit.quantum.phase_space_grid(x_min: float, x_max: float, p_min: float, p_max: float, num_x_points: int, num_p_points: int) tuple[ndarray, ndarray][source]

Generates a grid of points in x-p phase space.

Parameters:
  • x_min (float) – Minimum x-coordinate of the grid.

  • x_max (float) – Maximum x-coordinate of the grid.

  • p_min (float) – Minimum p-coordinate of the grid.

  • p_max (float) – Maximum p-coordinate of the grid.

  • num_x_points (int) – Number of points along the x-axis.

  • num_p_points (int) – Number of points along the p-axis.

Returns:

2D array containing the complex coordinates of the grid points in x-p phase space.

Return type:

np.ndarray

qsttoolkit.quantum.random_positive_semidefinite_dm(N: int, dim=None) Qobj[source]

Computes a random positive semi-definite density matrix in the given Hilbert space dimensionality.

Parameters:

N (int) – Hilbert space dimensionality.

Returns:

Random positive semi-definite density matrix.

Return type:

Qobj