SupportsCommutators
class SupportsCommutators(*args, **kwargs)
Bases: Protocol
A Protocol indicating support for efficient commutator generation.
Implementation of this protocol requires the three methods below. See commutator(), anti_commutator(), and double_commutator() for the type-agnostic helper functions dispatching to these methods.
>>> from qiskit_fermions.operators import FermionOperator
>>> cre_0 = FermionOperator.from_dict({((True, 0),): 1.0})
>>> ann_0 = FermionOperator.from_dict({((False, 0),): 1.0})
>>> comm = FermionOperator._commutator_(cre_0, ann_0)
>>> print(format(comm.normal_ordered().simplify()))
-1.000000e0 +0.000000e0j * ()
2.000000e0 +0.000000e0j * (+0 -0)
Protocol Methods
_anti_commutator_
static _anti_commutator_(op_a, op_b)
Computes the anti-commutator of two operator instances.
See anti_commutator() for more details.
Parameters
- op_a (T)
- op_b (T)
Return type
T
_commutator_
static _commutator_(op_a, op_b)
Computes the commutator of two operator instances.
See commutator() for more details.
Parameters
- op_a (T)
- op_b (T)
Return type
T
_double_commutator_
static _double_commutator_(op_a, op_b, op_c, sign)
Computes the double-commutator of three operator instances.
See double_commutator() for more details.
Parameters
- op_a (T)
- op_b (T)
- op_c (T)
- sign (bool)
Return type
T