I am interested in using the QASM2Cirq methods to make this gate: u2(0, np.pi, q[0]).

How can I build that object using Cirq rather than QASM string value passed onto cirq.


From the spec, $U_2(\phi, \lambda) = U ( \frac{\pi}{2}, \phi, \lambda)$. We can use Cirq's QasmUGate.

import cirq
from cirq.circuits.qasm_output import QasmUGate

q0 = cirq.NamedQubit('q[0]')
u2_gate = QasmUGate(0.5, 0, 1) # The angles are normalized to the range [0, 2) half_turns
circuit = cirq.Circuit(u2_gate(q0))

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.