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 :)
Your approach to creating multi-controlled gates should work, you just need to remove excessive parentheses:
gate = CGate((0, 1), Z(2))
qapply(gate * Qubit('111'))