qml.op_sum

op_sum(*summands, do_queue=True, id=None)[source]

Construct an operator which is the sum of the given operators.

Parameters

summands (tuple[Operator]) – the operators we want to sum together.

Keyword Arguments
  • do_queue (bool) – determines if the sum operator will be queued (currently not supported). Default is True.

  • id (str or None) – id for the Sum operator. Default is None.

Returns

The operator representing the sum of summands.

Return type

Sum

See also

Sum

Example

>>> summed_op = op_sum(qml.PauliX(0), qml.PauliZ(0))
>>> summed_op
PauliX(wires=[0]) + PauliZ(wires=[0])
>>> summed_op.matrix()
array([[ 1,  1],
       [ 1, -1]])