octave-maintainers
[Top][All Lists]
Advanced

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

bsxfun and sparse matrices in Matlab


From: Jordi Gutiérrez Hermoso
Subject: bsxfun and sparse matrices in Matlab
Date: Mon, 3 Oct 2011 09:49:31 -0500

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)

Note that @ldivide doesn't even work in Octave right now. That looks
like a bug. I'm not sure if having a matrix full of NaN and and inf
should count as "working", though.

TIA,
- Jordi G. H.


reply via email to

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