rho_mk_cell

Post Processing - Classical Shadow - Rho M K Cell (qurry.process.classical_shadow.rho_mk_cell)

qurry.process.classical_shadow.rho_mk_cell.RhoMKCellMethod

Type for rho_mk_cell method. It can be either “numpy”, “numpy_precomputed”, “jax_flatten”, or “numpy_flatten”. - “numpy”: Use Numpy to calculate the rho_m. - “numpy_precomputed”: Use Numpy to calculate the rho_m with precomputed values. Currently, “numpy_precomputed” is the best option for performance.

alias of Literal[‘numpy’, ‘numpy_precomputed’] | str

qurry.process.classical_shadow.rho_mk_cell.rho_mk_cell_py(idx: int, single_counts: dict[str, int], nu_shadow_direction: dict[int, Literal[0, 1, 2] | int], selected_classical_registers: list[int]) tuple[int, list[tuple[str, int, ndarray[tuple[int, int], dtype[complex128]]]], list[int]][source]

\(\rho_{mk}\) calculation for single cell.

The matrix :math:`rho_{mk}^{i} is calculated by the following equation, .. math:

\rho_{mk}^{i} = \frac{3} U_{mi}^{\dagger} |b_k \rangle\langle b_k | U_{mi} - \mathbb{1}

The matrix \(\rho_{mk}\) is calculated by the following equation, .. math:

\rho_{mk} = \bigotimes_{i=1}^{N_q} \rho_{mk}^{i}

where \(N_q\) is the number of qubits,

Parameters:
  • idx (int) – Index of the cell (counts).

  • single_counts (dict[str, int]) – Counts measured by the single quantum circuit.

  • nu_shadow_direction (dict[int, Union[Literal[0, 1, 2], int]]) – The shadow direction of the unitary operators.

  • selected_classical_registers (list[int]) – The list of the index of the selected_classical_registers.

Returns:

tuple[

int, list[tuple[str, int, np.ndarray[tuple[int, int], np.dtype[np.complex128]]]] list[int],

]:

Index, the list of the data of rho_mk, the sorted list of the selected qubits

qurry.process.classical_shadow.rho_mk_cell.rho_mk_cell_py_precomputed(idx: int, single_counts: dict[str, int], nu_shadow_direction: dict[int, Literal[0, 1, 2] | int], selected_classical_registers: list[int]) tuple[int, list[tuple[str, int, ndarray[tuple[int, int], dtype[complex128]]]], list[int]][source]

\(\rho_{mk}\) calculation for single cell.

The matrix :math:`rho_{mk}^{i} is calculated by the following equation, .. math:

\rho_{mk}^{i} = \frac{3} U_{mi}^{\dagger} |b_k \rangle\langle b_k | U_{mi} - \mathbb{1}

The matrix \(\rho_{mk}\) is calculated by the following equation, .. math:

\rho_{mk} = \bigotimes_{i=1}^{N_q} \rho_{mk}^{i}

where \(N_q\) is the number of qubits,

Parameters:
  • idx (int) – Index of the cell (counts).

  • single_counts (dict[str, int]) – Counts measured by the single quantum circuit.

  • nu_shadow_direction (dict[int, Union[Literal[0, 1, 2], int]]) – The shadow direction of the unitary operators.

  • selected_classical_registers (list[int]) – The list of the index of the selected_classical_registers.

Returns:

tuple[

int, list[tuple[str, int, np.ndarray[tuple[int, int], np.dtype[np.complex128]]]] list[int],

]:

Index, the list of the data of rho_mk, the sorted list of the selected qubits