python量子计算模拟器
QSystem的Python项目详细描述
Q系统
python的量子计算模拟器。
qsystem模拟器的灵感来自于量子电路模型,因此很容易 将任何量子电路转换为python。
例如以下示例:
fromqsystemimportQSystemfromcmathimportexp,piq=QSystem(3,24)# init q0, q1, q2q.evol(gate='H',qbit=0,count=3)# H q0; H q1; H q2q.add_ancillas(4)# init a0, a1, a2, a3q.evol(gate='X',qbit=6)# X a3q.cnot(target=4,control=[2])# CNOT a1, q2q.cnot(5,[2])# CNOT a2, q2q.cnot(5,[3])# CNOT a2, a0q.cnot(3,[1,5])# Toffoli a1, q1, a2q.cnot(5,[3])# CNOT a2, a0q.cnot(4,[6])# CNOT a1, a3q.cnot(6,[1,4])# Toffoli a3, q1, a1q.cnot(4,[6])# CNOT a1, a3q.measure(qbit=3,count=4)# measure a0, a1, a2, a3print('ancillas measurement =',q.bits()[3:])# ancillas measurement = [0, 1, 0, 0]q.rm_ancillas()# rm a0, a1, a2, a3q.evol('H',0)# H q0 ┐q.cphase(phase=1j,target=1,control=[0])# Controlled S q1, q0 │q.evol('H',1)# H q1 │q.cphase(exp(pi*1j/4),2,[0])# Controlled T q2, q0 │ = q.qft(0, 3)q.cphase(1j,2,[1])# Controlled S q2, q1 │q.evol('H',2)# H q1 │q.swap(0,2)# SWAP q0, q2 ┘q.measure(0,3)# measure q0, q1, q2print('final measurement =',q.bits())# final measurement = [1, 0, 0]
这个软件由