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, SqueezingEmbedding Exp

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.X(0), qml.Z(0))
False

Contents

Using PennyLane

Release news

Development

API

Internals