qml.grouping.diagonalize_qwc_groupings

diagonalize_qwc_groupings(qwc_groupings)[source]

Diagonalizes a list of qubit-wise commutative groupings of Pauli strings.

Parameters

qwc_groupings (list[list[Observable]]) – a list of mutually qubit-wise commutative groupings of Pauli string observables

Returns

  • list[list[Operation]]: a list of instances of the qwc_rotation template which diagonalizes the qubit-wise commuting grouping, order corresponding to qwc_groupings

  • list[list[Observable]]: a list of QWC groupings diagonalized in the computational basis, order corresponding to qwc_groupings

Return type

tuple

Example

>>> qwc_group_1 = [qml.PauliX(0) @ qml.PauliZ(1),
                   qml.PauliX(0) @ qml.PauliY(3),
                   qml.PauliZ(1) @ qml.PauliY(3)]
>>> qwc_group_2 = [qml.PauliY(0),
                   qml.PauliY(0) @ qml.PauliX(2),
                   qml.PauliX(1) @ qml.PauliZ(3)]
>>> post_rotations, diag_groupings = diagonalize_qwc_groupings([qwc_group_1, qwc_group_2])
>>> post_rotations
[[RY(-1.5707963267948966, wires=[0]), RX(1.5707963267948966, wires=[3])],
 [RX(1.5707963267948966, wires=[0]),
  RY(-1.5707963267948966, wires=[2]),
  RY(-1.5707963267948966, wires=[1])]]
>>> diag_groupings
[[PauliZ(wires=[0]) @ PauliZ(wires=[1]),
 PauliZ(wires=[0]) @ PauliZ(wires=[3]),
 PauliZ(wires=[1]) @ PauliZ(wires=[3])],
[PauliZ(wires=[0]),
 PauliZ(wires=[0]) @ PauliZ(wires=[2]),
 PauliZ(wires=[1]) @ PauliZ(wires=[3])]]