1112
June 2, 2022, 7:16am
1
My initial circuit is as follows:
def U(params, wires):
qml.RY(params[0], wires=wires[0])
but I want to plus one gate on wire[1] as follows, May I ask how can I increase the gate?(If I don’t directly qml.RY(params[1], wires=wires[1]) this line of code),I want the initial circuit to perform the added action.
def U(params, wires):
qml.RY(params[0], wires=wires[0])
qml.RY(params[1], wires=wires[1])
Hi @1112 ,
Could you explain your problem some more please?
If I’m understanding correctly you want to add some gates depending on the number of wires. Is this what you’re looking for?
If so, the following code should work for you
num_wires = 2
dev = qml.device('default.qubit',wires=num_wires)
@qml.qnode(dev)
def U(params, wires):
for wire in wires:
qml.RY(params[wire], wires=wires[wire])
return qml.expval(qml.PauliZ(0))
qml.draw_mpl(U)([1,1],range(num_wires))
Please let me know if this is what you were looking for!