[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Octave-bug-tracker] [bug #62968] idx_vector constructor m_len calculati
From: |
Maged Rifaat |
Subject: |
[Octave-bug-tracker] [bug #62968] idx_vector constructor m_len calculation is incorrect |
Date: |
Sat, 27 Aug 2022 14:08:48 -0400 (EDT) |
Follow-up Comment #2, bug #62968 (project octave):
[comment #1 comment #1:]
> Is `m_len` the number of elements in the idx_vector? (I think it is.) Is
`limit` included in the range? (Not sure if it is meant to be.)
Well I can't be sure in the absence of documentation, but from the usage that
I can find of this constructor across the code-base I think `limit` is not
included in the range.
For example, it was used in libinterp/corefcn/base-text-renderer line 52
<https://hg.octave.org/octave/file/tip/libinterp/corefcn/base-text-renderer.cc#l52>
for reversing a matrix like this:
idx(1) = idx_vector (pixels.dim2 ()-1, -1, -1);
Which implies that the start is included but the limit isn't, and this aligns
with the original formula (and mine).
[comment #1 comment #1:]
> Would the following change fix this?
I think your formula is very similar to the formula found in
liboctave/array/Range.h line 359
<https://hg.octave.org/octave/file/tip/liboctave/array/Range.h#l359>, but the
range class uses the same convention as Octave itself (i.e. 1:1:10 is the same
as range<double> (1, 1, 10) AFAICT), so the limit is included.
_______________________________________________________
Reply to this item at:
<https://savannah.gnu.org/bugs/?62968>
_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/