根据非满秩校验矩阵H在GF(2^m)上求解生成矩阵G

注1: 如果校验矩阵H满秩,请参考:根据H在有限域GF(2^m)上求解生成矩阵G

**注2:**如果校验矩阵H不满秩,即存在冗余行。在这种情况下,编码时可以采用H的零空间上的一组基来编码,在译码时可以使用所有行做校验。

冗余行直观上构造了高列重的LDPC码,它们和编码时用到的一组基底是线性相关的,因此这些冗余行可作为校验节点参与译码。在保证校验位数不增加的前提下,给出更多零和约束来抵抗噪声干扰,从而获得译码增益。

除此之外,冗余行会增大译码时延。这是因为在译码时,复杂度高的是校验节点的计算,因此冗余行的数量是影响译码时延的重要因素。

Matlab实现:根据非满秩校验矩阵H在GF(2^m)上求解生成矩阵G

其中,查找表的生成请参考: 根据H在有限域GF(2^m)上求解生成矩阵G

Matlab 复制代码
function [H_fixed,G_system,H_rank,Px,Py]=H2G(H,q,LUT_dec2exp_GFq,LUT_exp2dec_GFq)
    %% initial
    [m,n]=size(H);
    H_stair=H;
    Py = eye(n);
    Px = eye(m);
    H_rank=0;
    column_permutation=0;

    %% Row Permutations and Row Gaussian Elimination in GF(q)
    for i=1:m
        if H_stair(i,i)==0
            % Row Permutations 
            for j=i+1:m
                if H_stair(j,i)~=0
                    break;
                else
                    if j==m
                        % Column Permutations
                        for k=i+1:n
                            if H_stair(i,k)~=0
                                break;
                            else
                                if k==n
                                    H_rank=i-1;
                                end
                            end
                        end
                        if H_rank~=0
                            break;
                        else
                            column_permutation=1;
                            H_stair(:,[j,k]) = H_stair(:,[k,j]);
                            Py(:,[j,k]) = Py(:,[k,j]);
                            i=j;
                        end
                    end
                end
            end
            if H_rank~=0
                break;
            end
            if i ~= j 
                H_stair([j, i],:) = H_stair([i, j],:);
                Px([j, i],:) = Px([i, j],:);
            end
        end

        % Row Normalization
        inverse_in_GFq = inverse(H_stair(i,i),q,LUT_dec2exp_GFq,LUT_exp2dec_GFq);
        for j=1:n
            if H_stair(i, j)~=0
                H_stair(i, j) = multiplication(H_stair(i, j),inverse_in_GFq,q,LUT_dec2exp_GFq,LUT_exp2dec_GFq);
            end
        end
        for j=1:m
            if Px(i, j)~=0
                Px(i, j) = multiplication(Px(i, j),inverse_in_GFq,q,LUT_dec2exp_GFq,LUT_exp2dec_GFq);
            end
        end

        % Row Elimination
        for j=1:m
            if j~=i && H_stair(j,i)~=0
                factor=H_stair(j,i);
                for k=1:n
                    temp=multiplication(H_stair(i, k),factor,q,LUT_dec2exp_GFq,LUT_exp2dec_GFq);
                    H_stair(j, k) = XOR(H_stair(j, k),temp,q);
                end
                for k=1:m
                    temp=multiplication(Px(i, k),factor,q,LUT_dec2exp_GFq,LUT_exp2dec_GFq);
                    Px(j, k)=XOR(Px(j, k),temp,q);
                end
            end
        end
    end

    if column_permutation==1
        disp("The H is permutated by column.");
    end
    parity_matrix = H_stair(1:H_rank,H_rank+1:n);
    G_system=[parity_matrix',eye(n-H_rank)];
    % G=G_fixed*Py';
    H_fixed=H*Py;

    %% subfunctions
    function [inverse_in_GFq] = inverse(x,q,LUT_dec2exp_GFq,LUT_exp2dec_GFq)
        if x==0
            error("The zero element has no inverse element in GF(q).");
        else
            exponent=LUT_dec2exp_GFq(x+1);
            inverse_exponent=mod(q-1-exponent,q-1);
            inverse_in_GFq=LUT_exp2dec_GFq(inverse_exponent+2);
        end
    end
    
    function [product_in_GFq] = multiplication(x,y,q,LUT_dec2exp_GFq,LUT_exp2dec_GFq) 
        if x==0 || y==0
            product_in_GFq=0;
        else
            exponent_x=LUT_dec2exp_GFq(x+1);
            exponent_y=LUT_dec2exp_GFq(y+1);
            product_exponent=mod(exponent_x+exponent_y,q-1);
            product_in_GFq=LUT_exp2dec_GFq(product_exponent+2);
        end
    end
    
    function [XOR_in_GFq] = XOR(x,y,q)
        vector_x=dec2vec(x,log2(q));
        vector_y=dec2vec(y,log2(q));
        vector_sum=mod(vector_x+vector_y,2);
        XOR_in_GFq=vec2dec(vector_sum,log2(q));
    end
    
    function [binaryVec]=dec2vec(x,m)
        binaryStr = dec2bin(x, m);
        binaryStrReversed = binaryStr(end:-1:1);
        binaryVec = binaryStrReversed - '0';
    end
        
    function [decimalVec]=vec2dec(x,m)
        decimalVec=0;
        for jj =1:m
            decimalVec=decimalVec+x(jj)*2^(jj-1);
        end
    end

end
相关推荐
weixin_5150339310 分钟前
ccfcsp-202006(4、5)
c++·算法
西柚与蓝莓10 分钟前
922. 按奇偶排序数组 II 双指针 力扣
数据结构·算法·leetcode
宇柔16 分钟前
Day5:移除链表元素
数据结构·算法·链表
Amor风信子34 分钟前
【力扣】2376. 统计特殊整数
算法·leetcode·职场和发展
极客小张34 分钟前
基于正点原子Linux开发板的智能监控与家电控制系统设计:深度解析Video4Linux和TCP/IP技术栈
linux·运维·c++·物联网·网络协议·tcp/ip·算法
JustCouvrir2 小时前
代码随想录算法训练营Day5
算法
周哈里窗的编程3 小时前
CSP-CCF★201912-2回收站选址★
c++·算法·图论
SpongeG4 小时前
数据结构第三周做题总结_链表
数据结构·算法·链表
everyStudy4 小时前
前端五种排序
前端·算法·排序算法
little redcap6 小时前
第十九次CCF计算机软件能力认证-乔乔和牛牛逛超市
数据结构·c++·算法