cirq.ops.PauliSum

Represents operator defined by linear combination of PauliStrings.

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.

qubits

Methods

copy

View source

expectation_from_density_matrix

View source

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

View source

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

View source

THIS FUNCTION IS DEPRECATED.

IT WILL BE REMOVED IN cirq v0.10.0.

Use expectation_from_state_vector instead.

from_pauli_strings

View source

matrix

View source

Reconstructs matrix of self from underlying Pauli operations.

Raises
TypeError if any of the gates in self does not provide a unitary.

wrap

View source

__add__

View source

__bool__

View source

__eq__

View source

__iter__

View source

__len__

View source

__mul__

View source

__ne__

View source

__neg__

View source

__pow__

View source

__radd__

View source

__rmul__

View source

__rsub__

View source

__sub__

View source

__truediv__

View source