% ------------------------------
% forward propagation 

function [loga] = logalpha(x,hmm)

n = length(x);
a = zeros(length(hmm.p0),n);

lp0 = log(hmm.p0);
lPo = log(hmm.Po);
lPt = log(hmm.Pt);

loga(:,1) = lp0' + lPo(:,x(1));
for t=2:n,
  loga(:,t) = logsumexp(op(loga(:,t-1),'+',lPt))'+lPo(:,x(t));
end;

