cirq.ops.ProjectorSum

linear_dict A linear dictionary from a set of tuples of (Qubit, integer) to a complex number. The tuple is a projector onto the qubit and the complex number is the weight of these projections.

qubits

Methods

copy

View source

expectation_from_density_matrix

View source

Expectation of the sum of projections from a density matrix.

Projects the density matrix onto the sum of projectors and computes the expectation of the measurements.

Args
state An array representing a valid density matrix.
qid_map A map from all qubits used in this ProjectorSum to the indices of the qubits that state_vector is defined over.

Returns
The expectation value of the input state.

expectation_from_state_vector

View source

Compute the expectation value of this ProjectorSum given a state vector.

Projects the state vector onto the sum of projectors and computes the expectation of the measurements.

Args
state_vector An array representing a valid state vector.
qid_map A map from all qubits used in this ProjectorSum to the indices of the qubits that state_vector is defined over.

Returns
The expectation value of the input state.

from_projector_strings

View source

Builds a ProjectorSum from one or more ProjectorString(s).

Args
terms Either a single ProjectorString or a list of ProjectorStrings.

Returns
A ProjectorSum.

matrix

View source

Returns the matrix of self in computational basis of qubits.

Args
projector_qids Ordered collection of qubits that determine the subspace in which the matrix representation of the ProjectorSum is to be computed. Qbits absent from self.qubits are acted on by the identity. Defaults to the qubits of the projector_dict.

Returns
A sparse matrix that is the projection in the specified basis.

__add__

View source

__bool__

View source

__eq__

View source

__iter__

View source

__len__

View source

__mul__

View source

__ne__

View source

__neg__

View source

__rmul__

View source

__sub__

View source

__truediv__

View source