cirq.ControlledGate¶

class cirq.ControlledGate(sub_gate: cirq.ops.raw_types.Gate, num_controls: int = None, control_values: Optional[Sequence[Union[int, Collection[int]]]] = None, control_qid_shape: Optional[Sequence[int]] = None)[source]

Augments existing gates to have one or more control qubits.

This object is typically created via gate.controlled().

__init__(sub_gate: cirq.ops.raw_types.Gate, num_controls: int = None, control_values: Optional[Sequence[Union[int, Collection[int]]]] = None, control_qid_shape: Optional[Sequence[int]] = None) → None[source]
Initializes the controlled gate. If no arguments are specified for
the controls, defaults to a single qubit control.
Parameters
• sub_gate – The gate to add a control qubit to.

• num_controls – Total number of control qubits.

• control_values – For which control qubit values to apply the sub gate. A sequence of length num_controls where each entry is an integer (or set of integers) corresponding to the qubit value (or set of possible values) where that control is enabled. When all controls are enabled, the sub gate is applied. If unspecified, control values default to 1.

• control_qid_shape – The qid shape of the controls. A tuple of the expected dimension of each control qid. Defaults to (2,) * num_controls. Specify this argument when using qudits.