qml.is_commuting

is_commuting(operation1, operation2, wire_map=None)[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, Prod, Sum, Exp and SProd.

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

  • operation2 (Operation) – A second quantum operation.

  • wire_map (dict[Union[str, int], int]) – dictionary for Pauli word commutation containing all wire labels used in the Pauli word as keys, and unique integer labels as their values

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

Development

API

Internals