greedysearch.m

来自「Matlab packet for generating G and H mat」· M 代码 · 共 29 行

M
29
字号
%search a minimum weight parity check matrix for a generic parity check matrix using greedy algorithm
function H_opt=greedysearch(H_org,max_num,dead_upp)
n_k=size(H_org);
code_len=n_k(2);
chk_len=n_k(1);
msg_len=code_len-chk_len;
weight_opt=sum(sum(H_org));
dead_opt=dead_upp;
H_opt = H_org;
row2=1;
for i=1:max_num
    H_temp = H_opt;
    row1 = row2;
    while (row1==row2)
        row1 = randint(1,1,[1,chk_len]);
        row2 = randint(1,1,[1,chk_len]);
    end
    tempcol1 = H_temp(row1,:);
    tempcol2 = H_temp(row2,:);
    tempsum = gfadd(tempcol1,tempcol2);
    if sum(tempsum)<=sum(tempcol1)
        H_temp(row1,:)=tempsum;
        H_opt = H_temp;
    elseif sum(tempsum)<=sum(tempcol2)
        H_temp(row2,:)=tempsum;
        H_opt = H_temp;
    end
end

⌨️ 快捷键说明

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