Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Appropriate way to add on/off single controlled bloq? #883

Open
fdmalone opened this issue Apr 18, 2024 · 6 comments
Open

Appropriate way to add on/off single controlled bloq? #883

fdmalone opened this issue Apr 18, 2024 · 6 comments

Comments

@fdmalone
Copy link
Collaborator

fdmalone commented Apr 18, 2024

Is there a simpler way to add a singly-controlled bloq:

ctrl_spec = CtrlSpec(cvs=[0])
(ctrl,), q = bb.add(ZGate(), ctrl=(ctrl,), q=q)

seems a little awkward.

Is

ctrl_spec = CtrlSpec(QBit(), cvs=0b0)
ctrl, q = bb.add(ZGate(), ctrl=ctrl, q=q)

preferred?

@mpharrigan
Copy link
Collaborator

sorry, I don't fully understand your code snippets. Where are you using the ctrl_spec in either of them?

ctrl, q = bb.add(ZGate().controlled(), ctrl=ctrl, q=q)

would be how I would do it

@fdmalone
Copy link
Collaborator Author

I want an off-control.

@fdmalone
Copy link
Collaborator Author

Whoops, should have been:

ctrl_spec = CtrlSpec(cvs=[0])
(ctrl,), q = bb.add(ZGate().controlled(ctrl_spec), ctrl=(ctrl,), q=q)

and

ctrl_spec = CtrlSpec(QBit(), cvs=0b0)
ctrl, q = bb.add(ZGate().controlled(ctrl_spec), ctrl=ctrl, q=q)

@mpharrigan
Copy link
Collaborator

So you want a one-bit off-control. In the first one, you have to wrap your ctrl soquet in a lengh-1-list, which seems wrong and annoying. In the second one, you have to specify QBit(). You'd prefer something where you can just put cvs=0? Is this a correct summary of the issue?

@fdmalone
Copy link
Collaborator Author

Right the second way seems a bit verbose. Very low priority though, just ran into it in #882

@mpharrigan
Copy link
Collaborator

Does it not work if you do CtrlSpec(cvs=0)? the default data type should be QBit(), no?

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

No branches or pull requests

2 participants