% 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 Nchips;
global Nusers;
global FIR_save;
global FIR_0;

global TYPE;     % problem type

%TYPE = 30;       % multi-user, Gauss-Markov

TYPE = 40; 		%multi-user, GM known channel cost function, sep trellis

global alpha;
global alpha2;
global var_v;

global var_noise;
global SNR;
%
%%
%%%

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 = 15	% number of received data samples (symbols) per user - 5 was original value

alpha = 0.995
alpha2 = alpha*alpha;

var_v = 0.01

FIR_0 = sqrt(var_v/(1-alpha2)) * randn( FIR_length, Nusers, Nchips);

FIR_save = zeros( FIR_length, Nusers, Nchips, Nsyms);

F = FIR_0;

for t = 1:Nsyms
  F = alpha * F + sqrt(var_v) * randn( FIR_length, Nusers, Nchips);
  FIR_save(:,:,:,t) = F;
end
 
Memory = FIR_length - 1;     % channel memory size

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

%trans = get_trans_multi( states); % state transition feasibility matrix
trans=~get_trans(states, zeros(FIR_length,1))     %%%%%%%NEW LINE%%%%%%%%%%
%trans=[1 0 1 0; 1 0 1 0; 0 1 0 1; 0 1 0 1]

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

SNR = 40        %10 was original value
