monoprop

MajoranaOperator

A weighted sum of Majorana monomials.

Constructed from a \{term: coefficient\} mapping, where each key is a :class:Majorana term (or, equivalently, a raw index tuple). Terms are normalized: indices within each monomial are sorted and duplicate monomials are summed. The resulting :attr:terms mapping (Majorana-index tuple to complex coefficient) is what the propagator hands to the C++ engine.

Attributes

attributenum_modes
= num_modes
attributeterms
= self._accumulate(majoranas, list(terms.values()))

Functions

func__init__(self, terms, num_modes) -> None

Initialize the Majorana operator from a term mapping.

paramself
paramtermsMapping[Majorana | Sequence[int], complex]

Mapping from :class:Majorana terms (or raw index tuples) to coefficients.

paramnum_modesint

Number of modes in the system. Required: an operator carries its own mode count so a propagator can be built from it directly. A gate generator is also authored as a :class:MajoranaOperator (wrapped in :class:~monoprop.circuit.ExpGate) -- bare :class:Majorana terms are not accepted by ExpGate, since the operator is what carries the mode count.

Returns

None
funcget_majorana_operator(self) -> MajoranaOperator

Return self (satisfies the operator-conversion protocol).

paramself

Returns

monoprop.majorana.MajoranaOperator
func__len__(self) -> int

Number of distinct Majorana monomial terms.

paramself

Returns

int
func__repr__(self) -> str

Return a string representation of the operator.

paramself

Returns

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

Check if two MajoranaOperators are closely equal (same terms and coefficients).

paramself
paramotherobject

Another MajoranaOperator to compare with.

paramrtolfloat
= 1e-05

Relative tolerance for coefficient comparison.

paramatolfloat
= 1e-08

Absolute tolerance for coefficient comparison.

Returns

bool

True if the operators have the same mode count and matching terms, else False.

On this page