TransWikia.com

Can a Qubit belong to 2 different registers?

Quantum Computing Asked by Sourcerer on December 27, 2020

I’m starting with Qiskit in Python.

My question is regarding to have registers and sub-register. Something like this

axreg=QuantumRegister(4,name='ax')
ahreg=QuantumRegister(axreg[:2],name='ah')
alreg=QuantumRegister(axreg[2:],name='al')

The constructor of QuantumRegister has only the number of qubits to create, and I find no way to add previously existing qubit to other register

One Answer

If you want to add previously existing qubits to other register you can obviously compose or append to add previously existing qubits to other register, let's say we have have two qubits who are in state |++> and we want to add them to our register which has for example 4 qubits, we can do

sub_circuit = QuantumCircuit(2)
circuit = QuantumCircuit(4)
qr = circuit.qregs[0]
circuit.x(range(4))
sub_circuit.h(range(2))
circuit = circuit.append(sub_circ.to_instruction(), [qr[0], qr[1]])

You'll get something like this

picture of the final circuit

Correct answer by Heriotic on December 27, 2020

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP