function bnet = mk_space_for_hmm_marginals(bnet, discrete)
% MK_SPACE_FOR_HMM_MARGINALS Make space to store the marginals (since we can't store them in the cliques)
% bnet = mk_space_for_hmm_marginals(bnet, discrete)

ss = bnet.slice_size;
ns = bnet.node_sizes;
if discrete
  ns(bnet.observed_nodes) = 1;
else
  ns(bnet.observed_nodes) = 0;
end
T = bnet.num_slices;
bnet.hmm.two_slice_marginal = cell(1,T);
bnet.hmm.one_slice_marginal = cell(1,T);

for t=1:T
  dom = (1:ss) + (t-1)*ss; % all nodes in the slice (although some may be observed)
  if discrete
    bnet.hmm.one_slice_marginal{t} = mk_table(dom, ns(dom));
  else
    bnet.hmm.one_slice_marginal{t} = mk_gpot(dom, ns(dom), 'm');
  end
end

for t=1:T-1
  current_slice = bnet.hidden_slice + (t-1)*ss;
  next_slice = bnet.hidden_slice + (t)*ss;
  dom = [current_slice next_slice];
  if discrete
    bnet.hmm.two_slice_marginal{t} = mk_table(dom, ns(dom));
  else
    bnet.hmm.two_slice_marginal{t} = mk_gpot(dom, ns(dom), 'm');
  end
end


