def use_sqrtm_approx_of_H_K(n, print_option = True): redh_m = redh_mat(n) redh_mt2 = np.dot(redh_m, redh_m.T) # Use mp to calculate sqrtm, somehow, we can find sqrtm in np. H_approx = mp.sqrtm(redh_mt2) K_approx = mp.sqrtm(redh_mt2) # convert from mp matrix format to np matrix format H_approx_mat = np.matrix(H_approx.tolist(), dtype=float) K_approx_mat = np.matrix(K_approx.tolist(), dtype=float) if(print_option): print 'H_approx_mat = ', H_approx_mat dataRate_compare_HKH_vs_MM_watef(H_approx_mat, K_approx_mat, n)
if(len(args) != 2): print 'Wrong arguments, require parameters: start_num, max_num' sys.exit(0) start_num = int(args[0]) end_num = int(args[1]) print_option = True for n in range(2, 15): verify_LU_of_Redh(n, print_option) print_option = False for n in range(start_num, end_num): L, UU, UU_tr, R2_tr = verify_LUUL_vs_R2(n, print_option) # H = L, K = UU dataRate_compare_HKH_vs_MM_watef(L, UU, n, "L vs UU") # all eig of L is 1 l_eig, v = np.linalg.eig(L) print "l_eig = ", l_eig assert(np.allclose(l_eig, 1)) U, LL, LL_tr, R2_tr = verify_ULLU_vs_R2(n, print_option) # H = U, K = LL dataRate_compare_HKH_vs_MM_watef(U, LL, n, "U vs LL") # all execept two eigs of U is 1 u_eig, v = np.linalg.eig(U) print "u_eig = ", u_eig print_option = False