Path: news.mathworks.com!not-for-mail
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$1@fred.mathworks.com>
References: <gkmlm5$f7s$1@fred.mathworks.com> <gkns7u$2b3$1@fred.mathworks.com> <gkp0id$666$1@fred.mathworks.com> <gkpl0q$7dj$1@fred.mathworks.com>
Reply-To: <HIDDEN>
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 1232125382 12238 172.30.248.35 (16 Jan 2009 17:03:02 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Fri, 16 Jan 2009 17:03:02 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1440443
Xref: news.mathworks.com comp.soft-sys.matlab:512085

"Matt " <mjacobson.removethis@xorantech.com> wrote in message <gkpl0q$7dj$1@fred.mathworks.com>...
> "Akim " <aaa@bbb.ccc> wrote in message <gkp0id$666$1@fred.mathworks.com>...
> >
> > 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.