% Gauss-Markov multi-user ISI problem
%
% call xgm1_init first
%
% R. Perry, Oct. 2001

% generate each user's sequence
%
x = 2 * (rand( Nsyms, Nusers) > 0.5) - 1;

% apply the FIR filters
%
y = zeros( Nchips, Nsyms);

for u = 1:Nusers
  xu = [flipud(states(1:Memory,1)); x(:,u)]'; % initial -1's in the channels
  for t = 1:Nsyms
    xt = xu(t+Memory:-1:t);
    for j = 1:Nchips
      y(j,t) = y(j,t) + xt * FIR_save(:,u,j,t);
    end
  end
end

% constant noise variance for now
% maybe need different noise variances for each channel path?
%
var_noise = 10^(-SNR/10);

noise = sqrt(var_noise).*randn( Nchips, Nsyms);

z = y + noise; % signal plus noise
%%%
%%
% run Viterbi
%
L = 3;
%Nv = 1;
Nv=Nusers;                      %%%%%New Line%%%%%%%%%%

vit_init( L, M, Nsyms, Nv);


for t=1:Nsyms
  for vnum=1:Nv   %%%%NEW LINE %%%%
     vit_update(vnum);   %%%%updated line
 end             %%%%NEW LINE %%%%
end
%keyboard
paths=zeros(Nsyms, L, Nv);       

for vnum=1:Nv   %%%%NEW LINE %%%%
  paths(:,:,vnum)=vit_paths(vnum);             %%%%NEW LINE %%%%
end             %%%%NEW LINE %%%%

ex = zeros( Nsyms, L, Nusers);
%keyboard

for u=1:Nusers
   %ex(:,:,u) = get_ex_multi( paths, u);
   ex(:,:,u)=get_ex(paths(:,:,u));              %%%%%NEW LINE%%%%%
end
