perms.swap_operator
Swap operator.
Module Contents
Functions
|
Produce a unitary operator that swaps two subsystems. |
- perms.swap_operator.swap_operator(dim, is_sparse=False)
Produce a unitary operator that swaps two subsystems.
Provides the unitary operator that swaps two copies of
dim-dimensional space. If the two subsystems are not of the same dimension,dimshould be a 1-by-2 vector containing the dimension of the subsystems.Examples
The \(2\)-dimensional swap operator is given by the following matrix
\[\begin{split}X_2 = \begin{pmatrix} 1 & 0 & 0 & 0 \\ 0 & 0 & 1 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & 0 & 1 \end{pmatrix}\end{split}\]Using
toqitowe can obtain this matrix as follows.>>> from toqito.perms import swap_operator >>> swap_operator(2) [[1., 0., 0., 0.], [0., 0., 1., 0.], [0., 1., 0., 0.], [0., 0., 0., 1.]]
The \(3\)-dimensional operator may be obtained using
toqitoas follows.>>> from toqito.perms import swap_operator >>> swap_operator(3) [[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.]]
- Parameters:
dim (list[int] | int) – The dimensions of the subsystems.
is_sparse (bool) – Sparse if
Trueand non-sparse ifFalse.
- Returns:
The swap operator of dimension
dim.- Return type:
numpy.ndarray