Path: news.mathworks.com!not-for-mail From: "Elnaz " <ebsadeghian@gmail.com> Newsgroups: comp.soft-sys.matlab Subject: Re: Can this run any faster? Date: Wed, 10 Apr 2013 19:29:05 +0000 (UTC) Organization: Georgia Institute of Technology Lines: 26 Message-ID: <kk4ei1$6ku$1@newscl01ah.mathworks.com> References: <kk24q4$3j5$1@newscl01ah.mathworks.com> <kk2qqh$158$1@newscl01ah.mathworks.com> Reply-To: "Elnaz " <ebsadeghian@gmail.com> NNTP-Posting-Host: www-01-blr.mathworks.com Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Trace: newscl01ah.mathworks.com 1365622145 6814 172.30.248.46 (10 Apr 2013 19:29:05 GMT) X-Complaints-To: news@mathworks.com NNTP-Posting-Date: Wed, 10 Apr 2013 19:29:05 +0000 (UTC) X-Newsreader: MATLAB Central Newsreader 998620 Xref: news.mathworks.com comp.soft-sys.matlab:793202 Thanks Roger; that is a clever substitute. It runs 0.01 second faster than the original one. Steve: The code above is an excerpt of BCJR algorithm. It is the forward recursion part which sweeps over the trellis structure from the beginning to the end in forward direction. It is difficult to explain in words what that excerpt is trying to do for the general audience since it requires a lot of backgroun math to set the scene. I have another loop similar to the first one which is a backward recursion. It starts from the end working its way to the beginning: % Backwards recursion b=zeros(16,length); b=b-inf; b(1,length)=0; for i= length-1:-1:1 for j= 1:32 A = b(transitions(j,1),i); B = b(transitions(j,2),i+1) + ug (j, i+1) + eg(j, i+1); if(A == -inf && B == -inf) b(transitions(j,1),i) = -inf; else b(transitions(j,1),i)= max(A,B) + log(1+exp(-abs(A-B))); end end end If I apply Roger's idea I get 0.02 sec improvement in one calling. However, the main problem that costs time here is the big length of the signal (the variable i here). But thanks Roger, that was clever.