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)) + 1attribute__hash__= NoneFunctions
func__init__(self, terms, coefficients, num_modes=None) -> NoneInitialize the fermi operator.
paramselfparamtermsSequence[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= NoneInferred 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
Nonefuncfrom_dict(cls, terms_dict) -> FermiOperatorConstruct a FermiOperator from a dictionary.
paramclsparamterms_dictdict[tuple[tuple[int, str], ...], complex]Returns
monoprop.fermi.FermiOperatorfunc__len__(self) -> intNumber of terms in the operator.
paramselfReturns
intfunc__repr__(self) -> strReturn a string representation of the fermionic operator.
paramselfReturns
strfunc__eq__(self, other) -> boolEqual when terms, coefficients, and num_modes match exactly.
paramselfparamotherobjectReturns
boolfuncisclose(self, other, rtol=1e-05, atol=1e-08) -> boolCheck 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.
paramselfparamotherobjectparamrtolfloat= 1e-05paramatolfloat= 1e-08Returns
boolfuncget_majorana_operator(self) -> MajoranaOperatorConvert the fermi operator to a MajoranaOperator.
paramselfReturns
monoprop.majorana.MajoranaOperator