cirq.ProductOfSums

Represents control values as N OR (sum) clauses, each of which applies to one qubit.

is_trivial

Methods

expand

View source

Returns an expanded cirq.SumOfProduct representation of this control values.

validate

View source

Validates that all control values for ith qubit are in range [0, qid_shaped[i])

__and__

View source

Returns a cartesian product of all control values predicates in self x other.

The and of two control values cv1 and cv2 represents a control value object acting on the union of qubits represented by cv1 and cv2. For example:

cv1 = cirq.ProductOfSums([(0, 1), 2])
cv2 = cirq.SumOfProducts([[0, 0], [1, 1]])
assert cirq.num_qubits(cv1 & cv2) == cirq.num_qubits(cv1) + cirq.num_qubits(cv2)

Args
other An instance of AbstractControlValues.

Returns
An instance of AbstractControlValues that represents the cartesian product of control values represented by self and other.

__eq__

View source

__getitem__

View source

__iter__

View source

Iterator on internal representation of control values used by the derived classes.

>>> print(*cirq.ProductOfSums([(0, 1), (0,)]))
(0, 1) (0,)
>>> print(*cirq.SumOfProducts([(0, 0), (1, 0)]))
(0, 0) (1, 0)

__ne__

View source

__or__

View source

Returns a union of all control values predicates in self + other.

Both self and other must represent control values for the same set of qubits and hence their or would also be a control value object acting on the same set of qubits. For example:

cv1 = cirq.ProductOfSums([(0, 1), 2])
cv2 = cirq.SumOfProducts([[0, 0], [1, 1]])
assert cirq.num_qubits(cv1 | cv2) == cirq.num_qubits(cv1) == cirq.num_qubits(cv2)

Args
other An instance of AbstractControlValues.

Returns
An instance of AbstractControlValues that represents the union of control values represented by self and other.

Raises
ValueError If cirq.num_qubits(self) != cirq.num_qubits(other).