Skip to content

Qutrit Gates API Reference

This page documents the qutrit gates available in the skq.gates.qutrit module. Qutrits are quantum systems with 3 basis states (|0⟩, |1⟩, |2⟩) and can model spin-1 particles like photons and gluons.

Qutrit Gate Base Class

The QutritGate class serves as the foundation for all qutrit-based quantum gates in SKQ.

skq.gates.qutrit.base.QutritGate

Bases: BaseGate

Base class for Qutrit gates. These are quantum systems with a basis of 3 states. |0>, |1>, |2>. Models spin-1 particles like photons and gluons.

Source code in src/skq/gates/qutrit/base.py
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
class QutritGate(BaseGate):
    """
    Base class for Qutrit gates.
    These are quantum systems with a basis of 3 states. |0>, |1>, |2>.
    Models spin-1 particles like photons and gluons.
    """

    def __new__(cls, input_array: np.array):
        obj = super().__new__(cls, input_array)
        assert obj.is_at_least_nxn(n=3), "Gate must be at least a 3x3 matrix"
        assert obj.is_power_of_n_shape(n=3), "Gate shape must be a power of 3"
        return obj

    def num_qutrits(self) -> int:
        """Return the number of qutrits involved in the gate."""
        return int(np.log(self.shape[0]) / np.log(3))

    def is_multi_qutrit(self) -> bool:
        """Check if the gate involves multiple qutrits."""
        return self.num_qutrits() > 1

    def qutrit_to_qubit(self) -> CustomQubitGate:
        """
        Convert the qutrit gate to an equivalent qubit gate.
        :return: CustomQubitGate object
        """
        num_qutrits = self.num_qutrits()
        dim_qutrit = 3**num_qutrits
        num_qubits = int(np.ceil(num_qutrits * np.log2(3)))
        dim_qubit = 2**num_qubits
        qubit_gate = np.eye(dim_qubit, dtype=complex)
        qubit_gate[:dim_qutrit, :dim_qutrit] = self
        return CustomQubitGate(qubit_gate)

    def to_qiskit(self) -> qiskit.circuit.library.UnitaryGate:
        """
        Convert Qutrit gate to a Qiskit Gate object.
        Qiskit only supports qubit gates, so we convert the qutrit gate to a qubit gate first.
        :return: Qiskit UnitaryGate object
        """
        qubit_gate = self.qutrit_to_qubit()
        return qubit_gate.to_qiskit()

    def to_pennylane(self, wires: list[int] | int = None, qutrit_gate=False) -> qml.QubitUnitary | qml.QutritUnitary:
        """
        Convert gate to a PennyLane QubitUnitary.
        PennyLane only supports qubit gates, so we convert the qutrit gate to a qubit gate first.
        :param wires: List of wires the gate acts on
        :param qutrit_gate: If True, return a QutritUnitary gate instead of a qubit gate
        :return:
        If qutrit_gate is True, return a PennyLane QutritUnitary object.
        If qutrit_gate is False, return a PennyLane QubitUnitary object.
        """
        if qutrit_gate:
            return qml.QutritUnitary(self, wires=wires)
        else:
            return self.qutrit_to_qubit().to_pennylane(wires=wires)

is_multi_qutrit()

Check if the gate involves multiple qutrits.

Source code in src/skq/gates/qutrit/base.py
26
27
28
def is_multi_qutrit(self) -> bool:
    """Check if the gate involves multiple qutrits."""
    return self.num_qutrits() > 1

num_qutrits()

Return the number of qutrits involved in the gate.

Source code in src/skq/gates/qutrit/base.py
22
23
24
def num_qutrits(self) -> int:
    """Return the number of qutrits involved in the gate."""
    return int(np.log(self.shape[0]) / np.log(3))

qutrit_to_qubit()

Convert the qutrit gate to an equivalent qubit gate. :return: CustomQubitGate object

Source code in src/skq/gates/qutrit/base.py
30
31
32
33
34
35
36
37
38
39
40
41
def qutrit_to_qubit(self) -> CustomQubitGate:
    """
    Convert the qutrit gate to an equivalent qubit gate.
    :return: CustomQubitGate object
    """
    num_qutrits = self.num_qutrits()
    dim_qutrit = 3**num_qutrits
    num_qubits = int(np.ceil(num_qutrits * np.log2(3)))
    dim_qubit = 2**num_qubits
    qubit_gate = np.eye(dim_qubit, dtype=complex)
    qubit_gate[:dim_qutrit, :dim_qutrit] = self
    return CustomQubitGate(qubit_gate)

to_pennylane(wires=None, qutrit_gate=False)

