quantum_circuit::apply_controlled_gate()← Back to Class quantum_circuit
Apply controlled-Hermitian gate to the circuit
quantum_circuit::apply_controlled_gate(gate, qubit_controls, qubit_targets, name = "A")
gate (matrix) — The matrix representation of the gatequbit_controls (array) — The control qubitsqubit_targets (array) — The target qubitsname (string, optional) — The gate's name. The default value is "A"
quantum_circuit — Returns the instance of class quantum_circuit
import quantum
qc = quantum_circuit(3)
qc.apply_gate(gate_h & gate_h, [0, 1])
qc.apply_controlled_gate(gate_x, [0, 1], [2]) ' Apply CCX (Toffoli) gate