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)
Attributes
Methods
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, coeff])Returns the matrix representation.
update
(_PauliWord__m, **kwargs)Restrict updating PW after instantiation.
-
hamiltonian
(wire_order=None)[source]¶ Return
Hamiltonian
representing the PauliWord.
-
operation
(wire_order=None, get_as_tensor=False)[source]¶ Returns a native PennyLane
Operation
representing the PauliWord.
-
to_mat
(wire_order=None, format='dense', coeff=1.0)[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. It is “dense” by default. Use “csr” for sparse.
coeff (float) – Coefficient multiplying the resulting matrix.
- Returns
Matrix representation of the Pauli word.
- Return type
(Union[NumpyArray, ScipySparseArray])
- Raises
ValueError – Can’t get the matrix of an empty PauliWord.
-