SwapGate

Function SwapGate 

Source
pub fn SwapGate(radix: usize) -> UnitaryExpression
Expand description

The qudit swap gate. This is a two-qudit Clifford/Weyl-Heisenberg gate that swaps the state of two qudits.

The qubit (radix = 2) version is given by the following matrix:

$$ \begin{pmatrix} 1 & 0 & 0 & 0 \\ 0 & 0 & 1 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & 0 & 1 \\ \end{pmatrix} $$

The qutrit (radix = 3) version is given by the following matrix:

$$ \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} $$

However, generally it is given by the following formula:

$$ SWAP_d = \sum_{a, b} \ket{ab}\bra{ba} $$

where $d$ is the number of levels (2 levels is a qubit, 3 levels is a qutrit, etc.)

References: