亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? ldpc_decode.m

?? ldpc源代碼(matlab編寫),也有C語言
?? M
字號:
function [x_hat, success, k] = ldpc_decode(f,H,qq)
% decoding of LDPC over GFqq, qq = 2,4,8,16,32,64,128 and 256
% as in Comm. Letters by Davey&MacKay June 1998 with e few modifications.
% For notations see the same reference.
% outputs the estimate "x_hat" of the ENCODED sequence for
% the received vector with channel likelihoods "f".
% "f" ([2^qq][n]) stores the likelihoods for "n" symbols in natural 
% ordering. E.g., y(3,5) is the probability of 5-th symbol is equal to "2".
% "H" is the parity check matrix. Success==1 signals
% successful decoding. Maximum number of iterations is set to 100.
% k returns number of iterations until convergence.
%
% Examples:
% We assume G is systematic G=[A|I] and G*H'=0 over GFq
% Binary case
%         sigma = 1;                          % AWGN noise deviation
%         x = (sign(randn(1,size(G,1)))+1)/2; % random bits
%         y = mod(x*G,2);                     % encoding 
%         z = 2*y-1;                          % BPSK modulation
%         z=z + sigma*randn(1,size(G,2));     % AWGN transmission
%
%         f1=1./(1+exp(-2*z/sigma^2));        % likelihoods
%         f1 = (f1(:))';                      % make it a row vector
%         f0=1-f1;
%         [z_hat, success, k] = ldpc_decode([f0;f1],H,2);
%         x_hat = z_hat(size(G,2)+1-size(G,1):size(G,2));
%         x_hat = x_hat'; 
%
% Nonbinary case
%         sigma = 1;                          % AWGN noise deviation
%         q = 4;                              % Field parameter
%         nbits = log2(q);                    % bits per symbol
%         h = ldpc_generate(400,600,2.5,q,123); % Generate H
%         [H,G] = ldpc_h2g(h,q);              % find systematic G and modify H
%         x = floor(rand(1,size(G,1))*q);     % random symbols
%         y = ldpc_encode(x,G,q);             % encoding 
%         yb = (fliplr(de2bi(y,nbits)))';     % convert total index to binary format
%         yb = yb(:);                         % make a vector
%         zb = 2*yb-1;                        % BPSK modulation
%         zb=zb + sigma*randn(size(zb));      % AWGN transmission
%
%         f1=1./(1+exp(-2*zb/sigma^2));        % likelihoods for bits
%         f1 = f1(:);                         % make it a vector
%         f1 = reshape(f1,nbits,length(y));   % reshape for finding priors on symbols                    
%         f0=1-f1;
%         junk = ones(q,length(y));           % this is a placeholder in the next function
%         [v0, v1, pp] = bits_smbl_msg(f0,f1,junk);
%         [z_hat, success, k] = ldpc_decode(pp,H,q);
%         x_hat = z_hat(size(G,2)+1-size(G,1):size(G,2));
%         x_hat = x_hat'; 


%   Copyright (c) 1999 by Igor Kozintsev igor@ifp.uiuc.edu
%   $Revision: 1.2 $  $Date: 1999/11/23 $
%   fixed high-SNR decoding
%   works for GFq, q= 2^m now

