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$>
References: <gkmlm5$f7s$>
Reply-To: <HIDDEN>
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: 1232024342 2548 (15 Jan 2009 12:59:02 GMT)
NNTP-Posting-Date: Thu, 15 Jan 2009 12:59:02 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1088664
Xref: comp.soft-sys.matlab:511748

"Akim " <aaa@bbb.ccc> wrote in message <gkmlm5$f7s$>...
> 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