Created
November 2, 2018 22:34
-
-
Save nbecker/e60920fc54ceb443437733631cc402f6 to your computer and use it in GitHub Desktop.
pythran code breaks g++ gcc-c++-8.2.1-4.fc29.x86_64
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
#pythran export LdpcNREncode(int[:], int[:,:], int, int16[:,:], int, int) | |
def LdpcNREncode(in_pad, H_matrix, Zc,BG2_sh, K, Ksys): | |
Mb_rows, Nb_rows = np.shape(BG2_sh) | |
#%% encode the 4x14 QC-LDPC portion | |
#% V0 : Get the first Zc parity bits | |
cnt1 = 0 | |
V0 = np.zeros(Zc, dtype=int) | |
V0_tmp = np.zeros(Zc, dtype=int) | |
for kb in range (10): | |
sum_0 = np.zeros((Zc, Zc), dtype=int) | |
u_tmp = in_pad[cnt1:cnt1+Zc] | |
cnt2 = 0 | |
for mb in range (4): | |
Pij = H_matrix[cnt2:cnt2+Zc,cnt1:cnt1+Zc] | |
sum_0 += Pij % 2#mod( sum_0 + Pij , 2 ) | |
cnt2 += Zc | |
V0_tmp += np.dot(sum_0, u_tmp) % 2 | |
cnt1 += Zc | |
P_unpaired = BG2_sh[2,10] % Zc | |
CPM_unpaired_tmp = np.eye(Zc, dtype=int) | |
CPM_unpaired = np.roll (CPM_unpaired_tmp, Zc-P_unpaired, axis=1) | |
V0 = np.dot(CPM_unpaired,V0_tmp) % 2# % parity bits 1:8 | |
#% Parity blocks V1,V2,V3 | |
sum_1 = np.zeros(Zc, dtype=int) | |
sum_2 = np.zeros(Zc, dtype=int) | |
sum_3 = np.zeros(Zc, dtype=int) | |
cnt1 = 0 | |
for kb in range (10): | |
u_tmp = in_pad[cnt1:cnt1+Zc] | |
P1j = H_matrix[0:Zc ,cnt1:cnt1+Zc] | |
sum_1 ^= np.dot(P1j,u_tmp) | |
P2j = H_matrix[Zc:2*Zc,cnt1:cnt1+Zc] | |
sum_2 ^= np.dot(P2j,u_tmp) | |
P3j = H_matrix[2*Zc:3*Zc,cnt1:cnt1+Zc] | |
sum_3 ^= np.dot(P3j,u_tmp) | |
cnt1 = cnt1 + Zc | |
P1 = H_matrix[0:Zc, (11-1)*Zc:11*Zc] #%mod(BG2_sh(1,11), Zc) | |
P2 = H_matrix[Zc:2*Zc, (11-1)*Zc:11*Zc] #%mod(BG2_sh(2,11), Zc) | |
P3 = H_matrix[2*Zc:3*Zc, (11-1)*Zc:11*Zc] #%mod(BG2_sh(3,11), Zc) | |
CPM_tmp = np.eye(Zc, dtype=int) | |
CPM1 = P1#%circshift(CPM_tmp, P1, 2) | |
CPM2 = P2#%circshift(CPM_tmp, P2, 2) | |
CPM3 = P3#%circshift(CPM_tmp, P3, 2) | |
sum_tmp1 = np.dot(CPM1,V0) % 2 | |
sum_tmp2 = np.dot(CPM2,V0) % 2 | |
sum_tmp3 = np.dot(CPM3,V0) % 2 | |
V1 = sum_1 ^ sum_tmp1 # parity 9-16 | |
V2 = sum_2 ^ V1 ^ + sum_tmp2# % parity 17-24 | |
V3 = sum_3 ^ V2 ^ sum_tmp3# % parity 25-32 | |
mldpc, nldpc = np.shape(H_matrix) | |
encoder_out = np.empty (nldpc, dtype=int) | |
tmp = np.concatenate((in_pad, V0, V1, V2, V3)) | |
encoder_out[:len(tmp)] = tmp | |
Pij = np.zeros((Zc, Zc), dtype=int) | |
cnt2 = 14*Zc | |
for mb in range (5,Mb_rows+1): | |
cnt1 = 0 | |
sum_1 = np.zeros(Zc, dtype=int) | |
for kb in range(14): | |
u_tmp = encoder_out[cnt1:cnt1+Zc] | |
Pij = H_matrix[ (mb-1)*Zc:mb*Zc ,cnt1:cnt1+Zc] | |
sum_1 ^= np.dot(Pij,u_tmp) | |
cnt1 = cnt1 + Zc | |
encoder_out[cnt2:cnt2+Zc] =sum_1 | |
cnt2= cnt2 +Zc | |
encoder_out[K:Ksys] = -1*np.ones(Ksys-K, dtype=int) | |
ldpc_encoder_out = encoder_out[2*Zc:] | |
return ldpc_encoder_out#, V0, V1, V2, V3 | |
# // | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment