Some of them use https://github.com/Qiskit/qiskit-terra/blob/3b3536bcdb83124d49723dd205573f169c82ea9c/qiskit/circuit/add_control.py#L24 this code to implement the anticontrol X gate
Asked
Active
Viewed 162 times
1 Answers
0
U1Gate
is being replaced by PhaseGate
(aka p
). If you still want to use u1
, replace the import PhaseGate
in this example by import U1Gate as PhaseGate
:
from qiskit import QuantumCircuit
from qiskit.circuit.library import PhaseGate
circuit = QuantumCircuit(2)
circuit.append(PhaseGate(3.14159).control(1, ctrl_state="0"), [0, 1])
print(circuit)
q_0: ─o─────
│P(π)
q_1: ─■─────
The method control
takes the amount of qubits to control on (in this example, 1) and the ctrl_state
. In this case, an anticontrol (aka open control) applies phase rotation on q_1
if the q_0 == 0
.

luciano
- 399
- 4
- 13