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

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

[Octave-bug-tracker] [bug #61788] arrays of type int16 contain wrong num


From: John W. Eaton
Subject: [Octave-bug-tracker] [bug #61788] arrays of type int16 contain wrong numbers
Date: Tue, 11 Jan 2022 10:16:39 -0500 (EST)
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Firefox/91.0

Follow-up Comment #4, bug #61788 (project octave):

Doing what you suggest is fine for generating all the numbers in an array. 
But in Octave, we have ranges stored as base, limit, and increment and allow
indexing to obtain arbitrary elements.  I don't think you really want to have
to count from the beginning of an array all the way to the end just to access
the last element (or one near the last).

OTOH, to me, this appears to be just another example showing how the idea I
had years ago of storing ranges as special objects may just not be worth it. 
I would be glad to just eliminate ranges as a special storage type and simply
make colon expressions be syntactic shorthand for creating arrays with evenly
spaced elements (as I believe they are in Matlab).

Note that we also have the same problem for things like


for i = int8(-100):int8(100), i, end


but this problem can be fixed using the "increment previous value" method
since we are iterating over all elements, not indexing arbitrary elements.

And now, ranges in for loops are handled separately so that the range object
is not created directly, so we don't have to worry about memory issues in
range expressions if we eliminate the special range type.

    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?61788>

_______________________________________________
  Message sent via Savannah
  https://savannah.gnu.org/




reply via email to

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