How to use the pyqpanda.pyQPanda.cAlloc_many function in pyqpanda

To help you get started, we’ve selected a few pyqpanda examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github OriginQ / QPanda-2 / pyQPanda / test2.py View on Github external
data = {'shots':1000}
    result=machine.run_with_configuration(prog,clist,data) 
    print("result11111",result)
    pq.destroy_quantum_machine(machine)
    

    machine2=pq.init_quantum_machine(pq.QMachineType.CPU)
    qlist2=machine2.qAlloc_many(3)
    prog2=pq.QProg()
    prog2.insert(pq.H(qlist2[0])).insert(pq.CNOT(qlist2[0],qlist2[1]))
    result2=machine2.prob_run_dict(prog2,qlist2,-1)
    pq.destroy_quantum_machine(machine2)

    pq.init(pq.QMachineType.CPU)
    qlist3=pq.qAlloc_many(5)
    clist3=pq.cAlloc_many(5)
    prog3=pq.QProg()
    prog3.insert(pq.H(qlist3[0])).insert(pq.CNOT(qlist3[0],qlist3[1]))\
         .insert(pq.CNOT(qlist3[1],qlist3[2])).insert(pq.CNOT(qlist3[2],qlist3[3]))\
         .insert(pq.meas_all(qlist3,clist3))
    result3=pq.run_with_configuration(prog3,clist3,100)
    pq.finalize()


    return result,result2,result3
if __name__=="__main__":