SpinHalfOperator
Base class: Operator
Base class for spin-1/2 symbolic operators.
Operators
CNOT(integer site0, integer site1) -> SpinHalfOperator
Returns a spin-1/2 OperatorNamed for the CNOT (controlled-NOT) gate, taking two individual site indices.
Parameters
- site0: The control qubit site index.
- site1: The target qubit site index.
Example
var cnot1 = CNOT(0, 1)
DualUnitary(real J, integer i, integer j) -> SpinHalfOperator
Returns a spin-1/2 dual unitary operator: where are the site indices.
Parameters
- J: The Jz constant parameter.
- i: Site index i.
- j: Site index j.
Example
var dual_u = DualUnitary(0.25, 0, 1) // Dual unitary with Jz=0.25
Flip(integer site) -> SpinHalfOperator
Creates a spin-1/2 OperatorPermute that flips the spin at a single site.
Parameters
- site: The site index where the spin is flipped.
Flip(const List<integer> sites) -> SpinHalfOperator
Creates a spin-1/2 OperatorPermute that flips spins at specified sites.
Parameters
- sites: Vector of site indices where spins are flipped.
FlipAll() -> SpinHalfOperator
Creates a spin-1/2 OperatorPermute that flips all spins.
Floquet(const List<real> Js, integer i, integer j) -> SpinHalfOperator
Returns a spin-1/2 Floquet where are the site indices.
Parameters
- Js: Vector of exactly three parameters
[Jx, Jy, Jz]. - i: Site index i.
- j: Site index j.
Example
var flqt = Floquet([0.2, 0.3, 0.8], 1, 2) // Floquet operator
Hgate(integer site) -> SpinHalfOperator
Returns a spin-1/2 OperatorNamed for the Hadamard gate.
Parameters
- site: The site index where the operator acts (exactly 1 site required).
Example
var h0 = Hgate(0)
Permute(const List<integer> permutation, const List<integer> sites) -> SpinHalfOperator
Creates a spin-1/2 OperatorPermute that permutes spins according to a specified permutation.
Parameters
- permutation: Vector defining the permutation of spins (destination indices).
- sites: Vector of site indices where the permutation is applied.
Phase(real phi) -> SpinHalfOperator
Returns a global phase spin-1/2 operator .
Parameters
- phi: The phase angle.
Example
var ps = Phase(3.14159) // π phase
PhaseShift(real phi, integer site) -> SpinHalfOperator
Returns a spin-1/2 PhaseShift on the state.
Parameters
- phi: The rotation angle.
- site: The site index where the operator acts.
Example
var ps_half = PhaseShift(1.5708, 0)
Proj0(integer site) -> SpinHalfOperator
Returns a spin-1/2 OperatorNamed for the projector .
Parameters
- site: The site index where the operator acts (exactly 1 site required).
Example
var p0_op = Proj0(0)
Proj1(integer site) -> SpinHalfOperator
Returns a spin-1/2 OperatorNamed for the projector .
Parameters
- site: The site index where the operator acts (exactly 1 site required).
Example
var p1_op = Proj1(1)
Reflect() -> SpinHalfOperator
Creates a spin-1/2 OperatorPermute that reflects all spins about the center.
RotEuler(real phi, real theta, real omega, integer site) -> SpinHalfOperator
Returns a general spin-1/2 rotation operator RotEuler.
Parameters
- phi: The first rotation angle.
- theta: The second rotation angle.
- omega: The third rotation angle.
- site: The site index where the operator acts.
Example
var rot0 = RotEuler(1.57, 0.78, 3.14, 0) // General rotation on site 0
RotX(real phi, integer site) -> SpinHalfOperator
Returns a spin-1/2 RotX rotation operator around the X-axis.
Parameters
- phi: The rotation angle.
- site: The site index where the operator acts.
Example
var rx_half = RotX(1.5708, 0) // π/2 rotation on site 0
RotY(real phi, integer site) -> SpinHalfOperator
Returns a spin-1/2 RotY rotation operator around the Y-axis.
Parameters
- phi: The rotation angle.
- site: The site index where the operator acts.
Example
var ry_quarter = RotY(0.7854, 1) // π/4 rotation on site 1
RotZ(real phi, integer site) -> SpinHalfOperator
Returns a spin-1/2 RotZ rotation operator around the Z-axis.
Parameters
- phi: The rotation angle.
- site: The site index where the operator acts.
Example
var rz_full = RotZ(6.28318, 2) // 2π rotation on site 2
SWAP(integer site0, integer site1) -> SpinHalfOperator
Returns a spin-1/2 OperatorNamed for the SWAP gate, taking two individual site indices.
Parameters
- site0: The first site index.
- site1: The second site index.
Example
var swap1 = SWAP(0, 1)
Sgate(integer site) -> SpinHalfOperator
Returns a spin-1/2 OperatorNamed for the S gate.
Parameters
- site: The site index where the operator acts (exactly 1 site required).
Example
var s0 = Sgate(0)
Sminus(integer site) -> SpinHalfOperator
Returns a spin-1/2 OperatorNamed for Spin-minus operator.
Parameters
- site: The site index where the operator acts (exactly 1 site required).
Example
var sm1 = Sminus(1)
Splus(integer site) -> SpinHalfOperator
Returns a spin-1/2 OperatorNamed for Spin-plus operator.
Parameters
- site: The site index where the operator acts (exactly 1 site required).
Example
var sp0 = Splus(0)
Tgate(integer site) -> SpinHalfOperator
Returns a spin-1/2 OperatorNamed for the T gate.
Parameters
- site: The site index where the operator acts (exactly 1 site required).
Example
var t0 = Tgate(0)
Translate(integer shift) -> SpinHalfOperator
Creates a spin-1/2 OperatorPermute that translates spins by a specified shift.
Parameters
- shift: Number of sites by which the spins are shifted (default: 1).
UnitaryXYZ(const List<real> Js, integer i, integer j) -> SpinHalfOperator
Returns a spin-1/2 UnitaryXYZ operator: where are the site indices.
Parameters
- Js: Vector of exactly three parameters: [Jx, Jy, Jz].
- i: Site index i.
- j: Site index j.
Example
var xyz01 = UnitaryXYZ([0.5, 1.0, 1.5], 0, 1) // coupling between sites 0 and 1
X(integer site) -> SpinHalfOperator
Returns a spin-1/2 OperatorNamed for Pauli-X operator.
Parameters
- site: The site index where the operator acts (exactly 1 site required).
Example
var px0 = X(0)
XX(integer site0, integer site1) -> SpinHalfOperator
Returns a spin-1/2 OperatorNamed for operator, taking two individual site indices.
Parameters
- site0: The first site index ().
- site1: The second site index ().
Example
var pxx1 = XX(1, 2)
XXPYY(integer site0, integer site1) -> SpinHalfOperator
Returns a spin-1/2 OperatorNamed for operator, taking two individual site indices.
Parameters
- site0: The first site index.
- site1: The second site index.
Example
var xxpyy1 = XXPYY(0, 1)
Y(integer site) -> SpinHalfOperator
Returns a spin-1/2 OperatorNamed for Pauli-Y operator.
Parameters
- site: The site index where the operator acts (exactly 1 site required).
Example
var py1 = Y(1)
YY(integer site0, integer site1) -> SpinHalfOperator
Returns a spin-1/2 OperatorNamed for operator, taking two individual site indices.
Parameters
- site0: The first site index.
- site1: The second site index.
Example
var pyy1 = YY(0, 1)
Z(integer site) -> SpinHalfOperator
Returns a spin-1/2 OperatorNamed for Pauli-Z operator.
Parameters
- site: The site index where the operator acts (exactly 1 site required).
Example
var pz2 = Z(2)
ZN(const List<integer> sites) -> SpinHalfOperator
Returns a spin-1/2 OperatorNamed for operator.
Parameters
- sites: Vector of site indices where the operator acts (minimum 1 site).
Example
var zn_s = ZN([0]) // Single site: use brackets (vector format)
var zn_m = ZN([0, 1, 2, 3])
// ZN(0) would be INVALID - missing brackets
ZZ(integer site0, integer site1) -> SpinHalfOperator
Returns a spin-1/2 OperatorNamed for operator, taking two individual site indices.
Parameters
- site0: The first site index.
- site1: The second site index.
Example
var pzz1 = ZZ(0, 2)
ZZNN(const List<integer> sites) -> SpinHalfOperator
Returns a spin-1/2 OperatorNamed for operator.
Parameters
- sites: Vector of site indices where the operator acts (minimum 2 sites).
Example
var zznn_s = ZZNN([0, 1]) // Minimum sites: use brackets (vector format)
var zznn_m = ZZNN([0, 1, 2, 3])
// ZZNN(0, 1) would be INVALID - missing brackets
ZZNNN(const List<integer> sites) -> SpinHalfOperator
Returns a spin-1/2 OperatorNamed for operator.
Parameters
- sites: Vector of site indices where the operator acts (minimum 3 sites).
Example
var zznnn_s = ZZNNN([0, 1, 2]) // use brackets (vector format)
var zznnn_m = ZZNNN([0, 1, 2, 3, 4])
// ZZNNN(0, 1, 2) would be INVALID - missing brackets
operator_dense(const RealMatrix matrix, integer site) -> SpinHalfOperator
Returns a spin-1/2 OperatorDense parametrized by the given matrix.
Parameters
- matrix: The matrix parametrizing the operator.
- site: The site index where the operator acts.
operator_dense(const RealMatrix matrix, const List<integer> sites) -> SpinHalfOperator
Returns a spin-1/2 OperatorDense parametrized by the given matrix.
Parameters
- matrix: The matrix parametrizing the operator.
- sites: Vector of site indices where the operator acts.
operator_dense(const ComplexMatrix matrix, integer site) -> SpinHalfOperator
Returns a spin-1/2 OperatorDense parametrized by the given matrix.
Parameters
- matrix: The matrix parametrizing the operator.
- site: The site index where the operator acts.
operator_dense(const ComplexMatrix matrix, const List<integer> sites) -> SpinHalfOperator
Returns a spin-1/2 OperatorDense parametrized by the given matrix.
Parameters
- matrix: The matrix parametrizing the operator.
- sites: Vector of site indices where the operator acts.
operator_diagonal(const ComplexMatrix diagonal, const List<integer> sites) -> SpinHalfOperator
Returns a spin-1/2 diagonal operator with specified diagonal elements.
Parameters
- diagonal: Vector containing the operator diagonal elements.
- sites: Vector of site indices where the operator acts.
operator_diagonal(const RealMatrix diagonal, const List<integer> sites) -> SpinHalfOperator
Returns a spin-1/2 diagonal operator with specified diagonal elements.
Parameters
- diagonal: Vector containing the operator diagonal elements.
- sites: Vector of site indices where the operator acts.
operator_diagonal(const List<complex> diagonal, const List<integer> sites) -> SpinHalfOperator
Returns a spin-1/2 diagonal operator with specified diagonal elements.
Parameters
- diagonal: Vector containing the operator diagonal elements.
- sites: Vector of site indices where the operator acts.
operator_diagonal(const List<real> diagonal, const List<integer> sites) -> SpinHalfOperator
Returns a spin-1/2 diagonal operator with specified diagonal elements.
Parameters
- diagonal: Vector containing the operator diagonal elements.
- sites: Vector of site indices where the operator acts.
operator_diagonal(const List<real> diagonal, const List<integer> sites) -> SpinHalfOperator
Returns a spin-1/2 diagonal operator with specified diagonal elements.
Parameters
- diagonal: Vector containing the operator diagonal elements.
- sites: Vector of site indices where the operator acts.
operator_diagonal(const List<integer> diagonal, const List<integer> sites) -> SpinHalfOperator
Returns a spin-1/2 diagonal operator with specified diagonal elements.
Parameters
- diagonal: Vector containing the operator diagonal elements.
- sites: Vector of site indices where the operator acts.
operator_diagonal(const List<integer> diagonal, const List<integer> sites) -> SpinHalfOperator
Returns a spin-1/2 diagonal operator with specified diagonal elements.
Parameters
- diagonal: Vector containing the operator diagonal elements.
- sites: Vector of site indices where the operator acts.
operator_generic(const OperatorGenericFunction<ComplexMatrix, IntegerArray> function, const List<integer> sites) -> SpinHalfOperator
Creates a spin-1/2 OperatorGeneric from a string representation.
Parameters
- function: A function taking a vector and an array of indices.
- sites: Vector of site indices where the operator acts.
operator_generic(const OperatorGenericFunction<RealMatrix, IntegerArray> function, const List<integer> sites, as_real type_tag) -> SpinHalfOperator
Creates a spin-1/2 OperatorGeneric from a string representation.
Parameters
- function: A function taking a vector and an array of indices.
- sites: Vector of site indices where the operator acts.
- type_tag: A global constant tagging the object type.
operator_generic(const OperatorGenericFunction<ComplexMatrix, IntegerArray> function, const List<integer> sites, as_complex type_tag) -> SpinHalfOperator
Creates a spin-1/2 OperatorGeneric from a string representation.
Parameters
- function: A function taking a vector and an array of indices.
- sites: Vector of site indices where the operator acts.
- type_tag: A global constant tagging the object type.
operator_sparse(const RealSparseMatrix matrix, integer site) -> SpinHalfOperator
Returns a spin-1/2 OperatorSparse parametrized by the given matrix.
Parameters
- matrix: The matrix parametrizing the operator.
- site: The site index where the operator acts.
operator_sparse(const RealSparseMatrix matrix, const List<integer> sites) -> SpinHalfOperator
Returns a spin-1/2 OperatorSparse parametrized by the given matrix.
Parameters
- matrix: The matrix parametrizing the operator.
- sites: Vector of site indices where the operator acts.
operator_sparse(const ComplexSparseMatrix matrix, integer site) -> SpinHalfOperator
Returns a spin-1/2 OperatorSparse parametrized by the given matrix.
Parameters
- matrix: The matrix parametrizing the operator.
- site: The site index where the operator acts.
operator_sparse(const ComplexSparseMatrix matrix, const List<integer> sites) -> SpinHalfOperator
Returns a spin-1/2 OperatorSparse parametrized by the given matrix.
Parameters
- matrix: The matrix parametrizing the operator.
- sites: Vector of site indices where the operator acts.
pauli_string(const string word, const List<integer> sites) -> SpinHalfOperator
Creates a spin-1/2 OperatorPauliString from a string representation.
Parameters
- word: String representation of the Pauli string (e.g., "XYZ").
- sites: Vector of site indices where the operator acts.
Example
var pauli0 = pauli_string("XYZX", [1, 6, 2, 3])
Members
| Name | Description |
|---|---|
| name | Returns the symbolic name of a spin-1/2 operator. |
| parameters | Returns the sparse real matrix payload of a spin-1/2 operator. |
| sites | Returns the sites of a spin-1/2 operator in definition order. |