I want to understand this Qiskit function (a function for creating the gate CNX with Python): more specifically i don't understand what's the rotations (Y and Z) over the qubits for ? I added inline questions in the code below :

def cnx(qc, *qubits):
if len(qubits) >= 3:
last = qubits[-1]
#What's the goal of the next two lines ?
qc.crz(np.pi/2, qubits[-2], qubits[-1])
qc.cry(np.pi/2, 0, 0, qubits[-2],qubits[-1])

#Is this a recursive call to cnx ?
cnx(qc,*qubits[:-2],qubits[-1])

#what's this flip yielding ?
qc.cry(-np.pi/2, 0, 0, qubits[-2], qubits[-1])


• Hi! Could you tell us where you found this function? I searched for "cnx" in qiskit-terra, without any result. I also searched "cnx" in qiskit-aqua and the only results are commits showing that the cnx function has been removed the 9th of May. Jul 5 '19 at 20:33