def teleport(state, mres): X = rx(-math.pi, 3, 2) Z = rz(-math.pi, 3, 2) print(mres) if mres == 0: bra0 = bra("000") bra1 = bra("001") state = state if mres == 1: bra0 = bra("010") bra1 = bra("011") state = X * state if mres == 2: bra0 = bra("100") bra1 = bra("101") state = Z * state if mres == 3: bra0 = bra("110") bra1 = bra("111") state = Z * X * state pr0 = (bra0 * state).tr() pr1 = (bra1 * state).tr() return (pr0 * basis(2, 0) + pr1 * basis(2, 1)).unit()
def Z(self, qubit): """ Perform pauli Z gate on a qubit. Args: qubit (Qubit): Qubit on which gate should be applied to. """ gate = rz(np.pi) qubit_collection, name = qubit.qubit qubit_collection.apply_single_gate(gate, name)
def rz(self, qubit, phi): """ Perform a rotation pauli z gate with an angle of phi. Args: qubit (Qubit): Qubit on which gate should be applied to. phi (float): Amount of rotation in Rad. """ gate = rz(phi) qubit_collection, name = qubit.qubit qubit_collection.apply_single_gate(gate, name)
def sz(phi, N): m = np.diag(np.zeros(N, dtype=complex)) for i in range(2): for j in range(2): m[i, j] = qtop.rz(phi=phi).data[i, j] return Qobj(m)
def tdg(): return rz(-1 * np.pi / 4)
def sdg(): return rz(-1 * np.pi / 2)
#CR gate def targ_unit(): mat = (np.sqrt(1 / 2)) * np.array([[1, 0, -1.j, 0], [0, 1, 0, 1.j], [-1.j, 0, 1, 0], [0, 1.j, 0, 1]]) return Qobj(mat, dims=[[2, 2], [2, 2]]) #def had_gate(): # mat = (np.sqrt(1/2))*np.array([[1,1],[1,-1]]) # return Qobj(mat,dims=[[2],[2]]) #cnot gate cnot_gate = cnot() print( tensor(rz(phi=np.pi / 2), Si) * tensor(Si, rx(phi=np.pi / 2)) * cr(phi=-np.pi / 2.)) #u_targ = tensor(rz(phi=np.pi/2),Si)*tensor(Si,rx(phi=np.pi/2))*cr(phi=-np.pi/2.) u_targ = cr(phi=-np.pi / 2) #u_targ = had_gate() U0 = identity(4) print('U0=', U0) print('targ=', u_targ) # Time allowed for the evolution #evo_times = [140,150,160,175,195] evo_times = [384] #evo_times = [1312] # Number of time slots #n_ts = int(float(evo_time/0.222)) #H0 = (4.969/2.)*Sz #Hc = [Sz,Sx,Sy]