def demap0(rx, X0, X1, Ps, phase, P_noise, La0, La1): N_cells = len(rx) M0 = len(X0) M1 = len(X1) ldM0 = int(np.log2(M0)) ldM1 = int(np.log2(M1)) N_bits = N_cells * ldM0 Llrs = np.zeros(N_bits) for k in range(N_cells): D = np.zeros(M0*M1) for i in range(M0): for j in range(M1): d = rx[k] - np.sqrt(Ps[0])*X0[i] d-= np.sqrt(Ps[1])*X1[j]*phase[k] D[j*M0+i] = -1/P_noise*np.abs(d)**2 if len(La0) > 0: for m in range(ldM0): bit = (i >> (ldM0 - 1 - m)) & 1 D[j*M0+i] -= bit*La0[k*ldM0+m] if len(La1) > 0: for m in range(ldM1): bit = (j >> (ldM1 - 1 - m)) & 1 D[j*M0+i] -= bit*La1[k*ldM1+m] for m in range(ldM0): num = den = np.float64(-np.inf) for i in range(M0): for j in range(M1): if (i >> (ldM0 - 1 - m)) & 1: den = _max_star(den, D[j*M0+i]) else: num = _max_star(num, D[j*M0+i]) Llrs[k*ldM0+m] = num - den return Llrs
def _MI0(rx, tx0, Powers0, Powers1, X0, X1, phase, P_noise, N_fec_cells): N_cells = len(rx) N_codewords = N_cells // N_fec_cells m_rx = rx.reshape(-1, N_fec_cells) m_tx0 = tx0.reshape(-1, N_fec_cells) m_phase = phase.reshape(-1, N_fec_cells) Cp_sqrt = np.sqrt(Powers0[0]) Cpp_sqrt = np.sqrt(Powers0[1]) Ip_sqrt = np.sqrt(Powers1[0]) Ipp_sqrt = np.sqrt(Powers1[1]) MI0s = [] for i in range(N_codewords): MI0 = 0 for k in range(N_fec_cells): if 2*k//N_fec_cells % 2 == 0: C_sqrt = Cp_sqrt I_sqrt = Ip_sqrt else: C_sqrt = Cpp_sqrt I_sqrt = Ipp_sqrt num = -np.inf den = -np.inf for x1 in X1: D = m_rx[i,k] - C_sqrt*m_tx0[i,k] - I_sqrt*x1*m_phase[i,k] num = _max_star(num, -np.abs(D)**2/P_noise) for x0 in X0: D = m_rx[i,k] - C_sqrt*x0 - I_sqrt*x1*m_phase[i,k] den = _max_star(den, -np.abs(D)**2/P_noise) MI0 += num - den MI0s.append(np.log2(len(X0)) + MI0/N_fec_cells/np.log(2.0)) return np.array(MI0s)
def _MI0(rx, tx0, Ps, X0, X1, phase, P_noise): N_cells = len(rx) P0 = Ps[0] P1 = Ps[1] M0 = len(X0) MI = 0 for k in range(N_cells): num = -np.inf den = -np.inf for x1 in X1: D = rx[k] - np.sqrt(P0) * tx0[k] - np.sqrt(P1) * x1 * phase[k] num = _max_star(num, -np.abs(D)**2 / P_noise) for x0 in X0: D = rx[k] - np.sqrt(P0) * x0 - np.sqrt(P1) * x1 * phase[k] den = _max_star(den, -np.abs(D)**2 / P_noise) MI += num - den return np.log2(M0) + MI / N_cells / np.log(2.0)
def demap0(rx, X0, X1, Powers0, Powers1, phase, P_noise, N_fec_cells, La0, La1): N_cells = len(rx) M0 = len(X0) M1 = len(X1) ldM0 = int(np.log2(M0)) ldM1 = int(np.log2(M1)) N_bits = N_cells*ldM0 Cp_sqrt = np.sqrt(Powers0[0]) Cpp_sqrt = np.sqrt(Powers0[1]) Ip_sqrt = np.sqrt(Powers1[0]) Ipp_sqrt = np.sqrt(Powers1[1]) Llrs = np.zeros(N_bits) for k in range(N_cells): if int(k/(N_fec_cells/2)) % 2 == 0: C_sqrt = Cp_sqrt I_sqrt = Ip_sqrt else: C_sqrt = Cpp_sqrt I_sqrt = Ipp_sqrt D = np.zeros(M0*M1) for i in range(M0): for j in range(M1): d = rx[k] - C_sqrt*X0[i] - I_sqrt*X1[j]*phase[k] D[j*M0+i] = -1/P_noise*np.abs(d)**2 if len(La0) > 0: for m in range(ldM0): bit = (i >> (ldM0 - 1 - m)) & 1 D[j*M0+i] -= bit*La0[k*ldM0+m] if len(La1) > 0: for m in range(ldM1): bit = (j >> (ldM1 - 1 - m)) & 1 D[j*M0+i] -= bit*La1[k*ldM1+m] for m in range(ldM0): num = den = np.float64(-np.inf) for i in range(M0): for j in range(M1): if (i >> (ldM0 - 1 - m)) & 1: den = _max_star(den, D[j*M0+i]) else: num = _max_star(num, D[j*M0+i]) Llrs[k*ldM0+m] = num - den return Llrs
def _MI1_0(rx, tx0, tx1, Ps, X0, X1, phase, P_noise): N_cells = len(rx) P0 = Ps[0] P1 = Ps[1] M1 = len(X1) MI = 0 for k in range(N_cells): den = -np.inf D = rx[k] - np.sqrt(P0) * tx0[k] - np.sqrt(P1) * tx1[k] * phase[k] num = -np.abs(D)**2 / P_noise for x1 in X1: D = rx[k] - np.sqrt(P0) * tx0[k] - np.sqrt(P1) * x1 * phase[k] den = _max_star(den, -np.abs(D)**2 / P_noise) MI += num - den return np.log2(M1) + MI / N_cells / np.log(2.0)