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
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
Correct answer by Heriotic on December 27, 2020
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP