qat.quops.math_util.partial_trace

qat.quops.math_util.partial_trace(M, dims, axis1=1, axis2=3, traced_out_subspaces=None)

Perform partial trace of a matrix

We assume \(M\) is a tensor product of square matrices:

\[M = A_1 \otimes A_2 \otimes \ldots \otimes A_n\]

where \(A_i\) is a matrix of size \(d_i \times d_i\).

The partial trace over dimensions \(\{i_1, \ldots, i_m\}\) is defined as:

\[Tr_{i_1, \ldots, i_m}(M) = Tr(A_{i_1}) \ldots Tr(A_{i_m}) A_{j_1} \otimes \ldots \otimes A_{j_{n-m}}\]

where \(\{j_1, \ldots, j_{n-m}\}\) is the list of indices \(\{1, \ldots, n\}\) from which we removed \(\{i_1, \ldots, i_m\}\).

Parameters
  • M (np.ndarray) – the matrix \(M\) to be traced on

  • dims (list) – dimensions of the subspaces \(\{d_1, \ldots, d_n\}\)

  • traced_out_subspaces (list) – indices of the traced out subspaces \(\{i_1, \ldots, i_m\}\)