octave-maintainers
[Top][All Lists]
Advanced

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

Re: Saving memory in spones()


From: John W. Eaton
Subject: Re: Saving memory in spones()
Date: Mon, 16 May 2011 13:49:13 -0400

On 16-May-2011, Rik wrote:

| It's e-mail which does a bad job of conveying nuance so I couldn't quite
| tell whether you think this would be a bad idea or not.
|
| >From my perspective, I think Mathworks made the expedient design decision
| at the time and just returned a sparse double.  They made one choice, but I
| don't think we need to slavishly follow them if we have good reasons not
| to.  In this case it saves 7/8 of the memory (88% savings) to use a logical
| type.  In addition, I think there's very little room for compatibility
| problems because the matrix type will automatically be promoted to double
| if a user tries an operation, such as sum, to see how many entries are in
| each column.

I'm not sure whether it would cause real problems if the result is
logical instead of double.  Maybe not, since as you note, a logical
value in Octave can be converted automatically to work in an
arithmetic expression.  I can also think of cases like

  y(spones (x))

in which the idea is to select the elements of Y which correspond to
non-zero elements of X.  In that case, I think this would fail in
Matlab but succeed in Octave if we change the type to logical.  So
that's not really going to cause trouble, and people who want this
behavior in Matlab can write

  y(x != 0)

Apart from actually looking at the class of the object returned by
spones, are there any other cases where logical vs. double matters and
where it will actually do the wrong thing?

It seems to me that we should maybe just leave spones as it is now
since if you want to do the same thing as spones but you want a
logical result, you can just write x != 0.

jwe


reply via email to

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