title: converting ldpc parity matrix to alist format (for gnuradio ldpc encoder use)
LDPC(低密度奇偶校验码)是通信中常用的FEC(前向纠错)编码之一。
GnuRadio的LDPC编解码器接受的输入格式是alist格式的校验矩阵(通常记作H矩阵),本文提供了将H矩阵转换为alist格式的工具。
alist是一种通用的稀疏矩阵存储格式,具体定义见 XXXXXXXXXXXXXXXXXXXX/mackay/codes/XXXXXXXXml
可用以下matlab代码将矩阵x转换为alist,并保存到名字为filename的文件。
<code>function write_alist(x, filename) n = size(x,1); m = size(x,2); num_nlist = sum(x,1)'; num_mlist = sum(x,2); biggest_num_m = max(num_mlist); biggest_num_n = max(num_nlist); for i = 1:n nlist{i} = find(x(i, :) > 0); end for i = 1:m mlist{i} = find(x(:, i) > 0)'; end fd = fopen(filename, 'w'); fprintf(fd, '%d %d\n', n, m); fprintf(fd, '%d %d\n', biggest_num_n, biggest_num_m); fprintf(fd, '%d ', num_nlist); fprintf(fd, '\n'); fprintf(fd, '%d ', num_mlist); fprintf(fd, '\n'); for i=1:length(nlist) fprintf(fd, '%d ', nlist{i}); fprintf(fd, '\n'); end for j=1:length(mlist) fprintf(fd, '%d ', mlist{j}); fprintf(fd, '\n'); end fclose(fd); end</code>
调用示例:
<code>% convert sparse matrix to alist format % <a href=/l?t=aHR0cDovL3d3dy5pbmZlcmVuY2Uub3JnLnVrL21hY2theS9jb2Rlcy9hbGlzdC5odG1s target="_blank">http://www.inference.org.uk/mackay/codes/alist.html</a> clear all; x= [0 0 1 0 0 0 0 1 0 1 0 0 1 0 0 0; 0 0 0 1 0 0 1 0 1 0 0 0 1 0 0 0; 0 1 0 0 1 0 1 0 0 1 0 0 0 0 0 0; 0 0 0 1 0 1 0 0 0 0 1 0 0 1 0 0; 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 1; 1 0 0 0 0 1 0 0 1 1 0 0 0 0 0 0; 0 0 0 1 0 0 0 1 0 0 0 1 0 0 1 0; 0 1 0 0 0 1 0 0 0 0 0 1 0 0 0 1; 1 0 0 0 0 0 1 0 0 0 0 0 0 1 0 1; 0 0 1 0 1 0 0 0 0 0 0 1 0 1 0 0; 0 1 0 0 0 0 0 0 0 0 1 0 1 0 1 0; 1 0 0 0 1 0 0 1 0 0 1 0 0 0 0 0;]; write_alist(x, 'x.alist');</code>
输出结果与原文链接中的例子完全一致。
======TODO:补充CCSDS C2 LDPC 7/8的例子=====
时段 | 个数 |
---|---|
{{f.startingTime}}点 - {{f.endTime}}点 | {{f.fileCount}} |