% initialize Gauss-Markov multi-user ISI problem
%
% R. Perry, Oct. 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 FIR_0;
global FIR_save;

global Nchips;
global Nusers;
global Nsyms;

global TYPE;     % problem type

global alpha;
global alpha2;
global var_v;
global stdev_v;
global C_inv;

global var_noise;
global SNR;

global GG_tmp;
global qq_tmp;
global GG;
global qq;

global ex_known;
global ex_gm;
global ex_p;
%
%%
%%%

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
Nchips = 4
FIR_length = 3

Nsyms = 8	% number of received data samples (symbols) per user

alpha = 0.995
alpha2 = alpha*alpha;

var_v = 0.01
stdev_v = sqrt( var_v);

Memory = FIR_length - 1;     % channel memory size

%%%
%%
% select one full multi-user trellis
% or separate trellises for each user
%
one_trellis = 1

if( one_trellis)

  states = FSM( [-1 1], Nusers*Memory);
  trans = get_trans_multi( states); % state transition feasibility matrix

else

  states = FSM( [-1 1], Memory);
  trans = ~get_trans( states, zeros(FIR_length,1));

end

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

% full inv(C) matrix would have FIR_length*Nusers*Nchips rows and columns
% but here we are assuming that it is block diagonal with these blocks:
%
C_inv = eye( FIR_length*Nusers, FIR_length*Nusers) / var_v;

% user#1 has higher SNR
%
s = [10 20 30];
SNR = [ s; ones(Nusers-1,1)*(s-10)]
