toqito.channel_ops.apply_channel ================================ .. py:module:: toqito.channel_ops.apply_channel .. autoapi-nested-parse:: Applies a quantum channel to an operator. Module Contents --------------- .. py:function:: apply_channel(mat, phi_op) Apply a quantum channel to an operator. (Section: Representations and Characterizations of Channels of [@Watrous_2018_TQI]). Specifically, an application of the channel is defined as \[ \Phi(X) = \text{Tr}_{\mathcal{X}} \left(J(\Phi) \left(\mathbb{I}_{\mathcal{Y}} \otimes X^{T}\right)\right), \] where \[ J(\Phi): \text{T}(\mathcal{X}, \mathcal{Y}) \rightarrow \text{L}(\mathcal{Y} \otimes \mathcal{X}) \] is the Choi representation of \(\Phi\). We assume the quantum channel given as `phi_op` is provided as either the Choi matrix of the channel or a set of Kraus operators that define the quantum channel. This function is adapted from the QETLAB package. .. rubric:: Examples The swap operator is the Choi matrix of the transpose map. The following is a (non-ideal, but illustrative) way of computing the transpose of a matrix. Consider the following matrix \[ X = \begin{pmatrix} 1 & 4 & 7 \\ 2 & 5 & 8 \\ 3 & 6 & 9 \end{pmatrix} \] Applying the swap operator given as \[ \Phi = \begin{pmatrix} 1 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & 1 & 0 & 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & 0 & 0 & 0 & 1 & 0 & 0 \\ 0 & 1 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & 0 & 1 & 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & 0 & 0 & 0 & 0 & 1 & 0 \\ 0 & 0 & 1 & 0 & 0 & 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & 0 & 0 & 1 & 0 & 0 & 0 \\ 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 1 \end{pmatrix} \] to the matrix \(X\), we have the resulting matrix of \[ \Phi(X) = \begin{pmatrix} 1 & 2 & 3 \\ 4 & 5 & 6 \\ 7 & 8 & 9 \end{pmatrix} \] Using `|toqito⟩`, we can obtain the above matrices as follows. ```python exec="1" source="above" from toqito.channel_ops import apply_channel from toqito.perms import swap_operator import numpy as np test_input_mat = np.array([[1, 4, 7], [2, 5, 8], [3, 6, 9]]) print(apply_channel(test_input_mat, swap_operator(3))) ``` :raises ValueError: If matrix is not Choi matrix. :param mat: A matrix. :param phi_op: A superoperator. `phi_op` should be provided either as a Choi matrix, or as a list of numpy arrays with :param either 1 or 2 columns whose entries are its Kraus operators.: :returns: The result of applying the superoperator `phi_op` to the operator `mat`.