update the cu3 implementation based on basis gates.
@@ -32,6 +32,7 @@ def apply_cu1(circuit, lam, c, t, use_basis_gates=True):
def apply_cu3(circuit, theta, phi, lam, c, t, use_basis_gates=True):
if use_basis_gates:
+ circuit.u1((lam + phi) / 2, c)
circuit.u1((lam - phi) / 2, t)
circuit.cx(c, t)
circuit.u3(-theta / 2, 0, -(phi + lam) / 2, t)
@@ -40,12 +41,6 @@ def apply_cu3(circuit, theta, phi, lam, c, t, use_basis_gates=True):
else:
circuit.cu3(theta, phi, lam, c, t)
- # the u3 gate below is added to account for qiskit terra's cu3
- # TODO: here or only in if=True clause?
- if not np.isclose(float(phi + lam), 0.0):
- circuit.u3(0, 0, (phi + lam) / 2, c)
-
-
def apply_ccx(circuit, a, b, c, use_basis_gates=True):
if use_basis_gates:
circuit.u2(0, np.pi, c)
