⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sparsehno4.m

📁 压缩文件中是Error Correction Coding - Mathematical Methods and Algorithms(Wiley 2005)作者:(Todd K. Moon )的配
💻 M
字号:
function H = makesparseHno4(M,N,wt)%function H = makesparseHno4(M,N,wt)% Make a sparse parity check matrix, with column weight wt% and row weight as uniform as possible and overlap between columns no greater% than 1 (thus eliminating cycles of girth 4).  This is% MacKay's construction 1A% Copyright 2004 by Todd K. Moon% Permission is granted to use this program/data% for educational/research onlyH = zeros(M,N);% Generate the matrix at random with column weight wtfor i =1:N  colwt = 0;  while(1)    j = floor(M*rand)+1;    if(H(j,i) == 0)      H(j,i) = 1;      colwt = colwt + 1;    end    if(colwt == wt) break; end;  endend% Balance the row weightrowsum = zeros(1,M);coltoswap = 1;while(1)  % update row sums  maxrs = 0; minrs = N;  for i=1:M  % for each row    rowsum(i) = sum(H(i,:));    if(rowsum(i) > maxrs)      maxrs = rowsum(i);      maxi = i;    end    if(rowsum(i) < minrs)      minrs = rowsum(i);      mini = i;    end  end  % fprintf(1,'maxrs=%d  minrs=%d\n',maxrs,minrs);  if((maxrs - minrs) <= 1)     break;   end; 					% all rows balance  swapped = 0;  for i=1:N   % loop to find a column to swap    if((H(maxi,coltoswap)==1) & (H(mini,coltoswap)==0))      H(mini,coltoswap) = 1;      H(maxi,coltoswap) = 0;      rowsum(maxi) = rowsum(maxi) - 1;      rowsum(mini) = rowsum(mini) + 1;      swapped = 1;      break;    end    coltoswap = mod(coltoswap,N) + 1;  end  if(~swapped)    fprintf(1,'Problem: rows not swapped:  maxrs=%d  minrs=%d\n',maxrs,minrs);  endend% Now check for columns with overlap > 1toss = [];				% list of columns to tossfor i=1:N-1  for j=i+1:N    overlap = sum(H(:,i) .* H(:,j));    if(overlap > 1)  % toss either column i or j      toss = [toss j];    end  endendtoss = unique(toss);fprintf(1,'Throwing away %d columns to satisfy no 4-loop\n',length(toss));H(:,toss) = [];				% throw columns away

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -