SupportsCommutators¶
- class SupportsCommutators(*args, **kwargs)¶
Bases:
ProtocolA Protocol indicating support for efficient commutator generation.
Implementation of this protocol requires the three methods below. See
commutator(),anti_commutator(), anddouble_commutator()for the type-agnostic helper functions dispatching to these methods.>>> from qiskit_bosons.operators import BosonOperator >>> cre_0 = BosonOperator.from_dict({((True, 0),): 1.0}) >>> ann_0 = BosonOperator.from_dict({((False, 0),): 1.0}) >>> comm = BosonOperator._commutator_(ann_0, cre_0) >>> print(format(comm.normal_ordered().simplify())) 1.000000e0 +0.000000e0j * ()
Protocol Methods
- 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
- 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
- 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