-
Notifications
You must be signed in to change notification settings - Fork 19
/
LDPC.m
76 lines (55 loc) · 1.34 KB
/
LDPC.m
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
sum_parity=[];
check_node=cell(size(H,1),1);
for(i=1:size(H,1))
for(j=1:size(H,2))
if(H(i,j)==1)
check_node{i}=[check_node{i} j];
else
;
end;
end;
end;
Q=[];
for(i=1:size(H,1))
Q=[Q llr'];
end;
for(interation=1:1000)
[ processed_llr ] = check_node_processing(Q, check_node);
Processed_llr_in_varibale_form=cell(size(H,2),1);
for(i=1:length(processed_llr))
temp=processed_llr{i};
for(j=1:size(temp,2))
Processed_llr_in_varibale_form{round(temp(2,j))}=[Processed_llr_in_varibale_form{round(temp(2,j))} [temp(1,j);i]];
end;
end;
for(i=1:length(Processed_llr_in_varibale_form))
temp=Processed_llr_in_varibale_form{i};
for(j=1:size(temp,2))
Q(i,temp(2,j))=sum(setdiff(temp(1,:), temp(1,j)));
end;
end;
for(i=1:size(Q,1))
for(j=1:size(Q,2))
Q(i,j)=Q(i,j)+llr(i);
end;
end;
P=[];
for(i=1:length(Processed_llr_in_varibale_form))
temp=Processed_llr_in_varibale_form{i};
P(i)=sum(temp(1,:));
end;
P=P+llr;
for(jj=1:length(P))
if(P(jj)>=0)
estimated_output(jj)=0;
else
estimated_output(jj)=1;
end;
end;
parity_mat=H*estimated_output';
sum_parity=[sum_parity sum(parity_mat) ];
if(sum(parity_mat)==0)
break;
break;
end;
end;