I'm interested in implementing a controlled-swap operation on quantum registers. However, it appears that Qiskit's documentation primarily focuses on single qubits rather than registers. Could you provide guidance on how to implement controlled-swap operations specifically on quantum registers?


1 Answer 1


Assuming the two registers $q_1$ and $q_2$ have the same number of qubits then you can apply a controlled swap on the $i$-th qubits of $q_1$ and $q_2$ for each $i=1,2,\dots,n$ where $n$ is the number of qubits in each register. The Qiskit code would look something like this:

for i in range(n):
    qc.cswap(control, qr1[i], qr2[I])

while the circuit looks like this (for $n=3$):



Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.