qml.grouping.diagonalize_qwc_pauli_words

diagonalize_qwc_pauli_words(qwc_grouping)[source]

Diagonalizes a list of mutually qubit-wise commutative Pauli words.

Parameters

qwc_grouping (list[Observable]) – a list of observables containing mutually qubit-wise commutative Pauli words

Returns

  • list[Operation]: an instance of the qwc_rotation template which diagonalizes the qubit-wise commuting grouping

  • list[Observable]: list of Pauli string observables diagonal in the computational basis

Return type

tuple

Raises

ValueError – if any 2 elements in the input QWC grouping are not qubit-wise commutative

Example

>>> qwc_group = [qml.PauliX(0) @ qml.PauliZ(1),
                 qml.PauliX(0) @ qml.PauliY(3),
                 qml.PauliZ(1) @ qml.PauliY(3)]
>>> diagonalize_qwc_pauli_words(qwc_group)
([RY(-1.5707963267948966, wires=[0]), RX(1.5707963267948966, wires=[3])],
 [PauliZ(wires=[0]) @ PauliZ(wires=[1]),
  PauliZ(wires=[0]) @ PauliZ(wires=[3]),
  PauliZ(wires=[1]) @ PauliZ(wires=[3])])