% setup_combos() - setup global variables: perms, combos, unique_perms, MP, M, perm_offset
% Global variables used: K, MM_max
%
function setup_combos()

global perms;
global combos;
global unique_perms;
global MP;
global M;
global perm_offset;

global K;
global MM_max;

perms = permutations(1:K);
MP = size(perms,2);

combos = combinations( 1:MM_max, K);
M = size(combos,2);

unique_perms = [1:MP]' * ones(1,M);

for i = K-1:-1:1
  tc = combinations( 1:MM_max, i);
  tc = [tc; (MM_max+1)*ones(K-i,size(tc,2))];	% K-i missed target events
  combos = [combos, tc];
  up = get_unique_perms( tc(:,1));
  unique_perms = [unique_perms, up*ones(1,size(tc,2))];
end

combos = [combos, (MM_max+1)*ones(K,1)];	% K missed target events
unique_perms = [unique_perms, eye(MP,1)];

M = size(combos,2);

% perm_offset is needed by get_perm()
%
perm_offset = [0:K-1]'*((MM_max+1)*ones(1,MP));
