OperatorTrait¶
- class OperatorTrait(*args, **kwargs)¶
Bases:
ProtocolA protocol indicating all methods implemented by operator classes.
Attributes
- groups¶
Returns the groups indices.
Methods
- equiv(other, atol)¶
Checks this operator with another for equivalence up to the specified absolute tolerance.
- classmethod from_terms(terms)¶
Constructs a new operator from an iterator (see also
iter_terms()).
- classmethod from_terms_with_groups(terms)¶
Constructs a new operator from an iterator (see also
iter_terms_with_groups()).
- get_support()¶
Returns the set of mode indices which this operator acts upon.
- group_weights()¶
Returns the mean absolute coefficient magnitude of each group.
This is equivalent to (but cheaper than) reducing
get_coeffs()andgroupsdown to one value per group in NumPy, because it does not copy one value per ungrouped term out of the operator just to aggregate it away again.
- has_groups()¶
Returns whether this operator tracks group indices.
This is equivalent to (but cheaper than) checking
op.groups is not None, because it does not copy the group indices out of the operator in order to inspect them.- Return type:
- ichop(atol)¶
Trims coefficients below the absolute tolerance from this operator.
- Parameters:
atol (float)
- is_hermitian(atol=1e-08)¶
Returns whether this operator is Hermitian.
The check reduces the difference of this operator and its
adjoint()to a normal form (seenormal_ordered()) and compares the result againstzero(). It is therefore only as strong as the normal form that the specific operator type reduces through.Note
A
Trueresult is always reliable. AFalseresult is reliable only for operator types whose normal form is a genuine canonical form; for the others this check is conservative and can returnFalsefor an operator that is in fact Hermitian. Consult the specific implementation to find out which of the two applies.
- iter_terms_with_groups()¶
Iterates over the terms of this operator with their group indices.
- Return type:
- normal_ordered(*args, **kwargs)¶
Returns the normal-ordered form of this operator.
Note
A specific implementation of this method may take additional arguments.
- Return type:
- relabel_modes(permutation)¶
Relabels the modes of the operator.
- simplify(atol)¶
Simplifies the terms of this operator, discarding those below the absolute tolerance.