qml.pauli.observables_to_binary_matrix

observables_to_binary_matrix(observables, n_qubits=None, wire_map=None)[source]

Converts a list of Pauli words into a matrix where each row is the binary vector (symplectic) representation of the observables.

The dimension of the binary vectors (the number of columns) will be implied from the highest wire being acted on non-trivially by the Pauli words in observables.

Parameters
  • observables (list[Union[Identity, PauliX, PauliY, PauliZ, Tensor, Prod, SProd]]) – the list of Pauli words

  • n_qubits (int) – number of qubits to specify dimension of binary vector representation

  • wire_map (dict) – dictionary containing all wire labels used in the Pauli words as keys, and unique integer labels as their values

Returns

a matrix whose rows are Pauli words in binary vector (symplectic) representation.

Return type

array[array[int]]

Example

>>> observables_to_binary_matrix([X(0) @ Y(2), Z(0) @ Z(1) @ Z(2)])
array([[1., 1., 0., 0., 1., 0.],
       [0., 0., 0., 1., 1., 1.]])