function cost_init( vnum)
%
% initialize Viterbi cost function
%
% R. Perry, Oct. 2001

global USE_GGqq_tmp;

global TYPE;

global Vparam;   % Viterbi parameters


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

global Nusers;
global Nchips;
global FIR_length;
global FIR_0;
global C_inv;
global alpha;
global alpha2;
global var_noise;

if( TYPE == 30) % multi-user, Gauss-Markov, known channel

  % do nothing

elseif( TYPE == 31) % multi-user, Gauss-Markov cost

  % get Viterbi parameters
  %
  L  = Vparam(1);
  M  = Vparam(2);
  Nv = Vparam(4);

  if( Nv ~= 1)
    error( 'cost_init: TYPE == 31 but Nv != 1');
  end

  % full GG_i(:,:,el,m) matrix would have FIR_length*Nusers*Nchips rows and columns
  % but here we are assuming that it is block diagonal with these size blocks
  % as for C_inv:
  %
  GG = zeros( FIR_length*Nusers, FIR_length*Nusers, L, M);

  qq = zeros( FIR_length*Nusers, Nchips, L, M);

  if( USE_GGqq_tmp)
    %
    % temporary G and q for get_cost state transitions
    %
    GG_tmp = zeros( FIR_length*Nusers, FIR_length*Nusers, L, M, M);

    qq_tmp = zeros( FIR_length*Nusers, Nchips, L, M, M);
  end

elseif( TYPE == 40) % multi-user, Gauss-Markov, known channel, separate trellises

  % do nothing

else

  error( 'cost_init: unknown TYPE');

end
