quantum-compiler / quartz

The Quartz Quantum Compiler
Apache License 2.0
76 stars 19 forks source link

[gate] Support parsing general controlled gates #143

Closed xumingkuan closed 10 months ago

xumingkuan commented 10 months ago

Close #105

Now we can read and write general controlled gates.

In OpenQASM 2 (the format we write to and read from):

//ctrl
x q[5];
ccz q[5],q[6],q[8];
x q[5];

In CircuitSeq::to_string():

[Q5, Q6, Q8] = ccz[01](Q5, Q6, Q8)

OpenQASM 3 equivalent (not supported):

negctrl @ ctrl @ z q[5],q[6],q[8];

Compare with common controlled gates: In OpenQASM 2 (the format we write to and read from):

ccz q[5],q[6],q[8];

In CircuitSeq::to_string():

[Q5, Q6, Q8] = ccz(Q5, Q6, Q8)

OpenQASM 3 equivalent (not supported):

ctrl(2) @ z q[5],q[6],q[8];