![]() |
Represents operator defined by linear combination of PauliStrings.
cirq.ops.PauliSum(
linear_dict: Optional[value.LinearDict[UnitPauliStringT]] = None
)
Since PauliStrings store their own coefficients, this class does not implement the LinearDict interface. Instead, you can add and subtract terms and then iterate over the resulting (simplified) expression.
Under the hood, this class is backed by a LinearDict with coefficient-less PauliStrings as keys. PauliStrings are reconstructed on-the-fly during iteration.
Attributes | |
---|---|
qubits
|
Methods
copy
copy() -> "PauliSum"
expectation_from_density_matrix
expectation_from_density_matrix(
state: np.ndarray,
qubit_map: Mapping[cirq.ops.Qid
, int],
*,
atol: float = 1e-07,
check_preconditions: bool = True
) -> float
Evaluate the expectation of this PauliSum given a density matrix.
See PauliString.expectation_from_density_matrix
.
Args | |
---|---|
state
|
An array representing a valid density matrix. |
qubit_map
|
A map from all qubits used in this PauliSum to the
indices of the qubits that state is defined over.
|
atol
|
Absolute numerical tolerance. |
check_preconditions
|
Whether to check that state represents a
valid density matrix.
|
Returns | |
---|---|
The expectation value of the input state. |
expectation_from_state_vector
expectation_from_state_vector(
state_vector: np.ndarray,
qubit_map: Mapping[cirq.ops.Qid
, int],
*,
atol: float = 1e-07,
check_preconditions: bool = True
) -> float
Evaluate the expectation of this PauliSum given a state vector.
See PauliString.expectation_from_state_vector
.
Args | |
---|---|
state
|
An array representing a valid state vector. |
qubit_map
|
A map from all qubits used in this PauliSum to the
indices of the qubits that state_vector is defined over.
|
atol
|
Absolute numerical tolerance. |
check_preconditions
|
Whether to check that state_vector represents
a valid state vector.
|
Returns | |
---|---|
The expectation value of the input state. |
expectation_from_wavefunction
expectation_from_wavefunction(
state: np.ndarray,
qubit_map: Mapping[cirq.ops.Qid
, int],
*,
atol: float = 1e-07,
check_preconditions: bool = True
) -> float
THIS FUNCTION IS DEPRECATED.
IT WILL BE REMOVED IN cirq v0.10.0
.
Use expectation_from_state_vector instead.
from_pauli_strings
@classmethod
from_pauli_strings( terms: Union[PauliString, List[PauliString]] ) -> "PauliSum"
matrix
matrix() -> np.ndarray
Reconstructs matrix of self from underlying Pauli operations.
Raises | |
---|---|
TypeError
|
if any of the gates in self does not provide a unitary. |
wrap
@staticmethod
wrap( val:
cirq.ops.PauliSumLike
) -> "PauliSum"
__add__
__add__(
other
)
__bool__
__bool__() -> bool
__eq__
__eq__(
other: _SupportsValueEquality
) -> bool
__iter__
__iter__()
__len__
__len__() -> int
__mul__
__mul__(
other: cirq.ops.PauliSumLike
)
__ne__
__ne__(
other: _SupportsValueEquality
) -> bool
__neg__
__neg__()
__pow__
__pow__(
exponent: int
)
__radd__
__radd__(
other
)
__rmul__
__rmul__(
other: cirq.ops.PauliSumLike
)
__rsub__
__rsub__(
other
)
__sub__
__sub__(
other
)
__truediv__
__truediv__(
a: cirq.value.Scalar
)