-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathQCLDPCBaseH.py
49 lines (44 loc) · 2.19 KB
/
QCLDPCBaseH.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import numpy as np
from util import zero
def QCLDPCBaseH(Nbit,Rate):
nb = 24
z = int(Nbit/nb)
mb = int(nb-nb*Rate)
#kb = nb-mb
Hz = np.zeros((z,z))
SubH = np.zeros((z,z))
Hb = np.array([
[-1, 94, 73, -1, -1, -1, -1, -1, 55, 83, -1, -1, 7, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1],
[-1, 27, -1, -1, -1, 22, 79, 9, -1, -1, -1, 12, -1, 0, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1],
[-1, -1, -1, 24, 22, 81, -1, 33, -1, -1, -1, 0, -1, -1, 0, 0, -1, -1, -1, -1, -1, -1, -1, -1],
[61, -1, 47, -1, -1, -1, -1, -1, 65, 25, -1, -1, -1, -1, -1, 0, 0, -1, -1, -1, -1, -1, -1, -1],
[-1, -1, 39, -1, -1, -1, 84, -1, -1, 41, 72, -1, -1, -1, -1, -1, 0, 0, -1, -1, -1, -1, -1, -1],
[-1, -1, -1, -1, 46, 40, -1, 82, -1, -1, -1, 79, 0, -1, -1, -1, -1, 0, 0, -1, -1, -1, -1, -1],
[-1, -1, 95, 53, -1, -1, -1, -1, -1, 14, 18, -1, -1, -1, -1, -1, -1, -1, 0, 0, -1, -1, -1, -1],
[-1, 11, 73, -1, -1, -1, 2, -1, -1, 47, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0, -1, -1, -1],
[12, -1, -1, -1, 83, 24, -1, 43, -1, -1, -1, 51, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0, -1, -1],
[-1, -1, -1, -1, -1, 94, -1, 59, -1, -1, 70, 72, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0, -1],
[-1, -1, 7, 65, -1, -1, -1, -1, 39, 49, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0],
[43, -1, -1, -1, -1, 66, -1, 41, -1, -1, -1, 26, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0]
])
HbNew=np.zeros(Hb.shape)
for i in range(mb):
for j in range(nb):
if Hb[i,j] < 0:
Hz = np.zeros((z,z))
elif Hb[i,j] == 0:
Hz = np.identity(z)
else:
HbNew[i,j]= np.floor(Hb[i,j]*z/96)
#Hz = np.roll(np.identity(z), (0,int(HbNew[i,j])), axis=(0,1))
Hz = np.roll(np.identity(z), int(HbNew[i,j]), axis=1)
if j == 0:
SubH = Hz
else:
#SubH = np.concatenate((SubH,Hz),axis = 1)
SubH = np.concatenate((SubH,Hz),axis = 1)
if i == 0:
qcH=SubH
else:
qcH = np.concatenate((qcH,SubH), axis = 0)
return qcH,Hb