cirq.LinearCombinationOfOperations

class cirq.LinearCombinationOfOperations(terms: Mapping[cirq.ops.raw_types.Operation, Union[complex, float]])[source]

Represents operator defined by linear combination of gate operations.

If G1, …, Gn are gate operations, {q1_1, …, q1_k1}, {q2_1, …, q2_k2},
…, {qn_1, …, qn_kn} are (not necessarily disjoint) sets of qubits and
b1, b2, …, bn are complex numbers, then
LinearCombinationOfOperations({
    G1(q1_1, ..., q1_k1): b1,
    G2(q2_1, ..., q2_k2): b2,
    ...,
    Gn(qn_1, ..., qn_kn): bn})

represents the linear operator

A = b1 G1(q1_1, ..., q1_k1) +
  + b2 G2(q2_1, ..., q2_k2) +
  + ... +
  + bn Gn(qn_1, ..., qn_kn)
where in each term qubits not explicitly listed are assumed to be acted on
by the identity operator. Note that A may not be unitary or even normal.
__init__(terms: Mapping[cirq.ops.raw_types.Operation, Union[complex, float]]) → None[source]

Initializes linear combination from a collection of terms.

Parameters

terms – Mapping of gate operations to coefficients in the linear combination being initialized.