pycommute.expression
Polynomial expressions involving quantum-mechanical operators and manipulations with them
Index sequence
Note
Indices
objects are not the same thing as Python tuples because
they follow a different ordering rule. Unlike the Python tuples, two
index sequences I1
and I2
always compare as I1 < I2
if
len(I1) < len(I2)
.
- class pycommute.expression.Indices
Mixed sequence of integer/string indices
- __eq__(self: pycommute.expression.Indices, arg0: pycommute.expression.Indices) bool
- __getitem__(self: pycommute.expression.Indices, arg0: int) int | str
Individual index access.
- __gt__(self: pycommute.expression.Indices, arg0: pycommute.expression.Indices) bool
- __hash__ = None
- __init__(self: pycommute.expression.Indices, *args) None
Construct an index sequence from positional integer/string arguments.
- __iter__(self: pycommute.expression.Indices) Iterator[int | str]
- __len__(self: pycommute.expression.Indices) int
Index sequence length.
- __lt__(self: pycommute.expression.Indices, arg0: pycommute.expression.Indices) bool
- __ne__(self: pycommute.expression.Indices, arg0: pycommute.expression.Indices) bool
- __repr__(self: pycommute.expression.Indices) str
- property indices
Index sequence as a list of integers and strings
Algebra ID constants
Fermionic algebra ID
- expression.FERMION = -3
Bosonic algebra ID
- expression.BOSON = -2
Spin algebra ID
- expression.SPIN = -1
Algebra generator objects
- class pycommute.expression.Generator
Abstract algebra generator
- __eq__(self: pycommute.expression.Generator, g2: pycommute.expression.Generator) bool
- __gt__(self: pycommute.expression.Generator, g2: pycommute.expression.Generator) bool
- __hash__ = None
- __lt__(self: pycommute.expression.Generator, g2: pycommute.expression.Generator) bool
- __ne__(self: pycommute.expression.Generator, g2: pycommute.expression.Generator) bool
- __repr__(self: pycommute.expression.Generator) str
- property algebra_id
ID of the algebra this generator belongs to.
- property indices
Indices carried by this generator.
- class pycommute.expression.GeneratorFermion
Bases:
Generator
Generator of the fermionic algebra
- __init__(self: pycommute.expression.GeneratorFermion, dagger: bool, indices: pycommute.expression.Indices) None
Construct a creation or annihilation fermionic operator with given indices.
- Parameters:
dagger –
True
/False
for a creation/annihilation operator respectively.indices – Index sequence of the creation/annihilation operator.
- property dagger
Is this generator a creation operator?
- expression.make_fermion(dagger: bool, *args) pycommute.expression.GeneratorFermion
Make a creation or annihilation fermionic operator with indices passed as positional arguments.
- Parameters:
dagger –
True
/False
for a creation/annihilation operator respectively.*args – Indices of the creation/annihilation operator.
- class pycommute.expression.GeneratorBoson
Bases:
Generator
Generator of the bosonic algebra
- __init__(self: pycommute.expression.GeneratorBoson, dagger: bool, indices: pycommute.expression.Indices) None
Construct a creation or annihilation bosonic operator with given indices.
- Parameters:
dagger –
True
/False
for a creation/annihilation operator respectively.indices – Index sequence of the creation/annihilation operator.
- property dagger
Is this generator a creation operator?
- expression.make_boson(dagger: bool, *args) pycommute.expression.GeneratorBoson
Make a creation or annihilation bosonic operator with indices passed as positional arguments.
- Parameters:
dagger –
True
/False
for a creation/annihilation operator respectively.*args – Indices of the creation/annihilation operator.
- class pycommute.expression.SpinComponent
Enumeration: spin operator component, \(S_+\), \(S_-\) or \(S_z\).
Members:
PLUS : Label for the spin raising operators \(S_+ = S_x + i S_y\)
MINUS : Label for the spin lowering operators \(S_- = S_x - i S_y\)
Z : Label for the 3rd spin projection operators \(S_z\)
- class pycommute.expression.GeneratorSpin
Bases:
Generator
Generator of the spin algebra
- __init__(*args, **kwargs)
Overloaded function.
__init__(self:
pycommute.expression.GeneratorSpin
, c:pycommute.expression.SpinComponent
, indices:pycommute.expression.Indices
) -> None
Construct a spin-1/2 operator corresponding to a single spin component and carrying given indices.
- Parameters:
c – Which spin component to construct, one of
SpinComponent
values.indices – Index sequence of the spin component operator.
__init__(self:
pycommute.expression.GeneratorSpin
, spin: float, c:pycommute.expression.SpinComponent
, indices:pycommute.expression.Indices
) -> None
Construct an operator for a general spin \(S\) corresponding to a single spin component and carrying given indices.
- Parameters:
spin – Integer or half-integer value of spin \(S\).
c – Which spin component to construct, one of
SpinComponent
values.indices – Index sequence of the spin component operator.
- property component
Whether this generator \(S_+\), \(S_-\) or \(S_z\)?
- property multiplicity
Multiplicity \(2S+1\) of the spin algebra this generator belongs to.
- property spin
Spin \(S\) of the algebra this generator belongs to.
- expression.make_spin(*args, **kwargs)
Overloaded function.
make_spin(c:
pycommute.expression.SpinComponent
, *args) ->pycommute.expression.GeneratorSpin
Make a spin-1/2 operator corresponding to a single spin component and carrying indices passed as positional arguments.
- Parameters:
c – Which spin component to construct, one of
SpinComponent
values.*args – Indices of the operator.
make_spin(spin: float, c:
pycommute.expression.SpinComponent
, *args) ->pycommute.expression.GeneratorSpin
Make an operator for a general spin \(S\) corresponding to a single spin component and carrying indices passed as positional arguments.
- Parameters:
spin – Integer or half-integer value of spin \(S\).
c – Which spin component to construct, one of
SpinComponent
values.*args – Indices of the operator.
Monomial object
- class pycommute.expression.Monomial
Monomial: a product of algebra generators
- __contains__(self: pycommute.expression.Monomial, arg0: pycommute.expression.Generator) bool
- __copy__(self: pycommute.expression.Monomial) pycommute.expression.Monomial
- __deepcopy__(self: pycommute.expression.Monomial, memo: dict) pycommute.expression.Monomial
- __eq__(self: pycommute.expression.Monomial, arg0: pycommute.expression.Monomial) bool
- __getitem__(*args, **kwargs)
Overloaded function.
__getitem__(self:
pycommute.expression.Monomial
, arg0: int) ->pycommute.expression.Generator
Get a generator in the monomial by its index.
__getitem__(self:
pycommute.expression.Monomial
, arg0: slice) ->pycommute.expression.Monomial
Get a slice of the monomial.
- __gt__(self: pycommute.expression.Monomial, arg0: pycommute.expression.Monomial) bool
- __hash__ = None
- __init__(*args, **kwargs)
Overloaded function.
__init__(self:
pycommute.expression.Monomial
) -> None
Construct an identity monomial (a product of zero generators).
__init__(self:
pycommute.expression.Monomial
, arg0: list[pycommute.expression.Generator
]) -> None
Construct from a list of algebra generators.
- __iter__(self: pycommute.expression.Monomial) Iterator[pycommute.expression.Generator]
- __len__(self: pycommute.expression.Monomial) int
Number of generators in this monomial.
- __lt__(self: pycommute.expression.Monomial, arg0: pycommute.expression.Monomial) bool
- __mul__(*args, **kwargs)
Overloaded function.
__mul__(self:
pycommute.expression.Monomial
, arg0:pycommute.expression.Generator
) ->pycommute.expression.Monomial
__mul__(self:
pycommute.expression.Monomial
, arg0:pycommute.expression.Monomial
) ->pycommute.expression.Monomial
- __ne__(self: pycommute.expression.Monomial, arg0: pycommute.expression.Monomial) bool
- __repr__(self: pycommute.expression.Monomial) str
- __reverse__(self: pycommute.expression.Monomial) Iterator[pycommute.expression.Generator]
- __rmul__(self: pycommute.expression.Monomial, arg0: pycommute.expression.Generator) pycommute.expression.Monomial
- property is_ordered
Is this monomial canonically ordered?
- swap_generators(self: pycommute.expression.Monomial, n1: int, n2: int) None
Swap two generators at given positions within the monomial.
- Parameters:
n1 – Position of the first generator to be swapped.
n2 – Position of the second generator to be swapped.
Expression objects
- class pycommute.expression.ExpressionR
Polynomial in quantum-mechanical operators with real coefficients
- __add__(*args, **kwargs)
Overloaded function.
__add__(self:
pycommute.expression.ExpressionR
, arg0:pycommute.expression.ExpressionR
) ->pycommute.expression.ExpressionR
__add__(self:
pycommute.expression.ExpressionR
, arg0: float) ->pycommute.expression.ExpressionR
__add__(self:
pycommute.expression.ExpressionR
, arg0:pycommute.expression.ExpressionC
) ->pycommute.expression.ExpressionC
__add__(self:
pycommute.expression.ExpressionR
, arg0: complex) ->pycommute.expression.ExpressionC
- __copy__(self: pycommute.expression.ExpressionR) pycommute.expression.ExpressionR
- __deepcopy__(self: pycommute.expression.ExpressionR, memo: dict) pycommute.expression.ExpressionR
- __eq__(self: pycommute.expression.ExpressionR, arg0: pycommute.expression.ExpressionR) bool
- __hash__ = None
- __iadd__(*args, **kwargs)
Overloaded function.
__iadd__(self:
pycommute.expression.ExpressionR
, arg0:pycommute.expression.ExpressionR
) ->pycommute.expression.ExpressionR
__iadd__(self:
pycommute.expression.ExpressionR
, arg0: float) ->pycommute.expression.ExpressionR
- __imul__(*args, **kwargs)
Overloaded function.
__imul__(self:
pycommute.expression.ExpressionR
, arg0:pycommute.expression.ExpressionR
) ->pycommute.expression.ExpressionR
__imul__(self:
pycommute.expression.ExpressionR
, arg0: float) ->pycommute.expression.ExpressionR
- __init__(*args, **kwargs)
Overloaded function.
__init__(self:
pycommute.expression.ExpressionR
) -> None
Construct a zero expression.
__init__(self:
pycommute.expression.ExpressionR
, x: float) -> None
Construct a constant expression equal to \(x\).
- Parameters:
x – Constant \(x\).
__init__(self:
pycommute.expression.ExpressionR
, x: float, m:pycommute.expression.Monomial
) -> None
Construct an expression with one monomial, \(x \cdot m\).
- Parameters:
x – Coefficient \(x\).
m – Monomial \(m\).
- __isub__(*args, **kwargs)
Overloaded function.
__isub__(self:
pycommute.expression.ExpressionR
, arg0:pycommute.expression.ExpressionR
) ->pycommute.expression.ExpressionR
__isub__(self:
pycommute.expression.ExpressionR
, arg0: float) ->pycommute.expression.ExpressionR
- __iter__(self: pycommute.expression.ExpressionR) Iterator[tuple[pycommute.expression.Monomial, float]]
- __len__(self: pycommute.expression.ExpressionR) int
Number of monomials in this expression.
- __mul__(*args, **kwargs)
Overloaded function.
__mul__(self:
pycommute.expression.ExpressionR
, arg0:pycommute.expression.ExpressionR
) ->pycommute.expression.ExpressionR
__mul__(self:
pycommute.expression.ExpressionR
, arg0: float) ->pycommute.expression.ExpressionR
__mul__(self:
pycommute.expression.ExpressionR
, arg0:pycommute.expression.ExpressionC
) ->pycommute.expression.ExpressionC
__mul__(self:
pycommute.expression.ExpressionR
, arg0: complex) ->pycommute.expression.ExpressionC
- __ne__(self: pycommute.expression.ExpressionR, arg0: pycommute.expression.ExpressionR) bool
- __neg__(self: pycommute.expression.ExpressionR) pycommute.expression.ExpressionR
- __radd__(*args, **kwargs)
Overloaded function.
__radd__(self:
pycommute.expression.ExpressionR
, arg0: float) ->pycommute.expression.ExpressionR
__radd__(self:
pycommute.expression.ExpressionR
, arg0: complex) ->pycommute.expression.ExpressionC
- __repr__(self: pycommute.expression.ExpressionR) str
- __rmul__(*args, **kwargs)
Overloaded function.
__rmul__(self:
pycommute.expression.ExpressionR
, arg0: float) ->pycommute.expression.ExpressionR
__rmul__(self:
pycommute.expression.ExpressionR
, arg0: complex) ->pycommute.expression.ExpressionC
- __rsub__(*args, **kwargs)
Overloaded function.
__rsub__(self:
pycommute.expression.ExpressionR
, arg0: float) ->pycommute.expression.ExpressionR
__rsub__(self:
pycommute.expression.ExpressionR
, arg0: complex) ->pycommute.expression.ExpressionC
- __sub__(*args, **kwargs)
Overloaded function.
__sub__(self:
pycommute.expression.ExpressionR
, arg0:pycommute.expression.ExpressionR
) ->pycommute.expression.ExpressionR
__sub__(self:
pycommute.expression.ExpressionR
, arg0: float) ->pycommute.expression.ExpressionR
__sub__(self:
pycommute.expression.ExpressionR
, arg0:pycommute.expression.ExpressionC
) ->pycommute.expression.ExpressionC
__sub__(self:
pycommute.expression.ExpressionR
, arg0: complex) ->pycommute.expression.ExpressionC
- clear(self: pycommute.expression.ExpressionR) None
Reset expression to zero.
- class pycommute.expression.ExpressionC
Polynomial in quantum-mechanical operators with complex coefficients
- __add__(*args, **kwargs)
Overloaded function.
__add__(self:
pycommute.expression.ExpressionC
, arg0:pycommute.expression.ExpressionC
) ->pycommute.expression.ExpressionC
__add__(self:
pycommute.expression.ExpressionC
, arg0: complex) ->pycommute.expression.ExpressionC
__add__(self:
pycommute.expression.ExpressionC
, arg0:pycommute.expression.ExpressionR
) ->pycommute.expression.ExpressionC
__add__(self:
pycommute.expression.ExpressionC
, arg0: float) ->pycommute.expression.ExpressionC
- __copy__(self: pycommute.expression.ExpressionC) pycommute.expression.ExpressionC
- __deepcopy__(self: pycommute.expression.ExpressionC, memo: dict) pycommute.expression.ExpressionC
- __eq__(self: pycommute.expression.ExpressionC, arg0: pycommute.expression.ExpressionC) bool
- __hash__ = None
- __iadd__(*args, **kwargs)
Overloaded function.
__iadd__(self:
pycommute.expression.ExpressionC
, arg0:pycommute.expression.ExpressionC
) ->pycommute.expression.ExpressionC
__iadd__(self:
pycommute.expression.ExpressionC
, arg0: complex) ->pycommute.expression.ExpressionC
__iadd__(self:
pycommute.expression.ExpressionC
, arg0:pycommute.expression.ExpressionR
) ->pycommute.expression.ExpressionC
__iadd__(self:
pycommute.expression.ExpressionC
, arg0: float) ->pycommute.expression.ExpressionC
- __imul__(*args, **kwargs)
Overloaded function.
__imul__(self:
pycommute.expression.ExpressionC
, arg0:pycommute.expression.ExpressionC
) ->pycommute.expression.ExpressionC
__imul__(self:
pycommute.expression.ExpressionC
, arg0: complex) ->pycommute.expression.ExpressionC
__imul__(self:
pycommute.expression.ExpressionC
, arg0:pycommute.expression.ExpressionR
) ->pycommute.expression.ExpressionC
__imul__(self:
pycommute.expression.ExpressionC
, arg0: float) ->pycommute.expression.ExpressionC
- __init__(*args, **kwargs)
Overloaded function.
__init__(self:
pycommute.expression.ExpressionC
) -> None
Construct a zero expression.
__init__(self:
pycommute.expression.ExpressionC
, x: complex) -> None
Construct a constant expression equal to \(x\).
- Parameters:
x – Constant \(x\).
__init__(self:
pycommute.expression.ExpressionC
, x: complex, m:pycommute.expression.Monomial
) -> None
Construct an expression with one monomial, \(x \cdot m\).
- Parameters:
x – Coefficient \(x\).
m – Monomial \(m\).
__init__(self:
pycommute.expression.ExpressionC
, expr:pycommute.expression.ExpressionR
) -> None
Construct from a real expression by complexifying its coefficients.
- __isub__(*args, **kwargs)
Overloaded function.
__isub__(self:
pycommute.expression.ExpressionC
, arg0:pycommute.expression.ExpressionC
) ->pycommute.expression.ExpressionC
__isub__(self:
pycommute.expression.ExpressionC
, arg0: complex) ->pycommute.expression.ExpressionC
__isub__(self:
pycommute.expression.ExpressionC
, arg0:pycommute.expression.ExpressionR
) ->pycommute.expression.ExpressionC
__isub__(self:
pycommute.expression.ExpressionC
, arg0: float) ->pycommute.expression.ExpressionC
- __iter__(self: pycommute.expression.ExpressionC) Iterator[tuple[pycommute.expression.Monomial, complex]]
- __len__(self: pycommute.expression.ExpressionC) int
Number of monomials in this expression.
- __mul__(*args, **kwargs)
Overloaded function.
__mul__(self:
pycommute.expression.ExpressionC
, arg0:pycommute.expression.ExpressionC
) ->pycommute.expression.ExpressionC
__mul__(self:
pycommute.expression.ExpressionC
, arg0: complex) ->pycommute.expression.ExpressionC
__mul__(self:
pycommute.expression.ExpressionC
, arg0:pycommute.expression.ExpressionR
) ->pycommute.expression.ExpressionC
__mul__(self:
pycommute.expression.ExpressionC
, arg0: float) ->pycommute.expression.ExpressionC
- __ne__(self: pycommute.expression.ExpressionC, arg0: pycommute.expression.ExpressionC) bool
- __neg__(self: pycommute.expression.ExpressionC) pycommute.expression.ExpressionC
- __radd__(*args, **kwargs)
Overloaded function.
__radd__(self:
pycommute.expression.ExpressionC
, arg0: complex) ->pycommute.expression.ExpressionC
__radd__(self:
pycommute.expression.ExpressionC
, arg0: float) ->pycommute.expression.ExpressionC
- __repr__(self: pycommute.expression.ExpressionC) str
- __rmul__(*args, **kwargs)
Overloaded function.
__rmul__(self:
pycommute.expression.ExpressionC
, arg0: complex) ->pycommute.expression.ExpressionC
__rmul__(self:
pycommute.expression.ExpressionC
, arg0: float) ->pycommute.expression.ExpressionC
- __rsub__(*args, **kwargs)
Overloaded function.
__rsub__(self:
pycommute.expression.ExpressionC
, arg0: complex) ->pycommute.expression.ExpressionC
__rsub__(self:
pycommute.expression.ExpressionC
, arg0: float) ->pycommute.expression.ExpressionC
- __sub__(*args, **kwargs)
Overloaded function.
__sub__(self:
pycommute.expression.ExpressionC
, arg0:pycommute.expression.ExpressionC
) ->pycommute.expression.ExpressionC
__sub__(self:
pycommute.expression.ExpressionC
, arg0: complex) ->pycommute.expression.ExpressionC
__sub__(self:
pycommute.expression.ExpressionC
, arg0:pycommute.expression.ExpressionR
) ->pycommute.expression.ExpressionC
__sub__(self:
pycommute.expression.ExpressionC
, arg0: float) ->pycommute.expression.ExpressionC
- clear(self: pycommute.expression.ExpressionC) None
Reset expression to zero.
- expression.conj(*args, **kwargs)
Overloaded function.
conj(expr:
pycommute.expression.ExpressionR
) ->pycommute.expression.ExpressionR
Hermitian conjugate.
- Parameters:
expr – Expression to conjugate.
conj(expr:
pycommute.expression.ExpressionC
) ->pycommute.expression.ExpressionC
Hermitian conjugate.
- Parameters:
expr – Expression to conjugate.
- expression.transform(*args, **kwargs)
Overloaded function.
transform(expr:
pycommute.expression.ExpressionR
, f: Callable[[pycommute.expression.Monomial
, float], float]) ->pycommute.expression.ExpressionR
Apply a given function to all monomial/coefficient pairs and replace the coefficients with values returned by the function. Zero return values will result in respective monomials being discarded.
- Parameters:
expr – Expression to be transformed.
f – Transformation function. It must take two arguments, one of type
Monomial
and onefloat
argument.
transform(expr:
pycommute.expression.ExpressionC
, f: Callable[[pycommute.expression.Monomial
, complex], complex]) ->pycommute.expression.ExpressionC
Apply a given function to all monomial/coefficient pairs and replace the coefficients with values returned by the function. Zero return values will result in respective monomials being discarded.
- Parameters:
expr – Expression to be transformed.
f – Transformation function. It must take two arguments, one of type
Monomial
and onecomplex
argument.
transform(expr:
pycommute.expression.ExpressionR
, f: Callable[[pycommute.expression.Monomial
, float], complex]) ->pycommute.expression.ExpressionC
Apply a given function to all monomial/coefficient pairs and replace the coefficients with values returned by the function. Zero return values will result in respective monomials being discarded.
- Parameters:
expr – Expression to be transformed.
f – Transformation function. It must take two arguments, one of type
Monomial
and onefloat
argument.
transform(expr:
pycommute.expression.ExpressionC
, f: Callable[[pycommute.expression.Monomial
, complex], float]) ->pycommute.expression.ExpressionR
Apply a given function to all monomial/coefficient pairs and replace the coefficients with values returned by the function. Zero return values will result in respective monomials being discarded.
- Parameters:
expr – Expression to be transformed.
f – Transformation function. It must take two arguments, one of type
Monomial
and onecomplex
argument.
Expression factory functions
- expression.c_dag(*args) pycommute.expression.ExpressionR
Returns a fermionic creation operator with indices passed as positional arguments.
- Parameters:
*args – Indices of the operator.
- expression.c(*args) pycommute.expression.ExpressionR
Returns a fermionic annihilation operator with indices passed as positional arguments.
- Parameters:
*args – Indices of the operator.
- expression.n(*args) pycommute.expression.ExpressionR
Returns a fermionic particle number operator with indices passed as positional arguments.
- Parameters:
*args – Indices of the operator.
- expression.a_dag(*args) pycommute.expression.ExpressionR
Returns a bosonic creation operator with indices passed as positional arguments.
- Parameters:
*args – Indices of the operator.
- expression.a(*args) pycommute.expression.ExpressionR
Returns a bosonic annihilation operator with indices passed as positional arguments.
- Parameters:
*args – Indices of the operator.
- expression.S_p(*args, **kwargs)
Overloaded function.
S_p(*args) ->
pycommute.expression.ExpressionR
Returns a spin-1/2 raising operator \(S_+\) with indices passed as positional arguments.
- Parameters:
*args – Indices of the operator.
S_p(*args, **kwargs) ->
pycommute.expression.ExpressionR
Returns a general spin raising operator \(S_+\) with indices passed as positional arguments.
- Parameters:
spin – Spin \(S\).
*args – Indices of the operator.
- expression.S_m(*args, **kwargs)
Overloaded function.
S_m(*args) ->
pycommute.expression.ExpressionR
Returns a spin-1/2 lowering operator \(S_-\) with indices passed as positional arguments.
- Parameters:
*args – Indices of the operator.
S_m(*args, **kwargs) ->
pycommute.expression.ExpressionR
Returns a general spin lowering operator \(S_-\) with indices passed as positional arguments.
- Parameters:
spin – Spin \(S\).
*args – Indices of the operator.
- expression.S_x(*args, **kwargs)
Overloaded function.
S_x(*args) ->
pycommute.expression.ExpressionC
Returns a spin-1/2 x-projection operator \(S_x\) with indices passed as positional arguments.
- Parameters:
*args – Indices of the operator.
S_x(*args, **kwargs) ->
pycommute.expression.ExpressionC
Returns a general spin \(S\) x-projection operator \(S_x\) with indices passed as positional arguments.
- Parameters:
spin – Spin \(S\).
*args – Indices of the operator.
- expression.S_y(*args, **kwargs)
Overloaded function.
S_y(*args) ->
pycommute.expression.ExpressionC
Returns a spin-1/2 y-projection operator \(S_y\) with indices passed as positional arguments.
- Parameters:
*args – Indices of the operator.
S_y(*args, **kwargs) ->
pycommute.expression.ExpressionC
Returns a general spin \(S\) y-projection operator \(S_y\) with indices passed as positional arguments.
- Parameters:
spin – Spin \(S\).
*args – Indices of the operator.
- expression.S_z(*args, **kwargs)
Overloaded function.
S_z(*args) ->
pycommute.expression.ExpressionR
Returns a spin-1/2 z-projection operator \(S_z\) with indices passed as positional arguments.
- Parameters:
*args – Indices of the operator.
S_z(*args, **kwargs) ->
pycommute.expression.ExpressionR
Returns a general spin \(S\) z-projection operator \(S_z\) with indices passed as positional arguments.
- Parameters:
spin – Spin \(S\).
*args – Indices of the operator.
- expression.make_complex(expr: pycommute.expression.ExpressionR) pycommute.expression.ExpressionC
Make a complex expression out of a real one.
- Parameters:
expr – Real expression to be complexified.
Hermitian conjugate placeholder
- class pycommute.expression.HC
A placeholder type that adds/subtracts the Hermitian conjugate to/from an expression. There is a module-level constant of this type called
hc
, which allows to mimic the \(\pm H.c.\) notation in expressions.
- expression.hc = <pycommute.expression.HC object>