projekter/yquant

Mark "output" qubits

Closed this issue · 3 comments

In a few papers I am reading, a black triangle is used to mark the "output" qubits, like shown below. Is there something similar implemented in yquant? Otherwise, do you have any suggestion on how to achieve the same result?
image

No, there is nothing like this implemented currently. I have not seen this kind of notation before. Do you think it is useful? To highlight certain registers, it is always possible to assign styles to the lines (colors, thickness, whatever)...

If you want to reproduce this, I can think of various ways:

  • First, give a name to the register when it is created: [name=outreg] qubit x;. Next, give a name to the shape of the relevant gate: [name=squ] box {squ} (x, y);. Finally, draw the triangles in whichever way you want (you might use a node with \blacktriangleright, do the drawing by yourself, define a TikZ pic, ...). To place the drawing accurately, you take the vertical position of the register and the horizontal position of the gate.
    \documentclass[tikz]{standalone}
    
    \usepackage[compat=0.7]{yquant}
    \usepackage{amssymb}
    
    \begin{document}
       \begin{tikzpicture}
          \begin{yquant}[operator/separation=10pt]
             [name=outreg] qubit x;
             qubit y;
             
             h -; % just to do something
             [name=squ] box {squ} (-);
             \node[inner sep=0pt] at (outreg -| squ.west) {$\blacktriangleright$};
             \node[inner sep=0pt, anchor=west] at (outreg -| squ.east) {$\blacktriangleright$};
             x -;
          \end{yquant}
       \end{tikzpicture}
    \end{document}
  • If you need this more often, you will probably get bored of repeating it multiple times. Define a macro that does the job for you. The following example first takes the name of the register where to place the triangles, then the code for the gate. Note here I added small shifts to the nodes to better resemble your picture - but this will depend on the font that is used for the triangle.
    \documentclass[tikz]{standalone}
    
    \usepackage[compat=0.7]{yquant}
    \usepackage{amssymb}
    
    \newcommand\withoutput[2]{%
       \yquant [name=outputgate] #2;
       \node[inner sep=0pt, xshift=1.5pt] at (#1 -| outputgate.west) {$\blacktriangleright$};
       \node[inner sep=0pt, anchor=west, xshift=-1pt] at (#1 -| outputgate.east) {$\blacktriangleright$};
    }
    
    \begin{document}
       \begin{tikzpicture}
          \begin{yquant}[operator/separation=10pt]
             [name=outreg] qubit x;
             [name=otheroutreg] qubit y;
             
             h -; % just to do something
             \withoutput{outreg}{box {squ} (-)}
             x -;
             \withoutput{otheroutreg}{box {next} (-)}
          \end{yquant}
       \end{tikzpicture}
    \end{document}
  • Define a new triangle gate, which overwrites the internal positioning mechanism, allowing overlaps with the following gate. This requires to use the backend gate construction mechanism. You can have a look at the code for the slash gate that does precisely such an overwrite. And of course, you have to define the appropriate shape - probably best to have a look at the circle shape, from which adaption should be pretty straightforward.

Closed due to no further reaction

@projekter I somehow missed your reply.
To answer yout question, I saw it in a few papers, and it is used to express the result of mathematical operation. Take a look at this picture for example.

By the way, thanks for your solution. From a few quick tests, it seems to work perfectly.