if qq==2 % binary case first, just use the old code
   
   [m,n] = size(H); if m>n, H=H'; [m,n] = size(H); end
   if ~issparse(H) % make H sparse if it is not sparse yet
      [ii,jj,sH] = find(H);
      H = sparse(ii,jj,sH,m,n);
   end
   
   f0 = f(1,:); % prob of 0
   f1 = f(2,:);
   
   %initialization
   [ii,jj,sH] = find(H);          % subscript index to nonzero elements of H 
   indx = sub2ind(size(H),ii,jj); % linear index to nonzero elements of H
   q0 = H * spdiags(f0(:),0,n,n);
   sq0 = full(q0(indx)); 
   sff0 = sq0;

   q1 = H * spdiags(f1(:),0,n,n); 
   sq1 = full(q1(indx));
   sff1 = sq1;

   %iterations
   k=0;
   success = 0;
   max_iter = 100;
   while ((success == 0) & (k < max_iter)),
      k = k+1;
   
      %horizontal step
      sdq = sq0 - sq1; sdq(find(sdq==0)) = 1e-20; % if   f0 = f1 = .5
      dq = sparse(ii,jj,sdq,m,n);
      Pdq_v = full(real(exp(sum(spfun('log',dq),2)))); % this is ugly but works :)
      Pdq = spdiags(Pdq_v(:),0,m,m) * H;
      sPdq = full(Pdq(indx));
      sr0 = (1+sPdq./sdq)./2; sr0(find(abs(sr0) < 1e-20)) = 1e-20;
      sr1 = (1-sPdq./sdq)./2; sr1(find(abs(sr1) < 1e-20)) = 1e-20;
      r0 = sparse(ii,jj,sr0,m,n);
      r1 = sparse(ii,jj,sr1,m,n);
   
      %vertical step
      Pr0_v = full(real(exp(sum(spfun('log',r0),1))));
      Pr0 = H * spdiags(Pr0_v(:),0,n,n);
      sPr0 = full(Pr0(indx));
      Q0 = full(sum(sparse(ii,jj,sPr0.*sff0,m,n),1))';
      sq0 = sPr0.*sff0./sr0;
   
      Pr1_v = full(real(exp(sum(spfun('log',r1),1))));
      Pr1 = H * spdiags(Pr1_v(:),0,n,n);
      sPr1 = full(Pr1(indx)); 
      Q1 = full(sum(sparse(ii,jj,sPr1.*sff1,m,n),1))';
      sq1 = sPr1.*sff1./sr1;
   
      sqq = sq0+sq1;
      sq0 = sq0./sqq;
      sq1 = sq1./sqq;
   
      %tentative decoding
      QQ = Q0+Q1;
      Q0 = Q0./QQ;
      Q1 = Q1./QQ;
   
      x_hat = (sign(Q1-Q0)+1)/2;
      if rem(H*x_hat,2) == 0, success = 1; end
   end
   % end of binary case

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

