Skip to content

Ququart Gates API Reference

This page documents the ququart gates available in the skq.gates.ququart module. Ququarts are quantum systems with 4 basis states (|0⟩, |1⟩, |2⟩, |3⟩) and can model spin-3/2 particles.

Ququart Gate Base Class

The QuquartGate class serves as the foundation for all ququart-based quantum gates in SKQ.

skq.gates.ququart.base.QuquartGate

Bases: BaseGate

Base class for Ququart gates. These are quantum systems with a basis of 4 states. |0>, |1>, |2>, |3>. Models spin-1/2 particles like electrons.

Source code in src/skq/gates/ququart/base.py
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
class QuquartGate(BaseGate):
    """
    Base class for Ququart gates.
    These are quantum systems with a basis of 4 states. |0>, |1>, |2>, |3>.
    Models spin-1/2 particles like electrons.
    """

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

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

    def is_multi_qudit(self) -> bool:
        """Check if the gate involves multiple qudits."""
        return self.num_qudits() > 1

is_multi_qudit()

Check if the gate involves multiple qudits.

Source code in src/skq/gates/ququart/base.py
22
23
24
def is_multi_qudit(self) -> bool:
    """Check if the gate involves multiple qudits."""
    return self.num_qudits() > 1

num_qudits()

Return the number of qudits involved in the gate.

Source code in src/skq/gates/ququart/base.py
18
19
20
def num_qudits(self) -> int:
    """Return the number of qudits involved in the gate."""
    return int(np.log(self.shape[0]) / np.log(4))

Single-Ququart Gates

Identity Gate (QuquartI)

The Identity gate leaves the ququart state unchanged.

Matrix Representation:

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

skq.gates.ququart.single.QuquartI

Bases: QuquartGate

Identity gate for ququarts.

Source code in src/skq/gates/ququart/single.py
 6
 7
 8
 9
10
11
class QuquartI(QuquartGate):
    """Identity gate for ququarts."""

    def __new__(cls):
        obj = super().__new__(cls, np.eye(4))
        return obj

X Gate (QuquartX)

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

Matrix Representation:

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

skq.gates.ququart.single.QuquartX

Bases: QuquartGate

X gate for ququarts.

Source code in src/skq/gates/ququart/single.py
14
15
16
17
18
19
class QuquartX(QuquartGate):
    """X gate for ququarts."""

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

Z Gate (QuquartZ)

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

Matrix Representation:

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

skq.gates.ququart.single.QuquartZ

Bases: QuquartGate

Z gate for ququarts.

Source code in src/skq/gates/ququart/single.py
22
23
24
25
26
27
class QuquartZ(QuquartGate):
    """Z gate for ququarts."""

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

Hadamard Gate (QuquartH)

The Hadamard gate for a ququart creates a superposition of the four basis states with different phases.

Matrix Representation:

\[ \text{QuquartH} = \frac{1}{2} \begin{pmatrix} 1 & 1 & 1 & 1 \\ 1 & i & -1 & -i \\ 1 & -1 & 1 & -1 \\ 1 & -i & -1 & i \end{pmatrix} \]

skq.gates.ququart.single.QuquartH

Bases: QuquartGate

Hadamard gate for ququarts.

Source code in src/skq/gates/ququart/single.py
30
31
32
33
34
35
class QuquartH(QuquartGate):
    """Hadamard gate for ququarts."""

    def __new__(cls):
        obj = super().__new__(cls, np.array([[1, 1, 1, 1], [1, 1j, -1, -1j], [1, -1, 1, -1], [1, -1j, -1, 1j]]) / 2)
        return obj

T Gate (QuquartT)

The T gate for a ququart applies a phase shift to the |1⟩ state.

Matrix Representation:

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

skq.gates.ququart.single.QuquartT

Bases: QuquartGate

T gate for ququarts.

Source code in src/skq/gates/ququart/single.py
38
39
40
41
42
43
class QuquartT(QuquartGate):
    """T gate for ququarts."""

    def __new__(cls):
        obj = super().__new__(cls, np.diag([1, np.exp(1j * np.pi / 4), 1, 1]))
        return obj