Convert gate to a PennyLane QubitUnitary. PennyLane only supports qubit gates, so we convert the qutrit gate to a qubit gate first. :param wires: List of wires the gate acts on :param qutrit_gate: If True, return a QutritUnitary gate instead of a qubit gate :return: If qutrit_gate is True, return a PennyLane QutritUnitary object. If qutrit_gate is False, return a PennyLane QubitUnitary object.

Source code in src/skq/gates/qutrit/base.py
52
53
54
55
56
57
58
59
60
61
62
63
64
65
def to_pennylane(self, wires: list[int] | int = None, qutrit_gate=False) -> qml.QubitUnitary | qml.QutritUnitary:
    """
    Convert gate to a PennyLane QubitUnitary.
    PennyLane only supports qubit gates, so we convert the qutrit gate to a qubit gate first.
    :param wires: List of wires the gate acts on
    :param qutrit_gate: If True, return a QutritUnitary gate instead of a qubit gate
    :return:
    If qutrit_gate is True, return a PennyLane QutritUnitary object.
    If qutrit_gate is False, return a PennyLane QubitUnitary object.
    """
    if qutrit_gate:
        return qml.QutritUnitary(self, wires=wires)
    else:
        return self.qutrit_to_qubit().to_pennylane(wires=wires)

to_qiskit()

Convert Qutrit gate to a Qiskit Gate object. Qiskit only supports qubit gates, so we convert the qutrit gate to a qubit gate first. :return: Qiskit UnitaryGate object

Source code in src/skq/gates/qutrit/base.py
43
44
45
46
47
48
49
50
def to_qiskit(self) -> qiskit.circuit.library.UnitaryGate:
    """
    Convert Qutrit gate to a Qiskit Gate object.
    Qiskit only supports qubit gates, so we convert the qutrit gate to a qubit gate first.
    :return: Qiskit UnitaryGate object
    """
    qubit_gate = self.qutrit_to_qubit()
    return qubit_gate.to_qiskit()

Single-Qutrit Gates

Identity Gate (QutritI)

The Identity gate leaves the qutrit state unchanged.

Matrix Representation:

\[ \text{QutritI} = \begin{pmatrix} 1 & 0 & 0 \\ 0 & 1 & 0 \\ 0 & 0 & 1 \end{pmatrix} \]

skq.gates.qutrit.single.QutritI

Bases: QutritGate

Identity gate for a qutrit. [[1, 0, 0][0, 1, 0] [0, 0, 1]]

Source code in src/skq/gates/qutrit/single.py
 6
 7
 8
 9
10
11
12
13
14
15
class QutritI(QutritGate):
    """
    Identity gate for a qutrit.
    [[1, 0, 0]
    [0, 1, 0]
    [0, 0, 1]]
    """

    def __new__(cls):
        return super().__new__(cls, np.eye(3))

X Gate (QutritX)

The X gate for a qutrit performs a cyclic permutation of the basis states: |0⟩ → |1⟩ → |2⟩ → |0⟩.

Matrix Representation:

\[ \text{QutritX} = \begin{pmatrix} 0 & 0 & 1 \\ 1 & 0 & 0 \\ 0 & 1 & 0 \end{pmatrix} \]

skq.gates.qutrit.single.QutritX

Bases: QutritGate

X gate for a qutrit. |0> -> |1> |1> -> |2> |2> -> |0>

Source code in src/skq/gates/qutrit/single.py
18
19
20
21
22
23
24
25
26
27
class QutritX(QutritGate):
    """
    X gate for a qutrit.
    |0> -> |1>
    |1> -> |2>
    |2> -> |0>
    """

    def __new__(cls):
        return super().__new__(cls, np.array([[0, 0, 1], [1, 0, 0], [0, 1, 0]]))

Y Gate (QutritY)

The Y gate for a qutrit performs a cyclic permutation with phase: |0⟩ → -i|1⟩ → -i|2⟩ → -i|0⟩.

Matrix Representation:

\[ \text{QutritY} = \begin{pmatrix} 0 & 0 & -i \\ -i & 0 & 0 \\ 0 & -i & 0 \end{pmatrix} \]

skq.gates.qutrit.single.QutritY

Bases: QutritGate

Y gate for a qutrit. |0> -> -i|1> |1> -> -i|2> |2> -> -i|0>

Source code in src/skq/gates/qutrit/single.py
30
31
32
33
34
35
36
37
38
39
class QutritY(QutritGate):
    """
    Y gate for a qutrit.
    |0> -> -i|1>
    |1> -> -i|2>
    |2> -> -i|0>
    """

    def __new__(cls):
        return super().__new__(cls, np.array([[0, 0, -1j], [-1j, 0, 0], [0, -1j, 0]]))

Z Gate (QutritZ)

The Z gate for a qutrit applies different phases to each basis state.

Matrix Representation:

\[ \text{QutritZ} = \begin{pmatrix} 1 & 0 & 0 \\ 0 & e^{2\pi i/3} & 0 \\ 0 & 0 & e^{-2\pi i/3} \end{pmatrix} \]

skq.gates.qutrit.single.QutritZ

Bases: QutritGate

Z gate for a qutrit. |0> -> |0> |1> -> exp(2pii/3)|1> |2> -> exp(-2pii/3)|2>

Source code in src/skq/gates/qutrit/single.py
42
43
44
45
46
47
48
49
50
51
class QutritZ(QutritGate):
    """
    Z gate for a qutrit.
    |0> -> |0>
    |1> -> exp(2*pi*i/3)|1>
    |2> -> exp(-2*pi*i/3)|2>
    """

    def __new__(cls):
        return super().__new__(cls, np.array([[1, 0, 0], [0, np.exp(2 * np.pi * 1j / 3), 0], [0, 0, np.exp(-2 * np.pi * 1j / 3)]]))

Hadamard Gate (QutritH)

The Hadamard gate for a qutrit creates a superposition of the three basis states.

Matrix Representation:

\[ \text{QutritH} = \frac{1}{\sqrt{3}} \begin{pmatrix} 1 & 1 & 1 \\ 1 & e^{2\pi i/3} & e^{4\pi i/3} \\ 1 & e^{4\pi i/3} & e^{2\pi i/3} \end{pmatrix} \]

Where \(e^{2\pi i/3}\) is the cube root of unity.

skq.gates.qutrit.single.QutritH

Bases: QutritGate

Hadamard gate for a qutrit. |0> -> (|0> + |1> + |2>)/sqrt(3) |1> -> (|0> + e^(2πi/3)|1> + e^(4πi/3)|2>)/sqrt(3) |2> -> (|0> + e^(4πi/3)|1> + e^(2πi/3)|2>)/sqrt(3)

Source code in src/skq/gates/qutrit/single.py
54
55
56
57
58
59
60
61
62
63
64
class QutritH(QutritGate):
    """
    Hadamard gate for a qutrit.
    |0> -> (|0> + |1> + |2>)/sqrt(3)
    |1> -> (|0> + e^(2πi/3)|1> + e^(4πi/3)|2>)/sqrt(3)
    |2> -> (|0> + e^(4πi/3)|1> + e^(2πi/3)|2>)/sqrt(3)
    """

    def __new__(cls):
        omega = np.exp(2j * np.pi / 3)
        return super().__new__(cls, np.array([[1, 1, 1], [1, omega, omega**2], [1, omega**2, omega]]) / np.sqrt(3))

T Gate (QutritT)

The T gate for a qutrit applies smaller phase shifts than the Z gate.

Matrix Representation:

\[ \text{QutritT} = \begin{pmatrix} 1 & 0 & 0 \\ 0 & e^{2\pi i/9} & 0 \\ 0 & 0 & e^{-2\pi i/9} \end{pmatrix} \]

skq.gates.qutrit.single.QutritT

Bases: QutritGate

T gate for a qutrit. |0> -> |0> |1> -> exp(2pii/9)|1> |2> -> exp(-2pii/9)|2>

Source code in src/skq/gates/qutrit/single.py
67
68
69
70
71
72
73
74
75
76
class QutritT(QutritGate):
    """
    T gate for a qutrit.
    |0> -> |0>
    |1> -> exp(2*pi*i/9)|1>
    |2> -> exp(-2*pi*i/9)|2>
    """

    def __new__(cls):
        return super().__new__(cls, np.array([[1, 0, 0], [0, np.exp(2 * np.pi * 1j / 9), 0], [0, 0, np.exp(-2 * np.pi * 1j / 9)]]))

R Gate (QutritR)

The R gate for a qutrit is a non-Clifford gate that applies a phase flip to the |2⟩ state.

Matrix Representation:

\[ \text{QutritR} = \begin{pmatrix} 1 & 0 & 0 \\ 0 & 1 & 0 \\ 0 & 0 & -1 \end{pmatrix} \]

skq.gates.qutrit.single.QutritR

Bases: QutritGate

R gate for a qutrit (non-Clifford gate).

Source code in src/skq/gates/qutrit/single.py
79
80
81
82
83
class QutritR(QutritGate):
    """R gate for a qutrit (non-Clifford gate)."""

    def __new__(cls):
        return super().__new__(cls, np.array([[1, 0, 0], [0, 1, 0], [0, 0, -1]]))

