octave-bug-tracker
[Top][All Lists]
Advanced

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

[Octave-bug-tracker] [bug #45622] Sparsity of sparse matrix when assigni


From: Amro
Subject: [Octave-bug-tracker] [bug #45622] Sparsity of sparse matrix when assigning all elements
Date: Sat, 25 Jul 2015 16:20:26 +0000
User-agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:41.0) Gecko/20100101 Firefox/41.0

Follow-up Comment #2, bug #45622 (project octave):

Interesting, I didn't know about the "sparse_auto_mutate" option!

As for your interpretation of the expression M(:), I'm not sure it applies to
MATLAB, it being similar in behavior to REPMAT...


M = sparse(4,4);
M(:) = sparse(1);


The above is no different from the previous code with "M(:) = 1" when run in
MATLAB.

As for mixing different data types, there are well-defined rules for
up/down-casting between unlike classes, as described in this documentation
page:

http://www.mathworks.com/help/matlab/matlab_prog/valid-combinations-of-unlike-classes.html


M = uint8 (zeros (2,2));
M(:) = 1.1;


So according to the previous link, the matrix stays uint8 as expected, and the
1.1 elements are basically rounded to 1, i.e equivalent to writing "M(:) =
uint8(1.1)". I view sparsity as an attribute of the array not a data type on
its own.

The way I see it, "M(:) = ..." is simply treated as a special case in MATLAB,
and the sparse matrix gets converted to full unless the scalar value 0 is used
as in "A(:)=0".

I'm not necessarily asking to reproduce the behavior in Octave... Personally I
think a sparse matrix should remain so no matter what operation is performed
on it, excluding of course explicit conversion to FULL.


    _______________________________________________________

Reply to this item at:

  <http://savannah.gnu.org/bugs/?45622>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.gnu.org/




reply via email to

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