PermutationOperator

PermutationOperator is a function that returns a unitary operator that permutes two or more subsystems. The unitary can be chosen to be full or sparse.

Syntax

 * P = PermutationOperator(DIM,PERM)
 * P = PermutationOperator(DIM,PERM,INV_PERM)
 * P = PermutationOperator(DIM,PERM,INV_PERM,SP)

Argument descriptions

 * DIM: A specification of the dimensions of the subsystems that P will act on. DIM can be provided in one of two ways:
 * If DIM is a scalar, then all subsystems are assumed to have dimension DIM</tt>.
 * If the subsystems have unequal dimensions, DIM</tt> should be a vector containing their dimensions.
 * PERM</tt>: a permutation vector (i.e., a permutation of the vector 1:n</tt>)
 * INV_PERM</tt> (optional, default 0): If equal to 0, this argument has no effect. If equal to 1, the permutation operator permutes subsystems according to the inverse of PERM</tt> rather than PERM</tt> itself.
 * SP</tt> (optional, default 0): If set equal to 1, the permutation operator is sparse. If equal to 0, the permutation operator is full.

The standard swap operator
The following code produces the operator that swaps two qubits (note that for simple uses like this one, it may be easier to just use the SwapOperator</tt> function):

Similarly, the following code produces a sparse operator that swaps two qutrits: