List of mappings representing a sum of projector operators.
cirq.ProjectorSum(
linear_dict: Optional[value.LinearDict[FrozenSet[Tuple[raw_types.Qid, int]]]] = None
)
Args |
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.
|
Methods
copy
View source
copy() -> 'ProjectorSum'
expectation_from_density_matrix
View source
expectation_from_density_matrix(
state: np.ndarray,
qid_map: Mapping[cirq.Qid
, int]
) -> float
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
expectation_from_state_vector(
state_vector: np.ndarray,
qid_map: Mapping[cirq.Qid
, int]
) -> float
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
@classmethod
from_projector_strings(
terms: Union[ProjectorString, List[ProjectorString]]
) -> 'ProjectorSum'
Builds a ProjectorSum from one or more ProjectorString(s).
Args |
terms
|
Either a single ProjectorString or a list of ProjectorStrings.
|
matrix
View source
matrix(
projector_qids: Optional[Iterable[raw_types.Qid]] = None
) -> csr_matrix
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
__add__(
other: Union['ProjectorString', 'ProjectorSum']
)
__bool__
View source
__bool__() -> bool
__eq__
View source
__eq__(
other: _SupportsValueEquality
) -> bool
__iter__
View source
__iter__()
__len__
View source
__len__() -> int
__mul__
View source
__mul__(
other: value.Scalar
)
__ne__
View source
__ne__(
other: _SupportsValueEquality
) -> bool
__neg__
View source
__neg__()
__rmul__
View source
__rmul__(
other: value.Scalar
)
__sub__
View source
__sub__(
other: Union['ProjectorString', 'ProjectorSum']
)
__truediv__
View source
__truediv__(
a: value.Scalar
)