I'm trying to program a controlled gate as the figure below in Qiskit. Should it be sufficient to separate and control individually the Hadamard gates?
2 Answers
It seems like this gate is controlled on the top qubit (which I will call qubit 0) and performs a hadamard on both the other qubits (qubits 1 and 2) when the control is in state $|1\rangle$. In this case it is equivalent to separte two controlled-hadamards: each controlled on qubit 0, with qubit 1 as the target for one and qubit 2 as the target for the other.
The controlled-hadamard can be implemented with ch
. The entire three qubit gate is then as follows.
qc = QuantumCircuit(3)
qc.ch(0,1)
qc.ch(0,2)
-
$\begingroup$ Thank you sir, this is part of a bigger question here. I really appreciate your response. $\endgroup$ Jun 16, 2019 at 21:00
Yes, that notation means the Hadamard on the second qubit depends on the first qubit and the Hadamard on the third qubit depends on the first qubit. The gates aren't connected to each other in any way.
-
2$\begingroup$ Also notice that these two gates commute, so you can separate in either order. $\endgroup$– AHusainJun 13, 2019 at 6:24