Path: news.mathworks.com!not-for-mail
From: "Bruno Luong" <b.luong@fogale.findmycountry>
Newsgroups: comp.soft-sys.matlab
Subject: Re: HOWTO: Accelerate processing algorithm
Date: Sun, 5 Jul 2009 11:51:01 +0000 (UTC)
Organization: FOGALE nanotech
Lines: 13
Message-ID: <h2q435$r64$1@fred.mathworks.com>
References: <32955484.75385.1246792760370.JavaMail.jakarta@nitrogen.mathforum.org>
Reply-To: "Bruno Luong" <b.luong@fogale.findmycountry>
NNTP-Posting-Host: webapp-03-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1246794661 27844 172.30.248.38 (5 Jul 2009 11:51:01 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Sun, 5 Jul 2009 11:51:01 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 390839
Xref: news.mathworks.com comp.soft-sys.matlab:552869


Jose Antonio <juriguen@gmail.com> wrote in message 
>
> S = sparse(1:size(ySort), double((ySort+1).'), xMat.*exposuresMat);
> S = sum(S);

The two lines above can be replaced by :

v = xMat.*exposuresMat;
S = accumarray(ySort(:)+1,v(:));

It also avoid to create S and the required memory

Bruno