def continuousTeleportationSimulation(psi, c_ops=[]): N = 8 psi0 = tensor([basis(2, 0), psi] + [basis(2, 0) for i in range(N - 2)]) schedule = [] # encoding, Hadamards stage 1, 2 schedule.append((constructHadamardH(N, range(N)), constructHadamardCorr(N, range(N)), np.pi)) # encoding, CZs, stage 3 schedule.append((constructCZH(N, [0, 2, 4], [1, 3, 5]), None, np.pi)) # encoding, Hadamards, stage 4, 5 schedule.append((constructHadamardH(N, [1, 3, 5]), constructHadamardCorr(N, [1, 3, 5]), np.pi)) # teleportation, stage 6 schedule.append((osum([Sy(N, i) for i in [1, 2, 3, 4]]), None, np.pi / 2.)) # teleportation, stage 7 schedule.append( (osum([Sz(N, i) for i in [1, 2, 3, 4]]), None, -np.pi / 2.)) # teleportation, stage 8 schedule.append((constructCZH(N, [1, 3], [2, 4]), None, np.pi)) # teleportation, stage 9 schedule.append( (osum([Sy(N, i) for i in [1, 2, 3, 4]]), None, -np.pi / 2.)) # decoding, stage 10, 11 schedule.append( (constructHadamardH(N, [1, 3]), constructHadamardCorr(N, [1, 3]), np.pi)) # decoding, stage 12 schedule.append((constructCZH(N, [0, 2], [1, 3]), None, np.pi)) # decoding, stage 13, 14 schedule.append((constructHadamardH(N, [0, 1, 2, 3]), constructHadamardCorr(N, [0, 1, 2, 3]), np.pi)) # perform time evolution and return the final state return scheduledTimeEvolution(psi0, schedule, c_ops=c_ops)
def continuousDecodingSimulation(psi0, c_ops=[]): N = 8 schedule = [] # decoding, stage 1, 2 schedule.append( (constructHadamardH(N, [5, 7]), constructHadamardCorr(N, [5, 7]), np.pi)) # decoding, stage 3 schedule.append((constructCZH(N, [4, 6], [5, 7]), None, np.pi)) # decoding, stage 4, 5 schedule.append((constructHadamardH(N, [4, 5, 6]), constructHadamardCorr(N, [4, 5, 6]), np.pi)) return scheduledTimeEvolution(psi0, schedule, c_ops=c_ops)
def testHadamardUnitary(self): H = constructHadamardH(1, [0]) U = snot() U2 = deriveUnitary(H, np.pi) Ucorr = constructHadamardCorr(1, [0]) assert Ucorr*U2 == U assert H.isherm
def testHadamardUnitaryMulti(self): H = constructHadamardH(2, [0, 1]) UH1 = snot(N=2, target=0) UH2 = snot(N=2, target=1) U2 = deriveUnitary(H, np.pi) Ucorr = constructHadamardCorr(2, [0, 1]) assert Ucorr*U2 == UH1*UH2 assert H.isherm
def testHadamardHamiltonian(self): t = np.pi H = constructHadamardH(1, [0]) U = snot() Ucorr = constructHadamardCorr(1, [0]) for psi0 in [z0, z1, xp, xm, yp, ym, rand_ket(2)]: psiu = U*psi0 psif = evolve(H, t/2., psi0) psic = Ucorr*psif overl = psiu.overlap(psic) assert are_close(overl, 1.) assert H.isherm