qit.gate.controlled¶
- qit.gate.controlled(U, ctrl=(1,), dim=None)¶
Controlled gate.
- Parameters
U (array[complex], Lmap) – unitary operator
ctrl (vector[int]) – control nodes
dim (tuple[int]) – control subsystem dimensions
- Returns
controlled-U gate
- Return type
Returns the
(t+1)
-qudit controlled-U gate, wheret == len(ctrl)
.ctrl
defines the control nodes. It has one entry k per control qudit, denoting the required computational basis state \(\ket{k}\) for that particular qudit. Value k == -1 denotes no control.dim is the dimensions vector for the control qudits. If not given, all controls are assumed to be qubits.
Examples
controlled(NOT, [1])
gives the standard CNOT gate.controlled(NOT, [1, 1])
gives the Toffoli gate.