This is a follow-up question on composing the quantum circuits. Say if I have the following circuit element:
def qc1(a):
quanc1 = QuantumCircuit(2)
quanc1.x(0)
quanc1.h(1)
quanc1.crz(a,1,0)
quanc1.barrier()
return quanc1
and circ
is a list that contains multiple elements:
circ = []
for i in range (3):
circ.append(qc1(np.pi+i))
Then using the reduce
function, I could combine those 3 circuits and compose them into a larger quantum circuit:
from functools import reduce
qc = QuantumCircuit(5,5)
qc = reduce(lambda x,y: x.compose(y,[2,4]),circ, qc)
The code works to compose the circuits in circ
onto qubit 2 and 4 of qc
:
However, if I have another set of coordinates:
c = [[2,1],[2,4],[2,3]]
Is it possible for me to compose the circuits in circ
onto those pairs of coordinates, separately (instead of the fixed pair [2,4]
)? Or is there a simpler method than using reduce
? Thanks!