如何在sympy.physics.quantum.gate Quater中创建受控的z门
我想知道是否可以使用Sympy.physics.quantum.gate软件包创建受控的Z-Gate?
我尝试了这样的事情
CGate(((0,1), Z(2)))
,其中第一个元组是控件,第二个元组是门,但是我得到了此错误
在多个量子位上设置控件,也能够在任何门中掉落。
另外,是否可以创建一个arbitary旋转门并将其与此使用?例如,我在下面创建的arbitary x旋转门
def Rx(ctrl=1, angle=theta):
"""Rotation in x axis
Args:
ctrl (int, optional): which qubit from bottom up to apply to. Defaults to 1.
angle (_type_, optional): enter angle or leave as theta symbol. Defaults to theta.
Returns:
rotation: set of gate rotations
"""
rot = cos(theta/2)*Im-j*sin(theta/2)*Xm
return UGate((ctrl,), rot.subs(theta, angle))
任何帮助都将不胜感激:)
I am wondering if it is possible to create a controlled Z-Gate using the sympy.physics.quantum.gate package?
I've tried something like this
CGate(((0,1), Z(2)))
where the first tuple are the controls and the second the gate but I'm getting this error
Ideally I'd like to be able to set controls on multiple qubits and to also be able to drop in any gate.
also, is it possible to to create an arbitary rotation gate and use it with this? eg the arbitary x rotation gate I created below
def Rx(ctrl=1, angle=theta):
"""Rotation in x axis
Args:
ctrl (int, optional): which qubit from bottom up to apply to. Defaults to 1.
angle (_type_, optional): enter angle or leave as theta symbol. Defaults to theta.
Returns:
rotation: set of gate rotations
"""
rot = cos(theta/2)*Im-j*sin(theta/2)*Xm
return UGate((ctrl,), rot.subs(theta, angle))
Any help would be really appreciated :)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您创建多控制门的方法应起作用,您只需要删除过多的括号:
Your approach to creating multi-controlled gates should work, you just need to remove excessive parentheses:
感谢@cathulhu 我认为以下将创建任意控制的x,y,z
具有反控制能力的大门。
示例:
Thanks to @cathulhu I think the following will create arbitrary controlled X,Y,Z
gates with the ability to inverse controls.
Example: