www.pudn.com > ldpc802.16.rar > ldpc_encode_80216e1.m, change:2005-09-26,size:802b


function [out]=ldpc_encode_80216e(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)=bitxor(nda(:,i),circshift(eye(z),[0,p])*in(:,j)); 
        end 
    end 
    namuda=bitxor(nda(:,i),namuda); 
end 
 
%calculate v(1) 
v=zeros(z,m); 
loc=find(H(:,n-m+1)~=-1); 
v(:,1)=circshift(eye(z),[0,z-H(loc(2),n-m+1)])*namuda; 
 
%calculate v(i+1)  i=1 
v(:,1+1)=bitxor(circshift(eye(z),[0,H(1,n-m+1)])*v(:,1),nda(:,1)); 
 
%calculate v(i+1)  i=2,3,...,mb 
for i=1:m-2 
    v(:,i+2)=bitxor(v(:,i+1),bitxor(circshift(eye(z),[0,H(i+1,n-m+1)])*v(:,1),nda(:,i+1))); 
end 
 
in=reshape(in,size(in,1)*size(in,2),1); 
v=reshape(v,size(v,1)*size(v,2),1); 
 
out=[v;in];