[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Applying function to vector by index
From: |
Paul Kienzle |
Subject: |
Re: Applying function to vector by index |
Date: |
Thu, 12 Dec 2002 12:31:15 -0500 |
User-agent: |
Mutt/1.2.5.1i |
On Thu, Dec 12, 2002 at 05:58:32PM +0100, Schloegl Alois wrote:
> I'd call it flexibility:
> sparse(a).^(b+i*c) evaluates only the non-zero elements of a.
> The alternative is always possible with full(a).^(b+i*c)
Even if you treat zeros values correctly you can get flexibility
as follows:
[i,j,v,m,n]=spfind(sparse(a));
a = sparse(i,j,f(v),m,n);
Admittedly, this is not as convenient as a = f(sparse(v)) operating
only on the defined values of the sparse matrix. However, I notice
that matlab returns [-1 1;1 -1] from cos(sparse(pi*eye(2))), so you
will sacrifice compatibility for this convenience.
Personally I would rather not have functions spontaneously converting
sparse matrices to full since really small sparse matrices can form
really big full matrices, but I also would not want to introduce
needless incompatibilities.
BTW, I notice that
sparse(1,1,0)
returns the following:
Compressed Column Sparse (rows=1, cols=1, nnz=1)
(1 , 1) -> 0
and
[i,j,v] = spfind(sparse(1,1,0))
returns
i = 1
j = 1
v = 0
I haven't decided if this is a bug or a feature. I don't know if
this is a compatibility issue.
Paul Kienzle
address@hidden
-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.
Octave's home on the web: http://www.octave.org
How to fund new projects: http://www.octave.org/funding.html
Subscription information: http://www.octave.org/archive.html
-------------------------------------------------------------
- Re: Applying function to vector by index, (continued)
- Re: Applying function to vector by index, Mike Miller, 2002/12/09
- Re: Applying function to vector by index, Paul Kienzle, 2002/12/09
- Re: Applying function to vector by index, Iago Mosqueira, 2002/12/09
- Re: Applying function to vector by index, Paul Kienzle, 2002/12/09
- Re: Applying function to vector by index, Paul Kienzle, 2002/12/09
- Re: Applying function to vector by index, Andy Adler, 2002/12/09
- Re: Applying function to vector by index, Schloegl Alois, 2002/12/10
- Re: Applying function to vector by index, Paul Kienzle, 2002/12/12
- Re: Applying function to vector by index, Andy Adler, 2002/12/12
- Re: Applying function to vector by index, Schloegl Alois, 2002/12/12
- Re: Applying function to vector by index,
Paul Kienzle <=
- Re: Applying function to vector by index, Andy Adler, 2002/12/12
- Re: Applying function to vector by index, Paul Kienzle, 2002/12/12
- Re: Applying function to vector by index, Andy Adler, 2002/12/11
Re: Applying function to vector by index, Mike Miller, 2002/12/09