?? outer_decode_c.m
字號:
function outer_out_c=outer_decode_c(outer_input,trellis,formerstate)
% this function does the iterative MAP decode process of the
% outer convolutional code
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);
lu=zeros(number_of_out-1,depth_of_trellis);
% 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,number_of_out);
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(t)=temp(t)+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
for h=1:number_of_out-1
if(temp(h)==0)
lu(h,i)=-100;
elseif(temp(number_of_out)==0)
lu(h,i)=log(temp(h))+100;
else
lu(h,i)=log(temp(h)/temp(number_of_out));
end
if(lu(h,i)>80)
lu(h,i)=80;
elseif(lu(h,i)<-80)
lu(h,i)=-80;
end
outer_out_c(h,i)=lu(h,i)-outer_input(h,i);
if(outer_out_c(h,i)>45)
outer_out_c(h,i)=45;
elseif(outer_out_c(h,i)<-45)
outer_out_c(h,i)=-45;
end
end
end
%outer_out_c=lu-outer_input;
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -