def objfunc(x): Re = np.array(x[0:dim]) Im = np.array(x[dim:]) psi = np.array([Re + 1j * Im]).T psi = psi / norm(psi) rho = psi @ dag(psi) rho_out = apply_channel(K, rho) return entropy(rho_out)
def Choi_representation(K, dimA): ''' Calculates the Choi representation of the map with Kraus operators K. dimA is the dimension of the input space of the channel. The Choi represenatation is defined with the channel acting on the second half of the maximally entangled vector. ''' Gamma = MaxEnt_state(dimA, normalized=False) return np.array(apply_channel(K, Gamma, 2, [dimA, dimA]), dtype=np.complex)
def Clifford_twirl_channel_one_qubit(K, rho, sys=1, dim=[2]): ''' Twirls the given channel with Kraus operators in K by the one-qubit Clifford group on the given subsystem (specified by sys). ''' n = int(np.log2(np.sum([d for d in dim]))) C1 = eye(2**n) C2 = Rx_i(sys, np.pi, n) C3 = Rx_i(sys, np.pi / 2., n) C4 = Rx_i(sys, -np.pi / 2., n) C5 = Rz_i(sys, np.pi, n) C6 = Rx_i(sys, np.pi, n) * Rz_i(sys, np.pi, n) C7 = Rx_i(sys, np.pi / 2., n) * Rz_i(sys, np.pi, n) C6 = Rx_i(sys, np.pi, n) * Rz_i(sys, np.pi, n) C8 = Rx_i(sys, -np.pi / 2., n) * Rz_i(sys, np.pi, n) C9 = Rz_i(sys, np.pi / 2., n) C10 = Ry_i(sys, np.pi, n) * Rz_i(sys, np.pi / 2., n) C11 = Ry_i(sys, -np.pi / 2., n) * Rz_i(sys, np.pi / 2., n) C12 = Ry_i(sys, np.pi / 2., n) * Rz_i(sys, np.pi / 2., n) C13 = Rz_i(sys, -np.pi / 2., n) C14 = Ry_i(sys, np.pi, n) * Rz_i(sys, -np.pi / 2., n) C15 = Ry_i(sys, -np.pi / 2., n) * Rz_i(sys, -np.pi / 2., n) C16 = Ry_i(sys, np.pi / 2., n) * Rz_i(sys, -np.pi / 2., n) C17 = Rz_i(sys, -np.pi / 2., n) * Rx_i(sys, np.pi / 2., n) * Rz_i( sys, np.pi / 2., n) C18 = Rz_i(sys, np.pi / 2., n) * Rx_i(sys, np.pi / 2., n) * Rz_i( sys, np.pi / 2., n) C19 = Rz_i(sys, np.pi, n) * Rx_i(sys, np.pi / 2., n) * Rz_i( sys, np.pi / 2., n) C20 = Rx_i(sys, np.pi / 2., n) * Rz_i(sys, np.pi / 2., n) C21 = Rz_i(sys, np.pi / 2., n) * Rx_i(sys, -np.pi / 2., n) * Rz_i( sys, np.pi / 2., n) C22 = Rz_i(sys, -np.pi / 2., n) * Rx_i(sys, -np.pi / 2., n) * Rz_i( sys, np.pi / 2., n) C23 = Rx_i(sys, -np.pi / 2., n) * Rz_i(sys, np.pi / 2., n) C24 = Rx_i(sys, np.pi, n) * Rx_i(sys, -np.pi / 2., n) * Rz_i( sys, np.pi / 2., n) C = [ C1, C2, C3, C4, C5, C6, C7, C8, C9, C10, C11, C12, C13, C14, C15, C16, C17, C18, C19, C20, C21, C22, C23, C24 ] rho_twirl = 0 for i in range(len(C)): rho_twirl += (1. / 24.) * C[i] @ apply_channel(K, dag(C[i]) @ rho @ C[i], sys, dim) @ dag(C[i]) return rho_twirl, C
def objfunc(x): Re=np.matrix(x[0:dim_in**2]) Im=np.matrix(x[dim_in**2:]) psi=np.matrix(Re.T+1j*Im.T) psi=psi/norm(psi) psi_AA=psi*psi.H rho_AB=apply_channel(K,psi_AA,2,dim=[dim_in,dim_in]) return -coherent_inf_state(rho_AB,dim_in,dim_out,s)
def objfunc(x): Re = np.array(x[0:dim**3]) Im = np.array(x[dim**3:]) psi = np.array([Re + 1j * Im]).T psi = psi / norm(psi) p = [] S = [] for j in range(dim**2): R = tensor(dag(ket(dim**2, j)), eye(dim)) @ ( psi @ dag(psi)) @ tensor(ket(dim**2, j), eye(dim)) p.append(Tr(R)) rho = R / Tr(R) rho_out = apply_channel(K, rho) S.append(rho_out) return -np.real(Holevo_inf_ensemble(p, S))
def avg_fidelity_qubit(K): ''' K is the set of Kraus operators for the (qubit to qubit) channel whose average fidelity is to be found. ''' ket0 = ket(2, 0) ket1 = ket(2, 1) ket_plus = (1. / np.sqrt(2)) * (ket0 + ket1) ket_minus = (1. / np.sqrt(2)) * (ket0 - ket1) ket_plusi = (1. / np.sqrt(2)) * (ket0 + 1j * ket1) ket_minusi = (1. / np.sqrt(2)) * (ket0 - 1j * ket1) states = [ket0, ket1, ket_plus, ket_minus, ket_plusi, ket_minusi] F = 0 for state in states: F += np.real( Tr((state @ dag(state)) * apply_channel(K, state @ dag(state)))) return (1. / 6.) * F