Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

Array limits

Charles Dye

Super Moderator
May
4,948
126
Staff member
What are the limits on array dimensions and sizes? Available memory? I'm not finding anything in the "Limitations" page of the help file.
 
> What are the limits on array dimensions and sizes? Available memory?

SETARRAY documents the dimensions limit (4-dimensional).

There is no limit on the array size other than that set by Windows on your
available virtual memory. (Though anybody who gets anywhere close to that
limit probably has no idea what they're doing, and is definitely using the
wrong language to do it.)
 
From: rconn
| Quote:
|| Sorry; by "dimensions" I meant the extent or range per dimension.
|
| You're restricted to no more than four billion elements per dimension.
| (Here's where Vince and/or Steve jump in and protest that they have an
| urgent need for five billion elements, and why did I implement such a
| cruelly restrictive limitation ...)

Of course! We need quintillion elements! Just to count the characters in our posts in this group of forums.

But beware: what's a billion for a Briton or a German is a trillion for an American or a French. Undoubtedly you meant something in the neighborhood of 4E9, or more precisely, each index is a 32-bit unsigned interger, and whatever fits into that range is OK.

IIRC the arrays are sparse, so an element to which an empty string is actively assigned, or to which no non-empty string was ever assigned (in other words, if it were an ordinary environment variable, would mean not "defined") does not require storage space, so actually using large dimensions is not wasting a lot of storage.

BTW, it is often nice to have an array dimension specified by its (inclusive) lower and upper limits, e.g., with the Fortran statement below:
dimension xxx(-5:15)

Could a future version support this? All it requires in the code is to bias the actual index used to access the array element by the lower limit...
--
Steve
 
On Thu, 03 Nov 2011 18:25:04 -0400, Steve Fabian <> wrote:

|BTW, it is often nice to have an array dimension specified by its (inclusive) lower and upper limits, e.g., with the Fortran statement below:
|dimension xxx(-5:15)
|
|Could a future version support this? All it requires in the code is to bias the actual index used to access the array element by the lower limit...

What in the world would you use that for?
 
From: vefatica
| Steve Fabian wrote:
|| BTW, it is often nice to have an array dimension specified by its
|| (inclusive) lower and upper limits, e.g., with the Fortran statement
|| below: dimension xxx(-5:15)
||
|| Could a future version support this? All it requires in the code is
|| to bias the actual index used to access the array element by the
|| lower limit...
|
| What in the world would you use that for?

Many places! I have just been working with some data where I want to match the first index of an array with a book's columns, but have data only for columns 2..9. Any program that blindly examines all elements of an array as reported by @arrayinfo would need to access 20,000 unused elements before getting to the first one used. The worst part of this is that "if defined array[n]" is never true; to determine whether or not the element contains data you need to test either the length of the element being greater than 0, or set an ordinary environment variable to the array element, and check whether or not that variable is defined.

Rex:
In a future version could you make "if defined" work for array elements in the same manner as for exnvironment variables?
Both of my requests releating to arrays are backward compatible!
--
Steve
 

Similar threads

Back
Top