op_sum(*summands, do_queue=True, id=None)¶
Construct an operator which is the sum of the given operators.
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.
The operator representing the sum of summands.
- Return type
>>> summed_op = op_sum(qml.PauliX(0), qml.PauliZ(0)) >>> summed_op PauliX(wires=) + PauliZ(wires=) >>> summed_op.matrix() array([[ 1, 1], [ 1, -1]])
- What is PennyLane?
- Quantum circuits
- Gradients and training
- Quantum operators
- Inspecting circuits
- Compiling circuits
- Quantum Chemistry