Appropriate way to add on/off single controlled bloq?
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?
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
I want an off-control.
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)
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?
Right the second way seems a bit verbose. Very low priority though, just ran into it in #882
Does it not work if you do CtrlSpec(cvs=0)? the default data type should be QBit(), no?