Skip to content

Commit

Permalink
typing
Browse files Browse the repository at this point in the history
  • Loading branch information
renatomello committed Sep 23, 2024
1 parent a0f5ea9 commit b883f0e
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/qibo/quantum_info/linalg_operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,9 @@ def anticommutator(operator_1, operator_2):
return operator_1 @ operator_2 + operator_2 @ operator_1


def partial_trace(state, traced_qubits: Union[List[int], Tuple[int]], backend=None):
def partial_trace(
state, traced_qubits: Union[List[int], Tuple[int, ...]], backend=None
):
"""Returns the density matrix resulting from tracing out ``traced_qubits`` from ``state``.
Total number of qubits is inferred by the shape of ``state``.
Expand Down Expand Up @@ -159,15 +161,17 @@ def partial_trace(state, traced_qubits: Union[List[int], Tuple[int]], backend=No
return backend.np.einsum("abac->bc", state)


def partial_transpose(state, partition, backend=None):
def partial_transpose(
state, partition: Union[List[int], Tuple[int, ...]], backend=None
):
"""Return matrix resulting from the partial transposition of ``partition`` qubits in ``state``.
Given quantum state :math:`\\rho \\in \\mathcal{H}_{A} \\otimes \\mathcal{H}_{B}`,
the partial transpose with respect to ``partition`` :math:`B` is given by
.. math::
\\begin{align}
\\rho^{T_{B}} &= \\sum_{jklm} \\, \\rho_{lm}^{jk} \\, \\ketbra{j}{k} \\otimes \\ketbra{l}{m}^{T} \\\\
\\rho^{T_{B}} &= \\sum_{jklm} \\, \\rho_{lm}^{jk} \\, \\ketbra{j}{k} \\otimes \\left(\\ketbra{l}{m}\\right)^{T} \\\\
&= \\sum_{jklm} \\, \\rho_{lm}^{jk} \\, \\ketbra{j}{k} \\otimes \\ketbra{m}{l} \\\\
&= \\sum_{jklm} \\, \\rho_{lm}^{kl} \\, \\ketbra{j}{k} \\otimes \\ketbra{l}{m} \\, ,
\\end{align}
Expand Down

0 comments on commit b883f0e

Please sign in to comment.