Spin-½ Operators
This page details the specific operators available for spin-½ systems (qubits). These operators implement the general Operator interface described in the Operators concept guide.
Sites versus Support
All spin-½ operators possess at least one specific attribute: sites. It is crucial to distinguish this from the support of an operator.
- Sites: An ordered list of indices determining which qubits the operator targets when applied to a state. The order matters for operators that involve interactions (like
CNOT, where the first site is target and the second is control) or for mapping matrix elements to qubits. - Support: A set (unordered, unique) of indices representing the qubits involved in the operation.
For example, CNOT(1, 2) acting on sites 1 and 2 has sites = [1, 2] and support = {1, 2}.
var m = matrix([[0..4]], as_real)
CNOT(0, 1) * m // [[0, 1, 3, 2]]
CNOT(1, 0) * m // [[0, 3, 2, 1]]
Static Operators
Static operators are purely symbolic and require no numerical parameters, only the site indices they act upon. They represent common quantum gates and standard physics operators.
These are consistent in that they are lighter-weight objects defined entirely by their type and target sites.
| Factory Function | Sites (Min) | Description |
|---|---|---|
ID() | 0 | Identity operator (global) |
X(site) | 1 | Pauli-X |
Y(site) | 1 | Pauli-Y |
Z(site) | 1 | Pauli-Z |
SX(site) | 1 | Spin-X |
SY(site) | 1 | Spin-Y |
SZ(site) | 1 | Spin-Z |
Splus(site) | 1 | Raising operator |
Sminus(site) | 1 | Lowering operator |
Proj0(site) | 1 | Projector onto |
Proj1(site) | 1 | Projector onto |
Hgate(site) | 1 | Hadamard gate |
Sgate(site) | 1 | S gate ( gate, ) |
Tgate(site) | 1 | T gate () |
XX(site1, site2) | 2 | Ising interaction |
YY(site1, site2) | 2 | Ising interaction |
ZZ(site1, site2) | 2 | Ising interaction |
XXPYY(site1, site2) | 2 | Exchange interaction |
CNOT(control, target) | 2 | Controlled-NOT gate |
SWAP(site1, site2) | 2 | SWAP gate |
ZN(sites) | N () | Sum of local Z terms: |
ZZNN(sites) | N () | Nearest-neighbour ZZ sum: |
ZZNNN(sites) | N () | Next-nearest-neighbour ZZ sum: |
Parametrized Operators
Parametrized operators are characterized by one or more continuous variables (typically real numbers), representing angles, phases, or coupling constants.
These operators are consistent as they all carry floating-point parameters defining their action (e.g. rotation angles).
| Factory Function | Parameters | Sites | Description |
|---|---|---|---|
Phase(phi) | phi (real) | 0 | Global phase |
RotX(phi, site) | phi (real) | 1 | Rotation around X: |
RotY(phi, site) | phi (real) | 1 | Rotation around Y: |
RotZ(phi, site) | phi (real) | 1 | Rotation around Z: |
RotEuler(phi, theta, omega, site) | phi, theta, omega | 1 | |
UnitaryXYZ(Js, sites) | Js (vec3) | 2 | |
Floquet(Js, sites) | Js (vec3) | 2 | |
DualUnitary(J, sites) | J (real) | 2 |
Matrix Operators
Matrix operators are defined explicitly by their matrix elements. This category encompasses dense, sparse, and diagonal matrices.
These operators allow for arbitrary custom actions defined by the values in the matrix.
| Factory Function | Parameters | Description |
|---|---|---|
operator_dense(matrix, sites) | matrix, sites | Dense matrix operator. |
operator_sparse(matrix, sites) | matrix, sites | Sparse matrix operator. |
operator_diagonal(diag, sites) | diag, sites | Diagonal operator from vector. |
Permutation Operators
Permutation operators rearrange the basis states of the system rather than mixing them via complex arithmetic.
These operators are efficient and consistent in that they represent index shuffles or bitwise operations on the state.
| Factory Function | Parameters | Sites | Description |
|---|---|---|---|
Flip(site) | None | 1 | Flips spin at site. |
Flip(sites) | None | N | Flips spins at sites. |
FlipAll() | None | Global | Flips all spins. |
Reflect() | None | Global | Spatial reflection about center. |
Translate(shift) | shift (int) | Global | Spatial translation. |
Permute(p, sites) | p (vec), sites | N | Arbitrary permutation p on sites. |
Pauli Strings
Pauli strings construct operators from sequences of Pauli matrices.
Consistency: Defined by string literals representing the tensor product structure.
| Factory Function | Parameters | Description |
|---|---|---|
pauli_string(word, sites) | word (string), sites | e.g. "XZ" applies X to first site, Z to second. |
Generic Operators
Generic operators connect the high-level interface with user-defined low-level logic.
Consistency: Defined by a callback function f(matrix, indices) allowing arbitrary in-place modification.
| Factory Function | Parameters | Description |
|---|---|---|
operator_generic(func, sites) | func, sites | Applies func to state elements at sites. |