Skip to content

[add] targy gate#38

Open
erkue wants to merge 2 commits intoMc-Zen:mainfrom
erkue:main
Open

[add] targy gate#38
erkue wants to merge 2 commits intoMc-Zen:mainfrom
erkue:main

Conversation

@erkue
Copy link

@erkue erkue commented Jul 6, 2025

Adds a targy gate that behaves similiar to targ but is visualized as a gray triangle.

Example snippet:

#quantum-circuit(
  1, ctrl(1), 1, [\ ],
  1, targy(), 1
)

The visualisation is inspired by Stim.

@erkue
Copy link
Author

erkue commented Jul 7, 2025

Here is a small demo

targy-demo

Code:

#set page(width: auto, height: auto, margin: 20pt, numbering: none)

#grid(
columns: 3,

quantum-circuit(
  1, ctrl(1), 1, [\ ],
  1, targy(), 1
),

quantum-circuit(
  1, targy(1), 1, [\ ],
  1, ctrl(), 1
),

quantum-circuit(targy())
)

@Mc-Zen
Copy link
Owner

Mc-Zen commented Jul 7, 2025

Hi, thanks for the contribution. I have few questions before merging this: Where in Stim is this used exactly and does the name also come from Stim? Does it represent the exact entity as the regular target symbol?

(I have never seen this being used in a publication so far)

@erkue
Copy link
Author

erkue commented Jul 7, 2025

In stim the symbol is used to visualize a controlled-Y operation. In that sense, it behaves similiar to the controlled-X operation.

In the PR, the symbol is implemented exactly the same as the targ entity. Except for the draw-targy function which, of course, draws a different object.

@Mc-Zen
Copy link
Owner

Mc-Zen commented Jul 7, 2025

I see, sounds good.

Currently, targy has a parameter fill but it does not use it. We could change the default of the parameter to auto and have some "smart" setting for this case. However, I'm not sure what a sensible smart setting could be. Lightening up the wire color does not make too much sense to me. What about the case of a white wire stroke on a dark background? Maybe the default to targy should just be a fixed shade of gray (instead of auto)?

But in any case, if the user explicitly changes the fill, the fill should be applied as provided.

Also, I feel like the function should be called targ-y which helps with readability and clearity.

@Mc-Zen
Copy link
Owner

Mc-Zen commented Jul 7, 2025

One note about the rendering: In Stim, the diagram is positioned such that the center of the circumcircle of the triangle sits on the wire. In contrast, with your implementation the triangle's center (measured from the the top edge to the bottom tip) sits on the wire.

I'm not quite sure about it but on first sight I like your version more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants