% example script to initialize a known-channel multi-user ISI problem
%
% R. Perry, June 2001
%
%%%
%%
% global variables for Viterbi
%
global HUGE_VAL; % 1e99
global DEBUG;    % for debugging
global V;        % main state array
global Vl;       % array for L-best indices
global Vw;       % cost array
global Vparam;   % parameters
global Vprev;    % previous state indices
global Vlprev;   % previous state el indices
global VW;       % final path costs

HUGE_VAL = 1e99;

DEBUG = 0;
%
%%
%%%

%%%
%%
% global variables for the cost functions
%
global z;
global trans;
global states;
global FIR_length;
global Memory;

global Nusers;
global FIR_save;
global FIR_0;

global TYPE;     % problem type

TYPE = 2;        % multi-user, known-channel
%
%%
%%%

format short g;

% initialize rand() and randn() with time-of-day
%
  seed=floor(sum(100*clock))
  rand( 'state', seed);
  randn( 'state', seed);

%%%
%%
% input data setup
%
Nusers = 2;

FIR_length = 3;

%                FIR       from    to
FIR_0 = zeros( FIR_length, Nusers, Nusers);

% temporary FSM to try to get different FIR's for each user->user path
%
temp = FSM( [-1 1], FIR_length);
i = 0;
for from = 1:Nusers
  for to = 1:Nusers
    i = i + 1;
    if( from == to)
      scale = 0.8;
    else
      scale = 0.4;
    end
    if( i > size(temp,2)) % recycle
      i = 1;
    end
    FIR_0(:,from,to) = scale * temp(:,i);
  end
end

N = 5;                       % number of data samples

% could use size FIR_length,Nusers for FIR_save,
% but extra N dimension is needed in the time-varying case,
% so put it in here too
%
%                   FIR       t  from    to
FIR_save = zeros( FIR_length, N, Nusers, Nusers);
for from = 1:Nusers
  for to = 1:Nusers
    for t = 1:N
      FIR_save(:,t,from,to) = FIR_0(:,from,to);
    end
  end
end
 
Memory = FIR_length - 1;     % channel memory size

states = FSM( [-1 1], Nusers*Memory);

trans = get_trans_multi( states); % state transition feasibility matrix

M = size(states,2);          % number of states
