octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: bsxfun and sparse matrices in Matlab


From: PhilipNienhuis
Subject: Re: bsxfun and sparse matrices in Matlab
Date: Mon, 3 Oct 2011 08:15:11 -0700 (PDT)

Jordi Gutiérrez Hermoso-2 wrote:
> 
> While testing more things about auto BSX, I noticed that I missed to
> overload the operators for sparse matrices, and while investigating
> *that*, it seems like bsxfun destroys sparsity. While this may make
> sense for some operators (e.g. power operators), I wanted to confirm
> if this is what Matlab does.
> 
> Can someone please confirm if the following does not produce sparse
> matrices?
> 
>     x = sprand(1,3,1/3); y = x';
>     bsxfun(@plus, x, y)
>     bsxfun(@minus, x, y)
>     bsxfun(@times, x, y)
>     bsxfun(@rdivide, x, y)
>     bsxfun(@ldivide, x, y)
>     bsxfun(@power, x, y)
> 
> 

At work (ML r2009a):

>> x = sprand(1,3,1/3); y = x'
y =
   (3,1)       0.1270
>> issparse (bsxfun(@plus, x, y)
ans =
     1
>> issparse (bsxfun(@minus, x, y))
ans =
     1
>> issparse (bsxfun(@times, x, y))
ans =
     1
>> issparse (bsxfun(@rdivide, x, y))
ans =
     1
>> issparse (bsxfun(@ldivide, x, y))
ans =
     1
>> issparse (bsxfun(@power, x, y))
ans =
     1

(empty lines removed)


--
View this message in context: 
http://octave.1599824.n4.nabble.com/bsxfun-and-sparse-matrices-in-Matlab-tp3867746p3867801.html
Sent from the Octave - Maintainers mailing list archive at Nabble.com.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]