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

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

[Octave-bug-tracker] [bug #50776] Octave inconsistent with Matlab for co


From: Rik
Subject: [Octave-bug-tracker] [bug #50776] Octave inconsistent with Matlab for corner indexing case
Date: Wed, 12 Apr 2017 12:21:36 -0400 (EDT)
User-agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:52.0) Gecko/20100101 Firefox/52.0

Follow-up Comment #8, bug #50776 (project octave):

The patch works for me with the reporter's original test!

I wrote "any logical array index is first converted to a column vector"
because in my terminology an array is an N-d object which is not a scalar or a
vector, what we would traditionally just call a matrix.  Any logical array
which is not 1x1, 1xN, or Nx1 is first reshaped to Nx1 before indexing.

In pseudo-code


if (islogical (idx))
  if (! isvector (idx))
    idx = idx(:);
    numeric_idx = find (idx);
  endif
endif
obj(numeric_idx)


One of the advantages to logical indexing is that it takes less memory.  Is
that advantage still preserved?  I think it is, but seems worth asking.

For example, for this test case


x = rand (1e4,1);
logical_idx = (x > 0.5);
numeric_idx = find (logical_idx);
whos *idx
Variables in the current scope:

   Attr Name             Size                     Bytes  Class
   ==== ====             ====                     =====  ===== 
        logical_idx  10000x1                      10000  logical
        numeric_idx   4906x1                      39248  double



As you would expect, numeric indices use a lot more memory because they store
everything as 8-byte doubles.

Is there some point where we convert the logical index to a linear index deep
in the C++ code?  That would be a bummer.



    _______________________________________________________

Reply to this item at:

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

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




reply via email to

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