SwapOperator

SwapOperator is a function that returns a unitary operator that swaps two subsystems. The unitary can be chosen to be full or sparse.

Syntax

 * S = SwapOperator(DIM)
 * S = SwapOperator(DIM,SP)

Argument descriptions

 * DIM: A specification of the dimensions of the subsystems that S will act on. DIM can be provided in one of two ways:
 * If DIM is a scalar, then both subsystems are assumed to have dimension DIM.
 * If the subsystems have unequal dimensions, DIM</tt> should be a 1-by-2 vector containing their dimensions.
 * SP</tt> (optional, default 0): If set equal to 1, the swap operator is sparse. If equal to 0, the swap operator is full.

The standard swap operator
The following code produces the operator that swaps two qubits: