% This Matlab script compares the asymptotic performance gap of
% an infinite length DFE and an LC-BIDFE with the matched filter bound
% An L+1 tap fir channel [c(0), c(1), ...., c(L)] with no roots on the 
% unit circle is considered.


% Test channels
% A symmetric 3 tap channel with roots at alpha, 1/alpha
% An asymmetric 3 tap channel with roots at alpha, 0.5

Gap_dfe=[];Gap_bidfe=[];

for beta=0.01:0.01:0.99,

chan_roots=[beta, 1/beta];% for symmetric 3-tap channel
%chan_roots=[beta, 0.5];  % for 3-tap asymmetric channel

c=poly(chan_roots);

%Normalize the channel.
c=c/norm(c);
L=length(c)-1;

alpha=roots(c); 

alpha_in=alpha(find(abs(alpha) < 1));
alpha_out=alpha(find(abs(alpha) > 1));
alpha_num=[1./conj(alpha_in); alpha_out];
alpha_den=[alpha_in; 1./conj(alpha_out)]; 
G_num=prod(alpha_in)*conj(prod(alpha_in))*poly(alpha_num);
G_den=poly(alpha_den);

g=filter(c(1)*G_num,c(L+1)*G_den,[1 zeros(1,L)]);

Gain=2/(1+real(g(L+1)));
Gain_db=10*log10(Gain); % in dB

% Noise gain of conventional dfe
NG=10*log10(1/(c(1)*conj(c(1))*prod(alpha_out)*conj(prod(alpha_out))));

Gap_dfe=[Gap_dfe NG];
Gap_bidfe=[Gap_bidfe NG-Gain_db];

end;

beta=0.01:0.01:0.99;

set(0,'DefaultAxesFontSize',18);
set(0,'DefaultTextFontSize',18);
set(0,'DefaultTextFontName','times');
set(0,'DefaultAxesFontName','times');

figure;
pl1=plot(beta,Gap_dfe,'b-.','LineWidth',2);
hold on;
pl2=plot(beta,Gap_bidfe,'r-','LineWidth',2);
pl3=plot([0:0.1:1],0*[0:0.1:1],'k-o','LineWidth',2);
legend([pl1,pl2,pl3],'Conventional DFE','LC-BiDFE','Matched Filter Bound',2);
xlabel('Root  Location  \beta');
ylabel('Noise  Gain  (in  dB)');
grid on;








