www.pudn.com > ldpc802.16.rar > ldpc_encode_3gpp.m, change:2005-10-14,size:773b


function [out]=ldpc_encode_3gpp(in,H,z) 
 
in=reshape(in,z,length(in)/z); 
[m,n]=size(H); 
 
%calculate namuda 
nda=zeros(z,m); 
namuda=zeros(z,1); 
for i=1:m 
    for j=1:n-m 
        p=H(i,j); 
        if p~=-1 
            nda(:,i)=nda(:,i)+circshift(eye(z),[0,p])*in(:,j); 
        end 
    end 
    namuda=nda(:,i)+namuda; 
end 
 
%calculate v(0) 
v=zeros(z,m); 
loc=find(H(:,n-m+1)~=-1); 
v(:,1)=circshift(eye(z),[0,mod(z-H(loc(2),n-m+1),z)])*namuda; 
 
%calculate v(i+1)  i=1,2,...,x 
for i=1:loc(2) 
    v(:,i+1)=v(:,i)+nda(:,i); 
end 
 
%calculate v(i)  i=mb-1,mb-2,...., x+3 
v(:,m)=v(:,1)+nda(:,m); 
for i=1:m-loc(2)-2 
    v(:,m-i)=v(:,m-i+1)+nda(:,m-i); 
end 
 
in=reshape(in,size(in,1)*size(in,2),1); 
v=reshape(v,size(v,1)*size(v,2),1); 
 
out=[in;rem(v,2)];