I have a pre-defined quantum circuit with n initial qubits. I want to add m more qubits to it during the calculation as ancillary qubits. How can I do that?
I have a pre-defined quantum circuit with n initial qubits. I want to add m more qubits to it during the calculation as ancillary qubits. How can I do that?
You can add 2 quantum circuits with +
. Below is an example of adding 1 ancillary qubit to the 'data' quantum circuit:
# Define 'data' circuit
qr1 = QuantumRegister(2,'data')
qc1 = QuantumCircuit(qr1)
# Operations on 'data' qubits
qc1.h(0)
qc1.cx(0,1)
# Define an ancillary qubit
qr2 = QuantumRegister(1, 'ancillary')
qc2 = QuantumCircuit(qr2)
# Add the ancillary qubit to the 'data' circuit
q_tot = qc1 + qc2
q_tot.draw('mpl')