else % GFq, nonbinary  
   % our strategy is "divide and concur" - we partition H into several matrices with
   % the fixed number of variables per function in each of them and the other way around
   
   [m,n] = size(H); if m>n, H=H'; [m,n] = size(H); end
   if ~issparse(H) % make H sparse if it is not sparse yet
      [ii,jj,sH] = find(H);
      H = sparse(ii,jj,sH,m,n);
   end
   
   %initialization
   [ii,jj,sH] = find(H);          % subscript index to nonzero elements of H 
   W = sparse(ii,jj,ones(size(ii)),m,n); %indicator function
   nvars = full(sum(W,2));        % number of variables participating each check function
   minvars = min(nvars);          % min number of variables in a function
   maxvars = max(nvars);          % max number of variables in a function
   
   nfuns = full(sum(W,1));        % number of functions per variable
   minfuns = min(nfuns);          % min number of functions per variable
   maxfuns = max(nfuns);          % max number of functions per variable
   
   % the following will be used in solving linear equations over GFq
   M=log2(qq); % GFq exponent
   [tuple power] = gftuple([-1:2^M-2]', M, 2); 
   alpha = tuple * 2.^[0 : M - 1]';
   beta(alpha + 1) = 0 : 2^M - 1;


   % create cell arays which contain sparse matrices with fixed # of variables in rows
   for nnvars = minvars:maxvars
      tmp = zeros(size(H));
      rows = find(nvars == nnvars); %rows of H having 'nnvars' variables
      tmp(rows,:) = H(rows,:);
      [jjj,iii,ssH] = find(tmp'); 
      iir{nnvars} = reshape(iii,nnvars,length(iii)/nnvars)';
      jjr{nnvars} = reshape(jjj,nnvars,length(jjj)/nnvars)';
      Hr{nnvars} = reshape(ssH,nnvars,length(ssH)/nnvars)';% separate parity matrices
      q{nnvars} = reshape(f(:,jjr{nnvars})',[size(jjr{nnvars}),qq]); %initialize to channel likelihoods
      
      % Prestore valid configurations in array X
      if(~isempty(Hr{nnvars})) % make sure the are functions for this case
         Hleft = Hr{nnvars}(:,1);         % will solve for these varibles
         Hright = Hr{nnvars}(:,2:nnvars); % while setting these arbitrary
         for i=0:(qq^(nnvars-1)-1)  % there are qq^(nnvars-1) different combinations
            xr = (fliplr(de2bi(i,nnvars-1,qq))); % current nonzero combination 
             
            % find the remaining variable to satisfy the parity checks
            right_part = ones(size(Hleft))*(-Inf); %exponent over GFq
            for j=1:(nnvars-1) % multiply each column of Hright by the symbol from x and accumulate
               rr1 = power(beta(xr(j)+1)+1);      % get expon. representation of xr(i)
               rr2 = power(beta(Hright(:,j)+1)+1);% same for the column of Hright
               rr3 = gfmul(rr1,rr2,tuple)'; % this is exponential representation of the product
               right_part = gfadd(right_part,rr3,tuple);
            end
            left_part = mod((qq-1)+ right_part - power(beta(Hleft+1)+1),qq-1);
            xl=zeros(size(left_part));
            nzindx = find(isfinite(left_part));
            xl(nzindx) = alpha(left_part(nzindx)+2);
            x = [xl repmat(xr,[length(xl),1])]; %this is a valid configuration
            X{nnvars}(i+1,:,:) = x;
         end
      end
      
      
   end
   
   % create cell arays which contain sparse matrices with fixed # of functions in columns
   for nnfuns = minfuns:maxfuns
      tmp = zeros(size(H));
      cols = find(nfuns == nnfuns); %rows of H having 'nnvars' variables
      tmp(:,cols) = H(:,cols);
      [iii,jjj,ssH] = find(tmp); 
      iic{nnfuns} = reshape(iii,nnfuns,length(iii)/nnfuns);
      jjc{nnfuns} = reshape(jjj,nnfuns,length(jjj)/nnfuns);
      Hc{nnfuns} = reshape(ssH,nnfuns,length(ssH)/nnfuns);% separate parity matrices
      ff{nnfuns} = reshape(f(:,jjc{nnfuns})',[size(jjc{nnfuns}),qq]); %  this will not change
   end

   %iterations
   k=0;
   success = 0;
   max_iter = 100;
   while ((success == 0) & (k < max_iter)),
      k = k+1
      
      buffer = zeros([size(H),qq]);
      
      % Horizontal step - forming messages to variables from the parity check functions
      % each Hr is processed separately
      for nnvars = minvars:maxvars
         if(~isempty(Hr{nnvars})) % make sure the are functions for this case
         result = zeros([size(Hr{nnvars}) qq]); % will store the intermediate result
         for i=0:(qq^(nnvars-1)-1)  % there are qq^(nnvars-1) different combinations
               x = squeeze(X{nnvars}(i+1,:,:)); %lookup a valid configuration
               
               %calculate products
               a = cumsum(ones(size(x)),1);
               b = cumsum(ones(size(x)),2);
               idx = sub2ind(size(q{nnvars}),a,b,x+1); %index of current configuration in 3D
               pp = repmat(prod(q{nnvars}(idx),2),[1,size(x,2)]); %product for this configuration 
        
               denom = q{nnvars}(idx);
               denom(find(denom==0)) = realmin;
               result(idx) = result(idx) + pp./denom;
            end
            
            %  update global distribution
            a = repmat(iir{nnvars},[1,1,qq]);
            b = repmat(jjr{nnvars},[1,1,qq]);
            c = permute(repmat((1:qq)',[1 size(a,1) size(a,2)]),[2 3 1]);
            gidx = sub2ind(size(buffer),a,b,c);
            buffer(gidx) = result;
         end
      end
      
      % initialize r from the global data in buffer
      for nnfuns = minfuns:maxfuns
         a = repmat(iic{nnfuns},[1,1,qq]);
         b = repmat(jjc{nnfuns},[1,1,qq]);
         c = permute(repmat((1:qq)',[1 size(a,1) size(a,2)]),[2 3 1]);
         gidx = sub2ind(size(buffer),a,b,c);
         r{nnfuns} = buffer(gidx);
      end

      
      %vertical step
      buffer = zeros([size(H),qq]);
      QQ = zeros(qq,size(H,2));
      for nnfuns = minfuns:maxfuns
         if(~isempty(Hc{nnfuns})) % make sure the are variables for this case
            %calculate products
            pp = repmat( prod ( r{nnfuns},1),[size(r{nnfuns},1),1]).*ff{nnfuns}; %product for this configuration 
            denom = r{nnfuns};
            denom(find(denom==0)) = realmin;
            result = pp./denom;
            result = result./repmat((sum(result,3)),[1,1,qq]); %normalize to distribution
            %  update global distribution
            a = repmat(iic{nnfuns},[1,1,qq]);
            b = repmat(jjc{nnfuns},[1,1,qq]);
            c = permute(repmat((1:qq)',[1 size(a,1) size(a,2)]),[2 3 1]);
            gidx = sub2ind(size(buffer),a,b,c);
            buffer(gidx) = result;
            
            Q{nnfuns} = pp.*ff{nnfuns};
            b = repmat(jjc{nnfuns}(1,:),[qq,1]);
            c = repmat((1:qq)',[1, size(b,2)]);
            qidx =  sub2ind(size(QQ),c,b);
            QQ(qidx) = squeeze(Q{nnfuns}(1,:,:))';
         end
      end
      

      
      % initialize q from the global data in buffer
      for nnvars = minvars:maxvars
         a = repmat(iir{nnvars},[1,1,qq]);
         b = repmat(jjr{nnvars},[1,1,qq]);
         c = permute(repmat((1:qq)',[1 size(a,1) size(a,2)]),[2 3 1]);
         gidx = sub2ind(size(buffer),a,b,c);
         q{nnvars} = buffer(gidx);
      end
   
      
      %tentative decoding
      QQ = QQ ./ repmat(sum(QQ,1),[qq 1]); %normalize - can be used as soft outputs
      [xi xj sx] = find(QQ == repmat(max(QQ),[size(QQ,1),1]));
      x_hat = xi-1;
      if ldpc_encode(x_hat,H',qq) == 0, success = 1; end
   end
end % end of nonbinary case

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
日产精品久久久久久久性色| 亚洲精品国产精品乱码不99 | 欧美日韩国产在线观看| 成人夜色视频网站在线观看| 国内成+人亚洲+欧美+综合在线| 日韩成人精品视频| 日韩黄色免费电影| 看国产成人h片视频| 美女任你摸久久| 激情五月播播久久久精品| 久久电影国产免费久久电影| 国产成人在线视频网站| 精品一区二区三区香蕉蜜桃| 狠狠狠色丁香婷婷综合久久五月| 美脚の诱脚舐め脚责91| 国产一区二区三区免费播放| 国产乱国产乱300精品| 国产精品一区三区| 99在线精品一区二区三区| 成人免费视频一区| 在线观看av一区二区| 欧美日韩电影一区| 欧美成人r级一区二区三区| 久久一夜天堂av一区二区三区 | 国产在线不卡一区| 国产精品一级黄| 色综合天天综合在线视频| 欧美色综合网站| 日韩精品一区二区三区中文不卡| 国产午夜一区二区三区| 亚洲人成亚洲人成在线观看图片| 亚洲成人一二三| 国产美女一区二区三区| 日本久久精品电影| 精品美女一区二区三区| 国产精品久久久久一区二区三区| 亚洲香蕉伊在人在线观| 久久99精品一区二区三区三区| 国产成人av自拍| 88在线观看91蜜桃国自产| 国产欧美日本一区二区三区| 夜夜亚洲天天久久| 国产裸体歌舞团一区二区| 91成人免费网站| 国产视频亚洲色图| 亚洲超碰精品一区二区| 不卡一区二区在线| 91精品欧美综合在线观看最新 | 成人免费高清在线观看| 5566中文字幕一区二区电影| 国产精品久久久一本精品| 日本中文字幕不卡| 色天使久久综合网天天| 久久免费精品国产久精品久久久久| 一区二区三区免费在线观看| 国产凹凸在线观看一区二区| 欧美一区二区网站| 亚洲电影激情视频网站| 成人在线视频一区二区| 精品国产免费久久| 三级一区在线视频先锋| 色94色欧美sute亚洲线路一久| 国产女主播在线一区二区| 美女高潮久久久| 日韩亚洲欧美一区| 亚洲国产美女搞黄色| 色综合久久综合| 国产精品久久久久影院| 成人精品在线视频观看| 国产清纯白嫩初高生在线观看91 | 亚洲成人免费在线观看| 99麻豆久久久国产精品免费优播| wwwwww.欧美系列| 精品午夜久久福利影院| 欧美一区二区网站| 蜜乳av一区二区| 91精品国产综合久久福利软件| 亚洲国产aⅴ成人精品无吗| 99热这里都是精品| 一区二区三区四区乱视频| 一本大道av一区二区在线播放| 国产精品久久久久久久午夜片| 国产91丝袜在线播放| 亚洲国产成人午夜在线一区| 粗大黑人巨茎大战欧美成人| 国产亚洲一区二区在线观看| 国产91在线观看| 亚洲欧美国产三级| 欧美伊人久久久久久久久影院| 亚洲第一福利视频在线| 91精品欧美久久久久久动漫| 久久99国产精品麻豆| 久久久久97国产精华液好用吗| 国产69精品久久99不卡| 亚洲天堂久久久久久久| 91福利精品视频| 蜜臀a∨国产成人精品| 久久久久久久电影| 北岛玲一区二区三区四区| 又紧又大又爽精品一区二区| 欧美日产在线观看| 久久91精品国产91久久小草| 国产日产欧产精品推荐色| 色偷偷久久人人79超碰人人澡| 亚洲妇熟xx妇色黄| 久久综合久久99| 在线观看国产日韩| 国产在线日韩欧美| 亚洲三级在线免费| 91精品福利在线一区二区三区| 国产精选一区二区三区 | 在线观看国产一区二区| 美女网站色91| 亚洲品质自拍视频网站| 日韩午夜激情av| 99re在线视频这里只有精品| 日韩国产欧美在线观看| 国产精品久久久久毛片软件| 91精品在线观看入口| 成人亚洲一区二区一| 蜜桃视频一区二区| 亚洲人成在线播放网站岛国| 精品91自产拍在线观看一区| 在线视频国内一区二区| 国产成人精品影视| 美女被吸乳得到大胸91| 一区二区三区鲁丝不卡| 久久精品免视看| 欧美v日韩v国产v| 欧美日韩国产影片| 99麻豆久久久国产精品免费优播| 国产另类ts人妖一区二区| 一区二区三区四区亚洲| 国产精品久久久久久久蜜臀| 精品国产乱码久久久久久牛牛| 精品1区2区3区| 91在线观看下载| 成人av在线网| 国产福利精品一区| 国产在线视频一区二区| 日本在线观看不卡视频| 五月天激情小说综合| 夜夜夜精品看看| 亚洲欧美激情视频在线观看一区二区三区 | 精品国产乱码久久久久久免费| 欧美日韩中文精品| 色噜噜偷拍精品综合在线| 9色porny自拍视频一区二区| 国产+成+人+亚洲欧洲自线| 国产福利电影一区二区三区| 精品无人区卡一卡二卡三乱码免费卡| 日本大胆欧美人术艺术动态| 亚洲国产wwwccc36天堂| 亚洲高清不卡在线| 亚洲高清中文字幕| 五月婷婷色综合| 丝袜美腿亚洲色图| 日韩激情视频网站| 国产精品伊人色| 国内精品国产三级国产a久久| 91视频免费看| 色悠悠久久综合| 91国内精品野花午夜精品| 色系网站成人免费| 欧美日韩亚洲国产综合| 欧美日韩成人综合天天影院| 欧美挠脚心视频网站| 777xxx欧美| 久久日韩粉嫩一区二区三区| 国产欧美日韩激情| 亚洲欧美视频在线观看| 亚洲国产视频网站| 蜜臀av性久久久久蜜臀av麻豆| 美女精品一区二区| 国产成人欧美日韩在线电影| 99精品视频一区| 欧美日韩视频专区在线播放| 日韩欧美在线网站| 国产欧美精品一区| 亚洲综合另类小说| 久久99精品久久久久久国产越南 | 日本vs亚洲vs韩国一区三区 | 亚洲成人免费影院| 久久国产精品色婷婷| av激情综合网| 欧美片网站yy| 国产女人aaa级久久久级| 一级做a爱片久久| 久久99深爱久久99精品| 成人免费黄色大片| 欧美高清视频一二三区| 国产日产亚洲精品系列| 亚洲第一综合色| 成人深夜视频在线观看| 欧美一区午夜精品| 亚洲人xxxx| 国产精品伊人色| 在线播放91灌醉迷j高跟美女| 欧美激情艳妇裸体舞| 日本欧美在线观看|