trace_expect_process
¶
Post Processing - Classical Shadow - Trace-Expectation Process
(qurry.process.classical_shadow.trace_expect_process
)
This module is used to process the rho dictionary for classical shadow.
- qurry.process.classical_shadow.trace_expect_process.TraceRhoMethod¶
The method to calculate the trace of Rho square. - âtrace_of_matmulâ:
Use np.trace(np.matmul(rho_m1, rho_m2)) to calculate the each summation item in rho_m_list.
- âquick_trace_of_matmulâ or âeinsum_ij_jiâ:
Use np.einsum(âij,jiâ, rho_m1, rho_m2) to calculate the each summation item in rho_m_list.
- âeinsum_aij_bji_to_ab_numpyâ:
Use np.einsum(âaij,bji->abâ, rho_m_list, rho_m_list) to calculate the trace.
- âeinsum_aij_bji_to_ab_jaxâ:
Use jnp.einsum(âaij,bji->abâ, rho_m_list, rho_m_list) to calculate the trace.
alias of
Literal
[âtrace_of_matmulâ, âquick_trace_of_matmulâ, âeinsum_ij_jiâ] |str
|Literal
[âeinsum_aij_bji_to_ab_numpyâ, âeinsum_aij_bji_to_ab_jaxâ]
- qurry.process.classical_shadow.trace_expect_process.mean_rho_core(rho_m_list: list[ndarray[tuple[int, int], dtype[complex128]]], selected_classical_registers_sorted: list[int]) ndarray[tuple[int, int], dtype[complex128]] [source]¶
Calculate the expectation value of Rho.
- Parameters:
- Returns:
The expectation value of Rho.
- Return type:
- qurry.process.classical_shadow.trace_expect_process.trace_rho_square_core(rho_m_list: list[ndarray[tuple[int, int], dtype[complex128]]], trace_method: Literal['trace_of_matmul', 'quick_trace_of_matmul', 'einsum_ij_ji'] | str | Literal['einsum_aij_bji_to_ab_numpy', 'einsum_aij_bji_to_ab_jax'] = 'einsum_aij_bji_to_ab_jax') complex128 [source]¶
Calculate the trace of Rho square.
- Reference:
Note
Predicting many properties of a quantum system from very few measurements -
Huang, Hsin-Yuan and Kueng, Richard and Preskill, John [doi:10.1038/s41567-020-0932-7](
The randomized measurement toolbox -
Elben, Andreas and Flammia, Steven T. and Huang, Hsin-Yuan and Kueng, Richard and Preskill, John and Vermersch, BenoĂźt and Zoller, Peter [doi:10.1038/s42254-022-00535-2](
- Parameters:
rho_m_list (list[np.ndarray[tuple[int, int], np.dtype[np.complex128]]]) â The dictionary of Rho M.
trace_method (TraceMethod , optional) â
The method to calculate the trace of Rho square. - âtrace_of_matmulâ:
Use np.trace(np.matmul(rho_m1, rho_m2)) to calculate the each summation item in rho_m_list.
- âquick_trace_of_matmulâ or âeinsum_ij_jiâ:
Use np.einsum(âij,jiâ, rho_m1, rho_m2) to calculate the each summation item in rho_m_list.
- âeinsum_aij_bji_to_ab_numpyâ:
Use np.einsum(âaij,bji->abâ, rho_m_list, rho_m_list) to calculate the trace.
- âeinsum_aij_bji_to_ab_jaxâ:
Use jnp.einsum(âaij,bji->abâ, rho_m_list, rho_m_list) to calculate the trace.
- Returns:
The trace of Rho square.
- Return type:
np.complex128