### define channel transmission # sampl_func = lambda t: transm # for constant transmission value sampl_func = lambda t: np.random.normal(transm, 0.06) # for Gaussianly distribured values polynomial_expression = succprob_poly_withMC(graph, transm, MC_samples_meas, sampl_func, in_qubit, printing=False) print('polynomial_expression:', polynomial_expression) ## calculate threshold according to the analytical success probability estimate LT_threshold = LTthresold_from_polyexpress(polynomial_expression) print('LT_threshold:', LT_threshold) ### estimate succ probability from Monte-Carlo # eff_list_num = 11 # MC_sims = 1000 # # MCsucc_prob_list = trasmission_scan_MCestimate(poss_stabs_list, eff_list_num, MC_sims, in_qubit) # eff_list = np.linspace(0, 1, eff_list_num) ### plot all gstate.image(input_qubits=[in_qubit]) plt.show() t_list = np.linspace(0, 1, 100) # plt.plot(eff_list, MCsucc_prob_list, 'r.', label='MC estim.') plt.plot(t_list, probsucc_poly_fromexpress(t_list, polynomial_expression), c='blue', label='Analyt.') plt.plot(t_list, t_list, 'k:', label='Direct') plt.legend() plt.show()
vect_state0 = this_gstate.graph_vecstate() vect_state = added_U @ vect_state0 vect_state = np.exp(1.j * global_phase) * vect_state test_if_graph, Amat, _ = vector_is_graphstate(vect_state, print_error=False) if print_tests: print() print('target_adjmat:') print(target_adjmat) print('vect_state0') print(vect_state0) print('Amat') print(Amat) print('vect_state') print(vect_state) print('test_if_graph') print(test_if_graph) gstate = GraphState(graph) gstate.image() plt.show() if test_if_graph: # if test_if_graph and np.array_equal(Amat, target_adjmat): recognised_graphs_num += 1 print('\n\nSuccessful graphs recognized: ', recognised_graphs_num * 100. / num_graphs, '%')
# graph_targ.add_edges_from([(0, 1), (0, 2), (0, 3), (0, 4)]) ######## graph for 5-qubit code # graph_targ = nx.Graph() # graph_targ.add_nodes_from([0, 1, 2, 3, 4]) # graph_targ.add_edges_from([(0, 1), (1, 2), (2, 3), (3, 4), (4, 0)]) ######## graph for Shore code, from Griffiths notes graph_targ = nx.Graph() graph_targ.add_nodes_from([0, 1, 2, 3, 4, 5, 6, 7, 8]) graph_targ.add_edges_from([(0, 1), (1, 2), (2, 0), (0, 3), (0, 4), (1, 5), (1, 6), (2, 7), (2, 8)]) # TEST LOCAL EQUIVALENCE WITH TARGET GRAPH graph_state_targ = GraphState(graph_targ) check_equiv, unitaries = graph_state_targ.is_LC_equiv(graph_state, return_all=True) print( 'Are the two graphs locally equivalent? Which Clifford operators transform them into each other?' ) print(check_equiv) print(unitaries) ###### PLOT GRAPH EQUIVALENT TO STABILIZER CODE plt.subplot(211) graph_state.image(with_labels=True) plt.subplot(212) graph_state_targ.image(with_labels=True) plt.show()
graph, fixed_node=input_qubit) obt_graphs = obt_graphs + full_new_lc_class used_rots = used_rots + [ rots_list for i in range(len(full_new_lc_class)) ] # print('Total class representatives number:', len(lc_class_representatives)) # print('Total graph number:', len(obt_graphs)) else: if not arreq_in_list(adj_mat, obt_graphs): # print("Got a NEW graph! Rotation sequence:", rots_list, " Local Z phases:", local_phases, " Applied hadamards: ", applied_hadamard) print(rots_list, local_phases, applied_hadamard) obt_graphs.append(adj_mat) used_rots.append(rots_list) plt.subplot() gstate = GraphState(nx.from_numpy_matrix(adj_mat)) gstate.image(with_labels=True) plt.show() if not include_lc: obt_graphs = [nx.from_numpy_matrix(this_A) for this_A in obt_graphs] # plot all obtained graphs num_graphs = len(obt_graphs) n = int(np.sqrt(num_graphs)) n_plot_rows = n n_plot_cols = num_graphs / n if not isinstance(n_plot_cols, int): n_plot_cols = int(n_plot_cols) + 1 # for code_ix in range(num_graphs): print('All obtained', num_graphs, 'graphs:')