Path: news.mathworks.com!not-for-mail
From: "Bruno Luong" <b.luong@fogale.findmycountry>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Can this run any faster?
Date: Wed, 10 Apr 2013 23:29:14 +0000 (UTC)
Organization: FOGALE nanotech
Lines: 25
Message-ID: <kk4ska$hja$1@newscl01ah.mathworks.com>
References: <kk24q4$3j5$1@newscl01ah.mathworks.com> <kk2qqh$158$1@newscl01ah.mathworks.com> <kk4ei1$6ku$1@newscl01ah.mathworks.com> <kk4fec$9fr$1@newscl01ah.mathworks.com> <kk4gv4$ejf$1@newscl01ah.mathworks.com> <kk4hfs$g2v$1@newscl01ah.mathworks.com> <kk4rvi$fvc$1@newscl01ah.mathworks.com>
Reply-To: "Bruno Luong" <b.luong@fogale.findmycountry>
NNTP-Posting-Host: www-04-blr.mathworks.com
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: newscl01ah.mathworks.com 1365636554 18026 172.30.248.35 (10 Apr 2013 23:29:14 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Wed, 10 Apr 2013 23:29:14 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 390839
Xref: news.mathworks.com comp.soft-sys.matlab:793223

Few more ideas, starting from Roger's code:

a=-inf(16,m); % m is your length
a(1,1)=0;
[n m] = size(a);
t1 = transitions(:,1);
t2 = transitions(:,2);
ue = ug+eg;
for i= 1:m-1
    for j = 1:32
        k = t2(j) + i*n;
        A = a(k);
        B = a(t1(j),i);
        if B ~= -inf
            B = B + ue(j,i);
            if A < B
                a(k) = B + log(1+exp(A-B));
            else
                a(k) = A + log(1+exp(B-A));
            end
        end
    end
end

% Bruno