Phase Gate (QutritPhase)

The general Phase gate for qutrits applies arbitrary phase shifts to each basis state.

Matrix Representation:

\[ \text{QutritPhase}(\phi_0,\phi_1,\phi_2) = \begin{pmatrix} e^{i\phi_0} & 0 & 0 \\ 0 & e^{i\phi_1} & 0 \\ 0 & 0 & e^{i\phi_2} \end{pmatrix} \]

skq.gates.qutrit.single.QutritPhase

Bases: QutritGate

General phase gate for qutrits. Applies phase shifts to the qutrit basis states.

Source code in src/skq/gates/qutrit/single.py
86
87
88
89
90
91
92
93
class QutritPhase(QutritGate):
    """
    General phase gate for qutrits.
    Applies phase shifts to the qutrit basis states.
    """

    def __new__(cls, phi_0: float, phi_1: float, phi_2: float):
        return super().__new__(cls, np.array([[np.exp(1j * phi_0), 0, 0], [0, np.exp(1j * phi_1), 0], [0, 0, np.exp(1j * phi_2)]]))

S Gate (QutritS)

The S gate for qutrits is a special case of the Phase gate.

Matrix Representation:

\[ \text{QutritS} = \begin{pmatrix} 1 & 0 & 0 \\ 0 & e^{2\pi i/3} & 0 \\ 0 & 0 & e^{4\pi i/3} \end{pmatrix} \]

skq.gates.qutrit.single.QutritS

Bases: QutritPhase

S gate for qutrits. |0> -> |0> |1> -> exp(2pii/3)|1> |2> -> exp(4pii/3)|2>

Source code in src/skq/gates/qutrit/single.py
 96
 97
 98
 99
100
101
102
103
104
105
class QutritS(QutritPhase):
    """
    S gate for qutrits.
    |0> -> |0>
    |1> -> exp(2*pi*i/3)|1>
    |2> -> exp(4*pi*i/3)|2>
    """

    def __new__(cls):
        return super().__new__(cls, phi_0=0, phi_1=2 * np.pi / 3, phi_2=4 * np.pi / 3)

Multi-Qutrit Gates

Multi-Qutrit Identity (QutritMI)

The Identity gate for multiple qutrits.

Matrix Representation (for 1 qutrit):

\[ \text{QutritMI} = \begin{pmatrix} 1 & 0 & 0 \\ 0 & 1 & 0 \\ 0 & 0 & 1 \end{pmatrix} \]

skq.gates.qutrit.multi.QutritMI

Bases: QutritGate

Multi-qutrit Identity gate. :param num_qutrits: Number of qutrits in the gate.

Source code in src/skq/gates/qutrit/multi.py
 6
 7
 8
 9
10
11
12
13
14
class QutritMI(QutritGate):
    """
    Multi-qutrit Identity gate.
    :param num_qutrits: Number of qutrits in the gate.
    """

    def __new__(cls, num_qutrits: int):
        assert num_qutrits >= 1, "Number of qutrits must be at least 1."
        return super().__new__(cls, np.eye(3**num_qutrits))

Controlled-X Type A (QutritCXA)

The CNOT gate for qutrits with control on |1⟩. This gate performs a cyclic permutation on the target qutrit if the control qutrit is in state |1⟩.

Matrix Representation (9×9 matrix):

\[ \text{QutritCXA} = \begin{pmatrix} 1 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\ 0 & 0 & 1 & 0 & 0 & 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & 0 & 0 & 0 & 0 & 1 & 0 \\ 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 1 \\ 0 & 0 & 0 & 0 & 0 & 0 & 1 & 0 & 0 \\ 0 & 0 & 0 & 0 & 1 & 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & 0 & 0 & 1 & 0 & 0 & 0 \\ 0 & 0 & 0 & 1 & 0 & 0 & 0 & 0 & 0 \end{pmatrix} \]

skq.gates.qutrit.multi.QutritCXA

Bases: QutritGate

CNOT gate for qutrits. More information on Qutrit CNOT: https://www.iosrjournals.org/iosr-jap/papers/Vol10-issue6/Version-2/D1006021619.pdf Control on |1>

Source code in src/skq/gates/qutrit/multi.py
17
18
19
20
21
22
23
24
25
26
27
class QutritCXA(QutritGate):
    """
    CNOT gate for qutrits.
    More information on Qutrit CNOT: https://www.iosrjournals.org/iosr-jap/papers/Vol10-issue6/Version-2/D1006021619.pdf
    Control on |1>
    """

    def __new__(cls):
        return super().__new__(
            cls, np.array([[1, 0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 1], [0, 0, 0, 0, 0, 0, 1, 0, 0], [0, 0, 0, 0, 1, 0, 0, 0, 0], [0, 0, 0, 0, 0, 1, 0, 0, 0], [0, 0, 0, 1, 0, 0, 0, 0, 0]])
        )

