outer_decode_u.m

来自「短波信道抗多音干扰的性能分析及其仿真」· M 代码 · 共 88 行

M
88
字号
function outer_out_u=outer_decode_u(outer_input,trellis,formerstate)
% this function does the iterative MAP decode process of the
% outer convolutional code to recover the information

number_of_states=trellis.numStates;
nextstate=trellis.nextStates;
fanout=trellis.numInputSymbols;
output=trellis.outputs;
number_of_out=trellis.numOutputSymbols;
depth_of_trellis=size(outer_input,2);

alpha=zeros(number_of_states,depth_of_trellis);
alpha(:,1)=[0;-1e10*ones(number_of_states-1,1)];
alpha1=zeros(1,fanout);
gamma=zeros(fanout,depth_of_trellis);
max=-1e10*ones(1,depth_of_trellis-1);
beta=zeros(number_of_states,depth_of_trellis);
beta(:,depth_of_trellis)=[0;-1e10*ones(number_of_states-1,1)];
beta1=zeros(1,fanout);

% forward recursion
for i=1:depth_of_trellis-1
    for j=1:number_of_states
        for k=1:fanout
            if(formerstate(j,1,k)~=number_of_states)
                for h=1:fanout
                    t=output(formerstate(j,h,k)+1,k)+1;
                    if(t~=number_of_out)
                        gamma(h,i)=outer_input(t,i);
                    else
                        gamma(h,i)=0;
                    end
                    alpha1(h)=alpha(formerstate(j,h,k)+1,i)+gamma(h,i);
                    if(alpha1(h)<=-80)
                        alpha1(h)=0;
                    else
                        alpha1(h)=exp(alpha1(h));
                    end
                end
                if(sum(alpha1)>1e-30)
                     alpha(j,i+1)=log(sum(alpha1));
                else
                     alpha(j,i+1)=-1e10;
                end
                if(max(i)<alpha(j,i+1))
                     max(i)=alpha(j,i+1);
                end
            end
        end
    end
    alpha(:,i+1)=alpha(:,i+1)-max(i);
end

% backward recursion and compute the log-likelihood ratio
for i=depth_of_trellis:-1:1
    temp=zeros(1,fanout);
    for j=1:number_of_states
        for k=1:fanout
            t=output(j,k)+1;
            if(t~=number_of_out)
                gamma(k,i)=outer_input(t,i);
            else
                gamma(k,i)=0;
            end
            beta1(k)=beta(nextstate(j,k)+1,i)+gamma(k,i);
            if(beta1(k)<=-80)
                beta1(k)=0;
            else
                beta1(k)=exp(beta1(k));
            end
            temp(k)=temp(k)+exp(alpha(j,i)+gamma(k,i)+beta(nextstate(j,k)+1,i));
        end   
        if(i>1)
            if(sum(beta1)>1e-30)
                beta(j,i-1)=log(sum(beta1))-max(i-1);
            else
                beta(j,i-1)=-1e10;
            end
        end
    end
    [C,I]=max(temp);
    outer_out_u(i)=I-1;
end
        

    
       

⌨️ 快捷键说明

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