1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Array limits

Discussion in 'Support' started by Charles Dye, Nov 3, 2011.

  1. Charles Dye

    Charles Dye Super Moderator
    Staff Member

    Joined:
    May 20, 2008
    Messages:
    3,304
    Likes Received:
    39
    What are the limits on array dimensions and sizes? Available memory? I'm not finding anything in the "Limitations" page of the help file.
     
  2. rconn

    rconn Administrator
    Staff Member

    Joined:
    May 14, 2008
    Messages:
    9,856
    Likes Received:
    83
    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.)
     
  3. Charles Dye

    Charles Dye Super Moderator
    Staff Member

    Joined:
    May 20, 2008
    Messages:
    3,304
    Likes Received:
    39
    Sorry; by "dimensions" I meant the extent or range per dimension. Doubleword?
     
  4. rconn

    rconn Administrator
    Staff Member

    Joined:
    May 14, 2008
    Messages:
    9,856
    Likes Received:
    83
    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 ...)
     
  5. Steve Fabian

    Joined:
    May 20, 2008
    Messages:
    3,520
    Likes Received:
    4
    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
     
  6. vefatica

    Joined:
    May 20, 2008
    Messages:
    7,949
    Likes Received:
    30
    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?
     
  7. Steve Fabian

    Joined:
    May 20, 2008
    Messages:
    3,520
    Likes Received:
    4
    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
     
  8. rconn

    rconn Administrator
    Staff Member

    Joined:
    May 14, 2008
    Messages:
    9,856
    Likes Received:
    83
    Both of your requests were posted in the wrong place. If you want to make
    feature requests, post them with the Feedback tab.
     
  9. Charles Dye

    Charles Dye Super Moderator
    Staff Member

    Joined:
    May 20, 2008
    Messages:
    3,304
    Likes Received:
    39
    Dimensions Way Overboard for Regular Data, then.... Thanks for the clarification.
     

Share This Page