|
From: | Philip Nienhuis |
Subject: | Re: bsxfun and sparse matrices in Matlab |
Date: | Mon, 03 Oct 2011 22:28:30 +0200 |
User-agent: | Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1.11) Gecko/20100701 SeaMonkey/2.0.6 |
Jordi Gutiérrez Hermoso wrote:
On 3 October 2011 10:15, PhilipNienhuis<address@hidden> wrote: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.1270issparse (bsxfun(@plus, x, y)ans = 1issparse (bsxfun(@minus, x, y))ans = 1issparse (bsxfun(@times, x, y))ans = 1issparse (bsxfun(@rdivide, x, y))ans = 1issparse (bsxfun(@ldivide, x, y))ans = 1issparse (bsxfun(@power, x, y))ans = 1 (empty lines removed)I see. Thanks. Can you please also check what the nnz for the results are? I see here in the Octave source a comment about how Matlab
Sorry Jordi for taking your request too literally :-)Anyway hopefully someone else will beat me - I checked this for you in some lost 5 minutes before I had to rush to the train station to get home and tomorrow (Tue) I'm afraid I won't have much spare time :-)
P.
[Prev in Thread] | Current Thread | [Next in Thread] |