Discrete Variable¶
DiscreteVariableState
¶
Bases: AbstractPureState
A pure quantum state for a discrete variable system.
\(|\psi\rangle = \sum_{i} a_i |i\rangle\) where \(a_i\) are amplitudes and \(|i\rangle\) are basis states.
Source code in src/squint/ops/dv.py
MaximallyMixedState
¶
Bases: AbstractMixedState
The maximally mixed state for discrete variable systems.
Represents the completely mixed density matrix \(\rho = I/d\) where \(d\) is the total Hilbert space dimension. This state has maximum von Neumann entropy and represents complete ignorance about the quantum state.
The density matrix is constructed as: \(\(\rho = \frac{1}{d} \sum_{i=0}^{d-1} |i\rangle\langle i|\)\)
where \(d = \prod_i d_i\) is the product of all wire dimensions.
Example
Note
This state requires the "mixed" backend in the circuit.
Source code in src/squint/ops/dv.py
XGate
¶
Bases: AbstractGate
The generalized shift operator, which when dim = 2 corresponds to the standard \(X\) gate.
\(U = \sum_{k=0}^{d-1} |k\rangle \langle (k+1) \mod d|\)
Source code in src/squint/ops/dv.py
ZGate
¶
Bases: AbstractGate
The generalized phase operator, which when dim = 2 corresponds to the standard \(Z\) gate.
\(U = \sum_{k=0}^{d-1} e^{2\pi i k / d} |k\rangle\langle k|\)
Source code in src/squint/ops/dv.py
HGate
¶
Bases: AbstractGate
The generalized discrete Fourier operator, which when dim = 2 corresponds to the standard \(H\) gate.
\(U = \frac{1}{\sqrt{d}} \sum_{j,k=0}^{d-1} e^{2\pi i jk / d} |j\rangle\langle k|\)
Source code in src/squint/ops/dv.py
Conditional
¶
Bases: AbstractGate
The generalized conditional operator. Applies gate \(U\) raised to a power conditional on the control state: \(U = \sum_{k=0}^{d-1} |k\rangle\langle k| \otimes U^k\)
Source code in src/squint/ops/dv.py
CXGate
¶
Bases: Conditional
Controlled-X (CNOT) gate for qubits and qudits.
Applies an X gate to the target qubit/qudit conditional on the control. For qubits (dim=2), this is the standard CNOT gate: \(\(CX = |0\rangle\langle 0| \otimes I + |1\rangle\langle 1| \otimes X\)\)
For qudits (dim>2), this generalizes to: \(\(CX = \sum_{k=0}^{d-1} |k\rangle\langle k| \otimes X^k\)\)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
wires
|
tuple[Wire, Wire]
|
Tuple of (control_wire, target_wire). |
(0, 1)
|
Example
Source code in src/squint/ops/dv.py
CZGate
¶
Bases: Conditional
Controlled-Z gate for qubits and qudits.
Applies a Z gate to the target qubit/qudit conditional on the control. For qubits (dim=2), this is the standard CZ gate: \(\(CZ = |0\rangle\langle 0| \otimes I + |1\rangle\langle 1| \otimes Z\)\)
For qudits (dim>2), this generalizes to: \(\(CZ = \sum_{k=0}^{d-1} |k\rangle\langle k| \otimes Z^k\)\)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
wires
|
tuple[Wire, Wire]
|
Tuple of (control_wire, target_wire). |
(0, 1)
|
Example
Source code in src/squint/ops/dv.py
RZGate
¶
Bases: AbstractGate
Rotation gate around the Z-axis for qubits and qudits.
For qubits (dim=2), this implements the standard RZ rotation: \(\(R_Z(\phi) = \begin{pmatrix} 1 & 0 \\ 0 & e^{i\phi} \end{pmatrix}\)\)
For qudits (dim>2), this generalizes to: \(\(R_Z(\phi) = \sum_{k=0}^{d-1} e^{ik\phi} |k\rangle\langle k|\)\)
Attributes:
| Name | Type | Description |
|---|---|---|
phi |
ArrayLike
|
The rotation angle in radians. |
Source code in src/squint/ops/dv.py
RXGate
¶
Bases: AbstractGate
Rotation gate around the X-axis for qubits.
Implements the standard RX rotation: \(\(R_X(\phi) = \cos(\phi/2) I - i \sin(\phi/2) X = \begin{pmatrix} \cos(\phi/2) & -i\sin(\phi/2) \\ -i\sin(\phi/2) & \cos(\phi/2) \end{pmatrix}\)\)
Attributes:
| Name | Type | Description |
|---|---|---|
phi |
ArrayLike
|
The rotation angle in radians. |
Note
This gate is only defined for qubits (dim=2).
Source code in src/squint/ops/dv.py
RYGate
¶
Bases: AbstractGate
Rotation gate around the Y-axis for qubits.
Implements the standard RY rotation: \(\(R_Y(\phi) = \cos(\phi/2) I - i \sin(\phi/2) Y = \begin{pmatrix} \cos(\phi/2) & -\sin(\phi/2) \\ \sin(\phi/2) & \cos(\phi/2) \end{pmatrix}\)\)
Attributes:
| Name | Type | Description |
|---|---|---|
phi |
ArrayLike
|
The rotation angle in radians. |
Note
This gate is only defined for qubits (dim=2).
Source code in src/squint/ops/dv.py
TwoLocalHermitianBasisGate
¶
Bases: AbstractGate
Two-qubit/qudit gate generated by a tensor product of Gell-Mann basis operators.
Implements gates of the form: \(\(U(\theta) = \exp(-i \theta \cdot G_i \otimes G_j)\)\)
where \(G_i\) and \(G_j\) are Gell-Mann basis operators (generalized Pauli matrices) acting on the first and second wire respectively. For qubits (dim=2), the Gell-Mann operators reduce to the Pauli matrices.
This is the base class for specific two-qubit interaction gates like RXXGate and RZZGate.
Attributes:
| Name | Type | Description |
|---|---|---|
angles |
ArrayLike
|
The rotation angle(s) in radians. |
_basis_op_indices |
tuple[int, int]
|
Indices of the Gell-Mann basis operators to use on each wire. For dim=2: 0=Z, 1=Y, 2=X, 3=I. |