// stdgates.inc's own definitions of x, h, ry and u3, written into the program // under other names and used under `ctrl @`: the global phases each writes // with `U` and `gphase` are the ones the library's gates carry, so each is the // library's controlled gate (the reference writes cx, ch, cry and cu). OPENQASM 3.1; include "stdgates.inc"; gate my_x a { U(π, 0, π) a; gphase(-π/2);} gate my_h a { U(π/2, 0, π) a; gphase(-π/4);} gate my_ry(θ) a { U(θ, 0, 0) a; gphase(-θ/2);} gate my_u3(θ, φ, λ) q { gphase(-(φ+λ+θ)/2); U(θ, φ, λ) q; } qubit[3] q; h q[0]; ry(0.9) q[1]; rx(-0.4) q[2]; ctrl @ my_x q[0], q[1]; ctrl @ my_h q[1], q[2]; ctrl @ my_ry(0.7) q[2], q[0]; ctrl @ my_u3(0.3, 0.5, 0.7) q[0], q[2];