function L2 = getL_improve(llr, u, k)
% compute L_N^(i) according to llr and
% The length of llr is N, the length of u is (i-1)
% llr := W(y_i|u_i=0)/W(y_i|u_i=1)
global LLr n
i = length(u) + 1;
N = length(llr);
if LLr(i+k-1,n+1-log2(N)) == 0
if (i-1)==0 % u is null
if N==1
L2 = llr;
else
a = getL_improve(llr(1:N/2), [], k);
b = getL_improve(llr((N/2+1):N), [], k+N/2);
L2 = (a*b+1)/(a+b);
LLr(i+k-1,n+1-log2(N)) = L2;
end
elseif mod(i,2)==0 % even index
uo = u(1:2:(i-2));
ue = u(2:2:(i-2));
a = getL_improve(llr(1:N/2), xor(uo,ue), k);
b = getL_improve(llr((N/2+1):N), ue, k+N/2);
L2 = a^(1-2*u(i-1)) * b;
LLr(i+k-1,n+1-log2(N)) = L2;
else % odd index
uo = u(1:2:(i-1));
ue = u(2:2:(i-1));
a = getL_improve(llr(1:N/2), xor(uo,ue), k);
b = getL_improve(llr((N/2+1):N), ue, k+N/2);
L2 = (a*b+1)/(a+b);
LLr(i+k-1,n+1-log2(N)) = L2;
end
else
L2 = LLr(i+k-1,n+1-log2(N));
end