changeset 27880:31b95261c7d2

Backed out changeset 2890a931e647 (bug #47469) This requires more thought, and release in version 7 of Octave.
author Rik <rik@octave.org>
date Mon, 30 Dec 2019 13:08:47 -0800
parents b9710ee393ac
children f5e1072f1635
files doc/interpreter/numbers.txi libinterp/corefcn/bitfcns.cc liboctave/array/dim-vector.cc liboctave/array/dim-vector.h scripts/deprecated/module.mk scripts/deprecated/sizemax.m scripts/sparse/private/__sprand__.m
diffstat 7 files changed, 32 insertions(+), 74 deletions(-) [+]
line wrap: on
line diff
--- a/doc/interpreter/numbers.txi	Fri Dec 27 22:23:00 2019 +0100
+++ b/doc/interpreter/numbers.txi	Mon Dec 30 13:08:47 2019 -0800
@@ -277,10 +277,11 @@
 separate matrix elements and rows.
 
 The maximum number of elements in a matrix is fixed when Octave is compiled.
-If compiled with 64-bit index pointers the limit is @code{intmax ("int64")},
-otherwise it is @code{intmax ("int32")}.  Note that other factors, such as the
-amount of memory available on your machine, may limit the maximum size of
-matrices to something smaller.
+The allowable number can be queried with the function @code{sizemax}.  Note
+that other factors, such as the amount of memory available on your machine,
+may limit the maximum size of matrices to something smaller.
+
+@DOCSTRING(sizemax)
 
 When you type a matrix or the name of a variable whose value is a
 matrix, Octave responds by printing the matrix in with neatly aligned
--- a/libinterp/corefcn/bitfcns.cc	Fri Dec 27 22:23:00 2019 +0100
+++ b/libinterp/corefcn/bitfcns.cc	Mon Dec 30 13:08:47 2019 -0800
@@ -946,3 +946,27 @@
 %!error <not defined for 'double' objects> intmin ("double")
 %!error <not defined for 'char' objects> intmin ("char")
 */
+
+DEFUN (sizemax, args, ,
+       doc: /* -*- texinfo -*-
+@deftypefn {} {} sizemax ()
+Return the largest value allowed for the size of an array.
+
+If Octave is compiled with 64-bit indexing, the result is of class int64,
+otherwise it is of class int32.  The maximum array size is slightly
+smaller than the maximum value allowable for the relevant class as reported
+by @code{intmax}.
+@seealso{intmax}
+@end deftypefn */)
+{
+  if (args.length () != 0)
+    print_usage ();
+
+  return octave_value (octave_int<octave_idx_type> (dim_vector::dim_max ()));
+}
+
+/*
+%!assert (sizemax () >= (intmax ("int32") - 1))
+
+%!error sizemax (0)
+*/
--- a/liboctave/array/dim-vector.cc	Fri Dec 27 22:23:00 2019 +0100
+++ b/liboctave/array/dim-vector.cc	Mon Dec 30 13:08:47 2019 -0800
@@ -39,7 +39,6 @@
   return zv.rep;
 }
 
-// FIXME: DEPRECATED, remove in version 8.
 // The maximum allowed value for a dimension extent.  This will normally be a
 // tiny bit off the maximum value of octave_idx_type.
 // Currently 1 is subtracted to allow safe conversion of any 2D Array into
@@ -103,7 +102,7 @@
 octave_idx_type
 dim_vector::safe_numel (void) const
 {
-  octave_idx_type idx_max = std::numeric_limits<octave_idx_type>::max ();
+  octave_idx_type idx_max = dim_max ();
   octave_idx_type n = 1;
   int n_dims = ndims ();
 
--- a/liboctave/array/dim-vector.h	Fri Dec 27 22:23:00 2019 +0100
+++ b/liboctave/array/dim-vector.h	Mon Dec 30 13:08:47 2019 -0800
@@ -261,7 +261,6 @@
 
 public:
 
-  OCTAVE_DEPRECATED (6, "dim_vector::dim_max () is deprecated; any uses should be removed")
   static octave_idx_type dim_max (void);
 
   explicit dim_vector (void) : rep (nil_rep ())
--- a/scripts/deprecated/module.mk	Fri Dec 27 22:23:00 2019 +0100
+++ b/scripts/deprecated/module.mk	Mon Dec 30 13:08:47 2019 -0800
@@ -2,8 +2,7 @@
 
 %canon_reldir%_FCN_FILES = \
   %reldir%/output_max_field_width.m \
-  %reldir%/runtests.m \
-  %reldir%/sizemax.m
+  %reldir%/runtests.m
 
 %canon_reldir%dir = $(fcnfiledir)/deprecated
 
--- a/scripts/deprecated/sizemax.m	Fri Dec 27 22:23:00 2019 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,58 +0,0 @@
-## Copyright (C) 2019 Rik Wehbring
-##
-## This file is part of Octave.
-##
-## Octave is free software: you can redistribute it and/or modify it
-## under the terms of the GNU General Public License as published by
-## the Free Software Foundation, either version 3 of the License, or
-## (at your option) any later version.
-##
-## Octave is distributed in the hope that it will be useful, but
-## WITHOUT ANY WARRANTY; without even the implied warranty of
-## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-## GNU General Public License for more details.
-##
-## You should have received a copy of the GNU General Public License
-## along with Octave; see the file COPYING.  If not, see
-## <https://www.gnu.org/licenses/>.
-
-## -*- texinfo -*-
-## @deftypefn {} {} sizemax ()
-##
-## @code{sizemax} is deprecated and will be removed in Octave version 8.
-##
-## Return the largest value allowed for the size of an array.
-##
-## If Octave is compiled with 64-bit indexing, the result is of class int64,
-## otherwise it is of class int32.  The maximum array size is slightly smaller
-## than the maximum value allowable for the relevant class as reported by
-## @code{intmax}.
-## @seealso{intmax}
-## @end deftypefn
-
-## FIXME: DEPRECATED: Remove in version 8.
-
-function retval = sizemax (varargin)
-
-  persistent warned = false;
-  if (! warned)
-    warned = true;
-    warning ("Octave:deprecated-function",
-             "sizemax is obsolete and will be removed from a future version of Octave\n");
-  endif
-
-  if (nargin != 0)
-    print_usage ();
-  endif
-
-  if (__have_feature__ ("ENABLE_64"))
-    retval = intmax ("int64") - 1;
-  else
-    retval = intmax ("int32") - 1;
-  endif
-
-endfunction
-
-
-%!assert (sizemax () >= (intmax ("int32") - 1))
-%!error sizemax (0)
--- a/scripts/sparse/private/__sprand__.m	Fri Dec 27 22:23:00 2019 +0100
+++ b/scripts/sparse/private/__sprand__.m	Mon Dec 30 13:08:47 2019 -0800
@@ -56,13 +56,7 @@
     if (nargin == 5)
       mn = m*n;
       k = round (d*mn);
-      ## FIXME: randperm() should be fixed to handle large values
-      if (__have_feature__ ("ENABLE_64"))
-        max_numel = intmax ("int64");
-      else
-        max_numel = intmax ("int32");
-      endif
-      if (mn > max_numel)
+      if (mn > sizemax ())
         ## randperm will overflow, so use alternative methods
 
         idx = unique (fix (rand (1.01*k, 1) * mn)) + 1;