A control qubit conditionally determines whether a gate acts on a target qubit. In a state array, the gate recombines only amplitude pairs whose control positions contain 1; pairs with 0 remain unchanged. section 4.4 section 4.6
Use the control position to reason about controlled transformations:
- Find outcome pairs that differ only at the target position. section 4.4
- Keep only pairs whose control-bit positions contain 1. section 4.4
- Apply the gate formula to each selected pair; a controlled X swaps the selected amplitudes. section 4.4
- Add more controls by requiring every control position to contain 1. section 4.4.2
Python controlled transformation
A simulator can filter the pairs generated for target t with is_bit_set(p[0], c), then process each surviving pair. Calling c_transform(state, 1, 2, x) swaps outcomes 2 and 6, and outcomes 3 and 7. With controls [1, 2] and target 0, only outcomes 6 and 7 are swapped. section 4.4.1 section 4.4.2
Figure 4.25 The pairs of outcomes for applying a controlled single-qubit gate to a three-qubit system with target qubit 0 and control qubit 2
Use the outcome-pair diagram to see how target position and control position select the amplitude pairs processed by a controlled gate. section 4.4

