[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Octave-bug-tracker] [bug #47469] sizemax() is off by one
From: |
Kai Torben Ohlhus |
Subject: |
[Octave-bug-tracker] [bug #47469] sizemax() is off by one |
Date: |
Wed, 30 Mar 2016 10:50:13 +0000 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.110 Safari/537.36 |
Follow-up Comment #1, bug #47469 (project octave):
I suggest to deprecate "sizemax" and remove "dim_vector::dim_max". Or is there
any non-obvious benefit from it?
1. The function name is misleading. "numelmax" or alike would be more
applicable, as it gives the information, how many elements an array can index.
The misleading idea is, that something like
ones (2, sizemax())
was okay. I think in bug #47468 the intention is to use it in test code, what
I think is a bad idea, to start relying on this function.
2. The information of 64-bit indices for the user is implicitly given by
__have_feature__ ("ENABLE_64")
3. The only "real" usage is in scripts/sparse/private/__sprand__.m, but after
diving into that code, it is only part of a dirty hack, that should be solved
in the randperm() function.
>> grep -R sizemax
libinterp/corefcn/bitfcns.cc:DEFUN (sizemax, args, ,
libinterp/corefcn/bitfcns.cc:@deftypefn {} {} sizemax ()\n\
libinterp/corefcn/bitfcns.cc:%!assert (sizemax () >= (intmax ("int32") - 1))
libinterp/corefcn/bitfcns.cc:%!error sizemax (0)
scripts/sparse/private/__sprand__.m: if (mn > sizemax ())
>> grep -R dim_max
liboctave/array/dim-vector.h: static octave_idx_type dim_max (void);
liboctave/array/dim-vector.cc:dim_vector::dim_max (void)
liboctave/array/dim-vector.cc: octave_idx_type idx_max = dim_max ();
libinterp/corefcn/bitfcns.cc: return octave_value
(octave_int<octave_idx_type> (dim_vector::dim_max ()));
_______________________________________________________
Reply to this item at:
<http://savannah.gnu.org/bugs/?47469>
_______________________________________________
Message sent via/by Savannah
http://savannah.gnu.org/