0

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.

Enrique Segura
  • 1,011
  • 6
  • 9

1 Answers1

3

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))
Victory Omole
  • 2,332
  • 1
  • 10
  • 24