perms.permutation_operator

Permutation operator is a unitary operator that permutes subsystems.

Functions

permutation_operator(dim, perm[, inv_perm, is_sparse])

Produce a unitary operator that permutes subsystems.

Module Contents

perms.permutation_operator.permutation_operator(dim, perm, inv_perm=False, is_sparse=False)

Produce a unitary operator that permutes subsystems.

Generates a unitary operator that permutes the order of subsystems according to the permutation vector perm, where the \(i^{th}\) subsystem has dimension dim[i].

If inv_perm = True, it implements the inverse permutation of perm. The permutation operator return is full is is_sparse is False and sparse if is_sparse is True.

Examples

The permutation operator obtained with dimension \(d = 2\) is equivalent to the standard swap operator on two qubits

\[\begin{split}P_{2, [1, 0]} = \begin{pmatrix} 1 & 0 & 0 & 0 \\ 0 & 0 & 1 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & 0 & 1 \end{pmatrix}\end{split}\]

Using toqito, this can be achieved in the following manner.

>>> from toqito.perms import permutation_operator
>>> permutation_operator(2, [1, 0])
array([[1., 0., 0., 0.],
       [0., 0., 1., 0.],
       [0., 1., 0., 0.],
       [0., 0., 0., 1.]])
Parameters:
  • dim (list[int] | int) – The dimensions of the subsystems to be permuted.

  • perm (list[int]) – A permutation vector.

  • inv_perm (bool) – Boolean dictating if perm is inverse or not.

  • is_sparse (bool) – Boolean indicating if return is sparse or not.

Returns:

Permutation operator of dimension dim.

Return type:

numpy.ndarray