Controlled-X Type B (QutritCXB)

The CNOT gate for qutrits with control on |2⟩. This gate performs a cyclic permutation on the target qutrit if the control qutrit is in state |2⟩.

Matrix Representation (9×9 matrix):

\[ \text{QutritCXB} = \begin{pmatrix} 1 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\ 0 & 0 & 1 & 0 & 0 & 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 1 \\ 0 & 0 & 0 & 0 & 0 & 0 & 1 & 0 & 0 \\ 0 & 0 & 0 & 0 & 0 & 0 & 0 & 1 & 0 \\ 0 & 0 & 0 & 0 & 0 & 1 & 0 & 0 & 0 \\ 0 & 0 & 0 & 1 & 0 & 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & 0 & 1 & 0 & 0 & 0 & 0 \end{pmatrix} \]

skq.gates.qutrit.multi.QutritCXB

Bases: QutritGate

CNOT gate for qutrits. More information on Qutrit CNOT: https://www.iosrjournals.org/iosr-jap/papers/Vol10-issue6/Version-2/D1006021619.pdf Control on |2>

Source code in src/skq/gates/qutrit/multi.py
30
31
32
33
34
35
36
37
38
39
40
class QutritCXB(QutritGate):
    """
    CNOT gate for qutrits.
    More information on Qutrit CNOT: https://www.iosrjournals.org/iosr-jap/papers/Vol10-issue6/Version-2/D1006021619.pdf
    Control on |2>
    """

    def __new__(cls):
        return super().__new__(
            cls, np.array([[1, 0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 1], [0, 0, 0, 0, 0, 0, 1, 0, 0], [0, 0, 0, 0, 0, 0, 0, 1, 0], [0, 0, 0, 0, 0, 1, 0, 0, 0], [0, 0, 0, 1, 0, 0, 0, 0, 0], [0, 0, 0, 0, 1, 0, 0, 0, 0]])
        )

Controlled-X Type C (QutritCXC)

The CNOT gate for qutrits with control on |0⟩. This gate performs a cyclic permutation on the target qutrit if the control qutrit is in state |0⟩.

Matrix Representation (9×9 matrix):

\[ \text{QutritCXC} = \begin{pmatrix} 1 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\ 0 & 0 & 1 & 0 & 0 & 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & 0 & 1 & 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & 0 & 0 & 1 & 0 & 0 & 0 \\ 0 & 0 & 0 & 1 & 0 & 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & 0 & 0 & 0 & 0 & 1 & 0 \\ 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 1 \\ 0 & 0 & 0 & 0 & 0 & 0 & 1 & 0 & 0 \end{pmatrix} \]

skq.gates.qutrit.multi.QutritCXC

Bases: QutritGate

CNOT gate for qutrits. More information on Qutrit CNOT: https://www.iosrjournals.org/iosr-jap/papers/Vol10-issue6/Version-2/D1006021619.pdf Control on |0>

Source code in src/skq/gates/qutrit/multi.py
43
44
45
46
47
48
49
50
51
52
53
class QutritCXC(QutritGate):
    """
    CNOT gate for qutrits.
    More information on Qutrit CNOT: https://www.iosrjournals.org/iosr-jap/papers/Vol10-issue6/Version-2/D1006021619.pdf
    Control on |0>
    """

    def __new__(cls):
        return super().__new__(
            cls, np.array([[1, 0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 1, 0, 0, 0, 0], [0, 0, 0, 0, 0, 1, 0, 0, 0], [0, 0, 0, 1, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 1], [0, 0, 0, 0, 0, 0, 1, 0, 0]])
        )

SWAP Gate (QutritSWAP)

The SWAP gate for qutrits exchanges the states of two qutrits.

Matrix Representation (9×9 matrix):

\[ \text{QutritSWAP} = \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} \]

skq.gates.qutrit.multi.QutritSWAP

Bases: QutritGate

SWAP gate for qutrits. |01> -> |10> |10> -> |01>

Source code in src/skq/gates/qutrit/multi.py
56
57
58
59
60
61
62
63
64
65
class QutritSWAP(QutritGate):
    """
    SWAP gate for qutrits.
    |01> -> |10>
    |10> -> |01>
    """

    def __new__(cls):
        swap_matrix = np.array([[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]])
        return super().__new__(cls, swap_matrix)