CQuIC / qcircuit

A quantum circuit drawing application
GNU General Public License v2.0
166 stars 42 forks source link

Proper way to do equality between circuits? #26

Closed rmonat closed 7 years ago

rmonat commented 7 years ago

Hi,

I would like to write that two quantum circuits C1 and C2 are equal, but with the equal sign at the mid-height circuit C1. Is there any way to do that?

Thank you.

Travis-S commented 7 years ago

Hey @rmonat, just wanted to let you know I saw this and will think about it some. Is this something which needs to be solved soon-ish?

rmonat commented 7 years ago

Thank you, @Travis-S. No, I just saw a conference paper with that kind of equalities and was unable to reproduce it, but it's nothing urgent!

Travis-S commented 7 years ago

Would you mind providing a link to the paper in question? If it's on the arXiv, and they did the qcircuit figures in the paper itself, we might be able to find it there.

rmonat commented 7 years ago

Here is the paper: http://www.cs.ox.ac.uk/people/samuel.staton/papers/popl2015.pdf. There is an example at the bottom of page 2.

Travis-S commented 7 years ago

@rmonat My mistake on not following up with this sooner! You can use qcircuit figures inside LaTeX's mathematical environments; so to make the figure you referenced, you could do this

\[
\Qcircuit @C=1em @R=.7em {
      & \gate{X} & \qw} 
=
\Qcircuit @C=1em @R=.7em {
      & \gate{X} & \qw}
\]

which produces this output: circuit

In principle, this idea could be extended, say using the align environment, if you had several identities you wanted to display.

If this addresses your question, let me know, and I'll close this issue.

rmonat commented 7 years ago

This solves my problem, thank you!

malbergo commented 5 years ago

How might you do this so as to get a two row circuit equality? When I do it, the equals sign remains high up:

image

Code:

\[
\Qcircuit @C=1em @R=1.5em {
& \multigate{1}{\mathcal{G(\theta,\phi)}} & \qw  \\
& \ghost{G(\theta,\phi)} & \qw  \\
}
=
\Qcircuit @C=1em @R=1.5em {
& \multigate{1}{\mathcal{G(\theta,\phi)}} & \qw  \\
& \ghost{G(\theta,\phi)} & \qw \\
}
\]
zzwxy commented 2 years ago

How might you do this so as to get a two row circuit equality? When I do it, the equals sign remains high up:

image

Code:

\[
\Qcircuit @C=1em @R=1.5em {
& \multigate{1}{\mathcal{G(\theta,\phi)}} & \qw  \\
& \ghost{G(\theta,\phi)} & \qw  \\
}
=
\Qcircuit @C=1em @R=1.5em {
& \multigate{1}{\mathcal{G(\theta,\phi)}} & \qw  \\
& \ghost{G(\theta,\phi)} & \qw \\
}
\]

[ You can use \raisebox \Qcircuit @C=1em @R=1.5em { & \multigate{1}{\mathcal{G(\theta,\phi)}} & \qw \ & \ghost{G(\theta,\phi)} & \qw \ } \raisebox{-1.1em}{=} \Qcircuit @C=1em @R=1.5em { & \multigate{1}{\mathcal{G(\theta,\phi)}} & \qw \ & \ghost{G(\theta,\phi)} & \qw \ } ]

evmckinney9 commented 1 year ago

I could not get this example to work using \raisebox. The way I do it is by manually adding an additional row for the equal sign to live in (needed if you have an even number of wires)

\Qcircuit @C=1.0em @R=0.4em @!R {
        & \multigate{2}{\mathrm{U_t}} & \qw & & & \gate{\mathrm{U}} & \multigate{2}{2Q} & \dots & & \multigate{2}{2Q} & \gate{\mathrm{U}} & \qw
        \\
        & & & \push{\rule{0em}{0em}\!\!\!\!\approx\!\!\!\!\rule{0em}{0em}}
        \\
        & \ghost{\mathrm{U_t}} & \qw & & & \gate{\mathrm{U}} & \ghost{2Q} & \dots & & \ghost{2Q} & \gate{\mathrm{U}} &\qw\\
}

output-onlinepngtools