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: Thu, 15 Jan 2009 12:59:02 +0000 (UTC)
Organization: FZ-Juelich
Lines: 22
Message-ID: <gknbum$2fk$1@fred.mathworks.com>
References: <gkmlm5$f7s$1@fred.mathworks.com>
Reply-To: <HIDDEN>
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 1232024342 2548 172.30.248.38 (15 Jan 2009 12:59:02 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Thu, 15 Jan 2009 12:59:02 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1088664
Xref: news.mathworks.com comp.soft-sys.matlab:511748

"Akim " <aaa@bbb.ccc> wrote in message <gkmlm5$f7s$1@fred.mathworks.com>...
> Dear All,
> 
> Matlab help tells me that "Multiplication and division are performed on only the nonzero elements of sparse matrices." What about something similar for the exponential?
> 
> Specifically, given a sparse matrix A, I wish to obtain a sparse matrix B, such that
> 
> B(i,j)=exp(A(i,j)), for all nonzero A(i,j)
> B(i,j)=0, for all zero A(i,j)
> 
> I'm only interested in the exponents of the nonzeros, and calculating the exponents of a vast number of zeros slows things down a little bit.
> 
> Thank you for your help.

Hi Akim, 

why not try 

B = exp(A(A~=0))

hth kinor