In Qiskit, I am trying to perform controlled-Swap (cswap) of two registers, but an error occurs:
from qiskit import QuantumCircuit, ClassicalRegister, QuantumRegister from qiskit import execute, IBMQ, Aer c = ClassicalRegister(1) ancilla = QuantumRegister( 1 ) phi = QuantumRegister(4, 'phi') psi = QuantumRegister(4, 'psi') qc = QuantumCircuit(ancilla, phi, psi, c) qc.h(ancilla) qc.swap(phi, psi) qc.cswap(ancilla, phi, psi)
The swap works, exchanging each qubit of the first register (phi) with each qubit of the second register (psi), I expected that the cswap would work in the same way but the following error occurs:
qiskit.qiskiterror.QiskitError: "QuantumRegister(4, 'phi') is not a tuple.A qubit should be formated as a tuple."
I have read this answer but it didn't help