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 16:04:02 +0000 (UTC)
Organization: FOGALE nanotech
Lines: 9
Message-ID: <h2qith$ojj$1@fred.mathworks.com>
References: <14646834.75779.1246802812202.JavaMail.jakarta@nitrogen.mathforum.org> <1e37765c-af3c-49d8-8465-8203f0c78f19@d4g2000yqa.googlegroups.com>
Reply-To: "Bruno Luong" <b.luong@fogale.findmycountry>
NNTP-Posting-Host: webapp-05-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1246809842 25203 172.30.248.35 (5 Jul 2009 16:04:02 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Sun, 5 Jul 2009 16:04:02 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 390839
Xref: news.mathworks.com comp.soft-sys.matlab:552898


Rune,

In short, ACCUMARRAY does for nd-array what SPARSE does for sparse matrix. It accumulates the vector elements (second input argument) depending on where they are located on a 'cell' (defined by the first input argument of subindexes).

The subindex/vector might come in random order and arbitrary length. ACCUMARRAY just add them together on each cell. The sum result is then retuned as the array, each element corresponds to a 'cell'.

The "adding" behavior can be changed by passing a use function handle (such as @mean).

Bruno