Beispiel #1
0
 def main():
     num_qbits = 5
     num_up = 2
     dm = DenMat(1 << num_qbits, tuple([2]*num_qbits))
     st = SymNupState(num_up, num_qbits)
     st_vec = st.get_st_vec()
     dm.set_arr_from_st_vec(st_vec)
     ecase = PureStEnt(dm, 'eigen')
     pf = ecase.get_entang_profile()
     # print(',,...', pf)
     ecase.print_entang_profiles([pf, pf], dm.row_shape)
Beispiel #2
0
    def main3():
        print('--------------------main3')
        num_qbits = 4
        num_up = 2
        dm = DenMat(1 << num_qbits, tuple([2]*num_qbits))
        st = SymNupState(num_up, num_qbits)
        st_vec = st.get_st_vec()
        dm.set_arr_from_st_vec(st_vec)
        # dm.depurify(.1)

        exact_evas = np.linalg.eigvalsh(dm.arr)
        print('evas_of_dm\n', exact_evas, 'sum=', np.sum(exact_evas))

        pert = DenMatPertTheory.new_with_separable_dm0(dm, verbose=True)
        num_steps = 80
        main_test(dm, exact_evas, pert, num_steps)
Beispiel #3
0
 def main():
     print('4 Bell Basis states**********************')
     for bits_are_equal in [True, False]:
         for mid_sign in ['+', '-']:
             st_vec = OtherStates.get_bell_basis_st_vec(bits_are_equal, mid_sign)
             dm = DenMat(4, (2, 2))
             dm.set_arr_from_st_vec(st_vec)
             ecase = PureStEnt(dm)
             pf = ecase.get_entang_profile()
             print('----------bits_are_equal=', bits_are_equal,
                   ', mid_sign=', mid_sign)
             print("st_vec=\n", st_vec)
             ecase.print_entang_profiles([pf], dm.row_shape)
     print('bound entang state **********************')
     dm_bd = OtherStates.get_den_mat_with_bound_entang(.5)
     num_hidden_states = 5
     num_ab_steps = 30
     ecase = SquashedEnt(dm_bd, num_hidden_states, num_ab_steps,
                         verbose=True)
     pf = ecase.get_entang_profile()
     ecase.print_entang_profiles([pf], dm_bd.row_shape)
Beispiel #4
0
 def main1():
     print('4 Bell Basis states**********************')
     for key in TwoQubitState.bell_key_set():
         st_vec = TwoQubitState.get_bell_basis_st_vec(key)
         dm = DenMat(4, (2, 2))
         dm.set_arr_from_st_vec(st_vec)
         ecase = PureStEnt(dm)
         pf = ecase.get_entang_profile()
         print('----------key:', key)
         print("st_vec=\n", st_vec)
         ecase.print_entang_profiles([pf], dm.row_shape)
     print("*******************************")
     dm1 = TwoQubitState.get_bell_basis_diag_dm(fid=.7)
     # print('arr=\n', dm1.arr)
     np.random.seed(123)
     dm2 = DenMat(4, (2, 2))
     dm2.set_arr_to_rand_den_mat(np.array([.1, .2, .3, .4]))
     dm3 = DenMat(4, (2, 2))
     dm3.set_arr_to_rand_den_mat(np.array([.1, .1, .1, .7]))
     for dm in [dm1, dm2, dm3]:
         print("----------new dm")
         print("formation_entang=",
               TwoQubitState.get_known_formation_entang(dm))
Beispiel #5
0
    def check_max_entang_st(st):
        """
        This method checks that the object st of class MaxEntangState does
        indeed carry maximal entanglement. The entanglement is calculated 3
        different ways (von Neumann entropy of 2 partial traces of density
        matrix, and from known value) and the 3 values are checked to agree.

        Parameters
        ----------
        st : MaxEntangState

        Returns
        -------
        None

        """
        dm = DenMat(st.num_rows, st.row_shape)
        st_vec = st.get_st_vec()
        dm.set_arr_from_st_vec(st_vec)
        ent1 = dm.get_partial_tr(set(st.y_axes)).get_entropy()
        ent2 = dm.get_partial_tr(set(st.x_axes)).get_entropy()
        ent3 = np.log(st.num_vals_min)
        assert abs(ent1 - ent2) < 1e-6 and abs(ent1 - ent3) < 1e-6, \
            str(ent1) + ', ' + str(ent2) + ', ' + str(ent3)