qml.pauli.PauliWord

class PauliWord(mapping)[source]

Bases: dict

Immutable dictionary used to represent a Pauli Word, associating wires with their respective operators. Can be constructed from a standard dictionary.

>>> w = PauliWord({"a": 'X', 2: 'Y', 3: 'Z'})
>>> w
X(a) @ Y(2) @ Z(3)

wires

Track wires in a PauliWord.

wires

Track wires in a PauliWord.

hamiltonian([wire_order])

Return Hamiltonian representing the PauliWord.

map_wires(wire_map)

Return a new PauliWord with the wires mapped.

operation([wire_order, get_as_tensor])

Returns a native PennyLane Operation representing the PauliWord.

to_mat(wire_order[, format])

Returns the matrix representation.

update(_PauliWord__m, **kwargs)

Restrict updating PW after instantiation.

hamiltonian(wire_order=None)[source]

Return Hamiltonian representing the PauliWord.

map_wires(wire_map)[source]

Return a new PauliWord with the wires mapped.

operation(wire_order=None, get_as_tensor=False)[source]

Returns a native PennyLane Operation representing the PauliWord.

to_mat(wire_order, format='dense')[source]

Returns the matrix representation.

Keyword Arguments
  • wire_order (iterable or None) – The order of qubits in the tensor product.

  • format (str) – The format of the matrix (“dense” by default), if not a dense matrix, then the format for the sparse representation of the matrix.

Returns

Matrix representation of the Pauliword

Return type

(Union[NumpyArray, ScipySparseArray])

Raises

ValueError – Can’t get the matrix of an empty PauliWord.

update(_PauliWord__m, **kwargs)[source]

Restrict updating PW after instantiation.