pprop.pauli.sentence module¶
This module defines PauliDict, a mapping from PauliOp
to a list of trigonometric coefficient terms.
Coefficient representation¶
Each coefficient is stored as a CoeffTerms,
a list of CoeffTerm tuples of the form
(coeff, sin_idx, cos_idx), encoding the product:
- class pprop.pauli.sentence.PauliDict(data=None)[source]¶
Bases:
objectA mapping from
PauliOptoCoeffTerms.Each
PauliOpkey maps to a list ofCoeffTermtuples, where each tuple encodes one trigonometric product term. The full coefficient at parameters \(\boldsymbol{\theta}\) is:\[\sum_k c_k \prod_{i \in S_k} \sin(\theta_i) \prod_{j \in C_k} \cos(\theta_j)\]where \((c_k, S_k, C_k)\) ranges over the list stored for that key.
- Parameters:
data (dict, optional) – Initial mapping of
PauliOp -> CoeffTerms. IfNone(default), an empty dict is used.
Examples
>>> d = PauliDict() >>> key = PauliOp(0b01, 0b00) # X on qubit 0 >>> d.add_term(key, (0.5, [0], [1])) # 0.5 * sin(θ₀) * cos(θ₁) >>> d.add_term(key, (0.5, [], [0, 1])) # 0.5 * cos(θ₀) * cos(θ₁)
- add_term(key, term)[source]¶
Append a single
CoeffTermto the list forkey.This is the primary accumulation method during Heisenberg propagation: each evolved term is appended without any simplification.
- Parameters:
key (PauliOp) – The Pauli word to which the term belongs.
term (CoeffTerm) – A
(coeff, sin_indices, cos_indices)tuple to append.
- Return type:
None
- add_terms(key, terms)[source]¶
Extend the coefficient list for
keywith multipleCoeffTermtuples.- Parameters:
key (PauliOp) – The Pauli word to update.
terms (CoeffTerms) – A list of
(coeff, sin_indices, cos_indices)tuples to append.
- Return type:
None
- add_terms_from_dict(other)[source]¶
Merge all entries from
otherintoself.For keys present in both dicts the term lists are concatenated; for keys only in
othera copy of their list is inserted.- Parameters:
other (PauliDict) – The source mapping to merge from.
- Return type:
None
- classmethod from_qml(qml_op)[source]¶
Construct a
PauliDictfrom a PennyLane operator.The operator is decomposed into a sum of Pauli words via
pennylane.ops.op_math.sum(). Each Pauli word receives a constant (parameter-independent) coefficient, encoded as aCoeffTermwith emptysin_idxandcos_idxlists.- Parameters:
qml_op (pennylane.operation.Operator) – A PennyLane observable, typically the output of
qml.expval(...).- Return type:
- items()[source]¶
Return a view of
(PauliOp, CoeffTerms)pairs.- Return type:
ItemsView[PauliOp, list[tuple[float, list[int], list[int]]]]