qml.is_commuting

is_commuting(operation1, operation2)[source]

Check if two operations are commuting using a lookup table.

A lookup table is used to check the commutation between the controlled, targeted part of operation 1 with the controlled, targeted part of operation 2.

Note

Most qubit-based PennyLane operations are supported — CV operations are not supported at this time.

Unsupported qubit-based operations include:

PauliRot, QubitDensityMatrix, CVNeuralNetLayers, ApproxTimeEvolution, ArbitraryUnitary, CommutingEvolution, DisplacementEmbedding and SqueezingEmbedding.

Parameters
  • operation1 (Operation) – A first quantum operation.

  • operation2 (Operation) – A second quantum operation.

Returns

True if the operations commute, False otherwise.

Return type

bool

Example

>>> qml.is_commuting(qml.PauliX(wires=0), qml.PauliZ(wires=0))
False

Contents

Using PennyLane

Development

API