diff src/bitfcns.cc @ 10811:e38c071bbc41

allow user query the maximum array size
author Jaroslav Hajek <highegg@gmail.com>
date Wed, 21 Jul 2010 08:47:34 +0200
parents 57a59eae83cc
children b4ebfd675321
line wrap: on
line diff
--- a/src/bitfcns.cc	Tue Jul 20 21:19:10 2010 +0200
+++ b/src/bitfcns.cc	Wed Jul 21 08:47:34 2010 +0200
@@ -652,3 +652,23 @@
 
   return retval;
 }
+
+DEFUN (sizemax, args, ,
+  "-*- texinfo -*-\n\
+@deftypefn {Built-in Function} {} sizemax ()\n\
+Return the largest value that is allowed as the size of an array.\n\
+If Octave is compiled with 64-bit indexing, the result is of class int64,\n\
+otherwise it is of class int32. It will be a tiny bit lower than the maximum\n\
+allowable value for that type, as reported by intmax.\n\
+@seealso{intmax}\n\
+@end deftypefn")
+{
+  octave_value retval;
+
+  if (args.length () == 0)
+    retval = octave_int<octave_idx_type> (dim_vector::dim_max);
+  else
+    print_usage ();
+
+  return retval;
+}