qml.pauli.pauli_word_prefactor¶
-
pauli_word_prefactor
(observable)[source]¶ If the operator provided is a valid Pauli word (i.e a single term which may be a tensor product of pauli operators), then this function extracts the prefactor.
- Parameters
observable (Operator) – the operator to be examined
- Returns
The scaling/phase coefficient of the Pauli word.
- Return type
Union[int, float, complex]
- Raises
ValueError – If an operator is provided that is not a valid Pauli word.
Example
>>> pauli_word_prefactor(qml.Identity(0)) 1 >>> pauli_word_prefactor(qml.PauliX(0) @ qml.PauliY(1)) 1 >>> pauli_word_prefactor(qml.PauliX(0) @ qml.PauliY(0)) 1j
code/api/pennylane.pauli.pauli_word_prefactor
Download Python script
Download Notebook
View on GitHub