From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: taking the exponential of only the nonzero elements of a sparse matrix
Date: Fri, 16 Jan 2009 17:03:02 +0000 (UTC)
Organization: Xoran Technologies
Lines: 18
Message-ID: <gkqek6$bue$>
References: <gkmlm5$f7s$> <gkns7u$2b3$> <gkp0id$666$> <gkpl0q$7dj$>
Reply-To: <HIDDEN>
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: 1232125382 12238 (16 Jan 2009 17:03:02 GMT)
NNTP-Posting-Date: Fri, 16 Jan 2009 17:03:02 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1440443
Xref: comp.soft-sys.matlab:512085

"Matt " <> wrote in message <gkpl0q$7dj$>...
> "Akim " <aaa@bbb.ccc> wrote in message <gkp0id$666$>...
> >
> > In my simulations spfun runs slightly faster cf. Bruno's code, apparently because feval(@exp,x) is faster than exp(x).
> I don't think so.
> I'm pretty sure the reason is that spfun(A) has to generate new matrix elements only, but not a new table of indices of the explicit matrix elements. The index table is shared with the original matrix A using a copy-on-write pointer.
> When you call sparse() however, MATLAB does no data sharing and creates an entirely new sparse matrix object from scratch.

Actually, I've done some of my own tests and don't see a significant speed difference between either approach. Of course, I don't know what matrix size and density you are using...

Anyway, my above conjecture might be no more than that.