• 大小: 0M
    文件类型: .rar
    金币: 2
    下载: 0 次
    发布日期: 2021-05-16
  • 语言: 其他
  • 标签: 其他  

资源简介

四种算法.rar

资源截图

代码片段和文件信息

function [z_hat] = ldpc_decode(zHsigmaiteration)
% Log-domain sum product algorithm LDPC decoder对数域BP译码算法
%
%  z       : Received signal vector (column vector) 接收信号
%  H         : LDPC matrix LDPC矩阵
%  N0      : Noise variance 噪声方差
%  iteration : Number of iteration 迭代次数
%
%  z_hat    : Decoded vector (0/1) 
%
%
% Copyright Bagawan S. Nugroho 2007 
% http://bsnugroho.googlepages.com

[mn] = size(H); if m>n H=H‘; [mn] = size(H); end
if ~issparse(H) % make H sparse if it is not sparse yet如果不是稀疏矩阵,将H变为稀疏矩阵
   [iijjsH] = find(H);
   H = sparse(iijjsHmn);
end

% Prior log-likelihood. Minus sign is used for 0/1 to -1/1 mapping

qij1=1./(1+exp(-2*z./(sigma^2)));
qij0=1-qij1;
Lci =log(qij0./qij1);
% Initialization
Lrji = zeros(mn);
Pibetaij = zeros(m n);

% Asscociate the L(ci) matrix with non-zero elements of
 Lqij = H.*repmat(Lcim 1);

% Get non-zero elements
[r c] = find(H);%r是行中非零元素,c是列中的非零元素

% Iteration
for u = 1:iteration
   
%    fprintf(‘Iteration : %d\u‘ u);
   
   % Get the sign and magnitude of L(qij)   
   alphaij = sign(Lqij); 
   betaij = abs(Lqij);

   for l = 1:length(r)
      Pibetaij(r(l) c(l)) = log((exp(betaij(r(l) c(l))) + 1)/...
                             (exp(betaij(r(l) c(l))) - 1));
   end
   
   % ----- Horizontal step校验节点处理 -----
   for i = 1:m  
      c1 = find(H(i :));   %  找出列中的非零元素个数
      
      % Get the summation of Pi(betaij))        
      for k = 1:length(c1)

         sumOfPibetaij = 0;
         prodOfalphaij = 1;
         
         % Summation of Pi(betaij)\c1(k)
         sumOfPibetaij = sum(Pibetaij(i c1)) - Pibetaij(i c1(k));
         
         % Avoid division by zero/very small number get Pi(sum(Pi(betaij)))
         if sumOfPibetaij < 1e-20
            sumOfPibetaij = 1e-10;
         end         
         PiSumOfPibetaij = log((exp(sumOfPibetaij) + 1)/(exp(sumOfPibetaij) - 1));
      
         % Multiplication of alphaij\c1(k) (use ‘*‘ since alphaij are -1/1s)
         prodOfalphaij = prod(alphaij(i c1))*alphaij(i c1(k)); % prod使元素按列相乘  ??????????????
         % Update L(rji) 更新校验节点
         Lrji(i c1(k)) = prodOfalphaij*PiSumOfPibetaij;
         
      end % for k
      
   end % for i
  soft_information=[];
   % ------ Vertical step比特节点处理 ------
   for j = 1:n

      % Find non-zero in the row
      r1 = find(H(: j)); % 找出行中的非零元素个数
      
      for k = 1:length(r1)        
        
         % Update L(qij) by summation of L(rij)\r1(k)
         Lqij(r1(k) j) = Lci(j) + sum(Lrji(r1 j)) - Lrji(r1(k) j);
      
      end % for k
      
      % Get L(Qi)
      LQi = Lci(j) + sum(Lrji(r1 j));
  
       
      % Decode L(Qi)
      if LQi <= 0
         z_hat(j) = 1;
      else
         z_hat(j) = 0;
      end
                   
   end % for j

    if mod(z_hat*H‘2) == 0 
    end
end % for u


  


 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件       3025  2011-03-10 17:44  ldpc_decode.m

----------- ---------  ---------- -----  ----

                 3025                    1


评论

共有 条评论