monoprop

FermiOperator

A weighted sum of FermiString terms.

Attributes

attributeterms
= [(t if isinstance(t, FermiString) else FermiString(t)) for t in terms]
attributecoefficients
= list(coefficients)
attributenum_modes
= num_modes if num_modes is not None else max(idx for f in (self.terms) for idx, _ in (f.expression)) + 1
attribute__hash__
= None

Functions

func__init__(self, terms, coefficients, num_modes=None) -> None

Initialize the fermi operator.

paramself
paramtermsSequence[FermiString] | Sequence[Sequence[tuple[int, str]]]

The FermiString terms, or (index, '+'/'-') sequences to build them.

paramcoefficientsSequence[complex]

One coefficient per term, in the same order.

paramnum_modesint | None
= None

Inferred as one past the largest index in terms when None, which needs at least one term -- pass it explicitly to build an empty operator.

Returns

None
funcfrom_dict(cls, terms_dict) -> FermiOperator

Construct a FermiOperator from a dictionary.

paramcls
paramterms_dictdict[tuple[tuple[int, str], ...], complex]

Returns

monoprop.fermi.FermiOperator
func__len__(self) -> int

Number of terms in the operator.

paramself

Returns

int
func__repr__(self) -> str

Return a string representation of the fermionic operator.

paramself

Returns

str
func__eq__(self, other) -> bool

Equal when terms, coefficients, and num_modes match exactly.

paramself
paramotherobject

Returns

bool
funcisclose(self, other, rtol=1e-05, atol=1e-08) -> bool

Check that two operators are almost equal, term-wise.

Terms are compared after canonicalization, with numpy.isclose at rtol/atol; a differing mode count is False, not an error.

paramself
paramotherobject
paramrtolfloat
= 1e-05
paramatolfloat
= 1e-08

Returns

bool
funcget_majorana_operator(self) -> MajoranaOperator

Convert the fermi operator to a MajoranaOperator.

paramself

Returns

monoprop.majorana.MajoranaOperator

On this page