📄 girth6_shifter.m
字号:
% This program constructs girth 6 quasi-cyclic LDPC codes given
% row weight(k),column-weight (j) and size of each sub-matrix (m). The
% program calculates the shift value of each sub-matrix stored in an array called `shift'.
%The shift values are then used to construct a QC-LPDC code H. The first row sub-matrices are
% not shifted. Hence they remain as identity sub-matrices.
% The obtained code is stored in matrix H.
% Author : Dr. Gabofetswe Alafang Malema,University of Botswana
% Department of Computer science. e-mail: malemag@mopipi.ub.bw
clear
pack
clear
pack
j=3; % variable column-weight. change it to your desired column weight.
k=8; % row-weight is also variable.
m=10; % size of each sub-matrix is also variable.
p=[1:m];
M=j*m; % total number of rows.
shift=zeros(j,k); % stores shift values for each sub-matrix.
rows = struct('connect',0,'counter',0,'con',0); % structure used for storing connections.
shifter = struct('mem',0);
emptyset = [];
for y = 1:M % connections and number of connections for rows and columns are initialized.
rows(y).counter = 0;
rows(y).con = intersect(emptyset,rows(y).con);
rows(y).connect = intersect(emptyset,rows(y).connect);
end
for y =1:j
shifter(y).mem =[];
gp(y).mem=[(y-1)*m+1:y*m];
end
%This for loop calculates sub-matrix shift values. The calculation avoids
% shift values resulting in four-cycles. Shifts values are not repeated in
% the same row-group or column-group and two connections in the same groups
% must not have the same difference.
for a=1:k
for b=2:j
if a==1
shift(b,a)=ceil(rand*m);
shifter(b).mem = union(shifter(b).mem,shift(b,a));
else
if b==2
x1=setxor(shifter(b).mem,p);
r=ceil(rand*(length(x1)));
shift(b,a)=x1(r);
shifter(b).mem=union(shifter(b).mem,x1(r));
else
done =0; x1=setxor(shifter(b).mem,p);
while done==0
if isempty(x1)==1
display('Could not find code!! Try again or increase size of group.');
break;
end
r=ceil(rand*length(x1));
x=x1(r);
reject=0;
for d=b:-1:3
for e=a-1:-1:1
d1=x-shift(b,e);
d1=mod(d1,m);
d2=shift(d-1,a)-shift(d-1,e);
d2=mod(d2,m);
if d1==d2
reject=1;
end
end
end
if reject==0 %isempty(intersect(d11,d22))==1
shift(b,a)=x;
shifter(b).mem=union(shifter(b).mem,x);
done =1;
break;
else
x1=setxor(x1,x);
end
end % while loop
end % if b==2
end % if a == 1
end % for b=2:j
end % for a=1:k
% use the shift values to create connections in sub-matrices.
for i =1:k
for y=1:j
g(y).mem =circshift(gp(y).mem,[1 -shift(y,i)]);
end
for b=1:m
for y=2:j
rows(b).connect(i,y-1)= g(y).mem(b);
end
end
end
% use the row connections to form a matrix code.
counter = 1;
H = zeros(M,5);
for i = 1:k
for z = 1:m
H(z,counter)=1;
for y=1:j-1
x=rows(z).connect(i,y);
H(x,counter)=1;
end
counter = counter + 1;
end
end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -