Suppose I have created a circuit composed of some registers with the usual
qc = QuantumCircuit(qr, cr)
cr are a quantum register and a classical register respectively.
Now, suppose that at this point I want to invoke a subroutine. This subroutine, however, uses some ancillas. Is there any functions to append this new set of qubits to the original circuit? Something like
ancillas = QuantumRegister(n, 'ancillas') #qc.append(ancillas)
An equivalent problem (maybe) is the following one. Suppose I have a quantum circuit
qcn composed of
n qubits and a subroutine which returns another quantum circuit
qck operating on
k qubits, with
k > n. Is it possible to compose the two circuits in such a way that the first
n qubits on which the subroutine operates are the same of the original circuit?
At the moment, the only solution to me seems to declare in advance all the total number of qubits required (
k in the previous case) and then passing around them to the various functions.