[GAP Forum] Range of List Iteration

Frank Lübeck frank.luebeck at math.rwth-aachen.de
Wed May 5 10:39:10 BST 2010


On Mon, May 03, 2010 at 10:42:03AM +0100, Sandeep Murthy wrote:
> The programs work fine for groups of order n <= 27, but not for n >= 28 - GAP says that a
> loop cannot over a range >= 2^28. Is this an absolute limit, or is this machine dependent?

Dear Sandeep Murthy, dear Forum,

Here are a few general remarks about ranges [a..b] in GAP. 
These are (currently) implemented with some machine dependend restrictions: 
The integers a and b and the length of the range must have absolute value
< 2^28  if GAP is compiled for 32-bit systems, and < 2^60 if GAP is compiled
for 64-bit systems. The reason for this limitation is efficiency of loops
over such ranges.

So, in your case I suggest two possible solutions:

(1) Use the 64-bit version of GAP on a 64-bit system. With a limit
    of 2^60 you run into other problems before asking for larger ranges.
(2) Don't use a range in your loop, e.g.:

  i := 1;
  while i < 2^28-1 do
  od;
    
    needs about 40 seconds on my computer compared to 

  for i in [1..2^28-1] do  od;

    which takes about 5 seconds. So, the additional overhead in the 
    while-loop is probably neglectible if the body of your loop is not
    empty. In the while-loop there is no restriction on the integer you 
    compare to, so 'while i < 2^32 do ...' is no problem.

Side remark: Very often it is still sensible to use a 32-bit version of GAP,
even on a 64-bit system because it is more memory efficient and often slightly
faster (depends on what exactly you are doing), see also the comment at:
   http://www.math.rwth-aachen.de/RsyncLinuxGAP/index.html#32versus64

Best regards,
   Frank 
-- 
///  Dr. Frank Lübeck, Lehrstuhl D für Mathematik, Templergraben 64,  ///
\\\                    52062 Aachen, Germany                          \\\
///  E-mail: Frank.Luebeck at Math.RWTH-Aachen.De                        ///
\\\  WWW:    http://www.math.rwth-aachen.de/~Frank.Luebeck/           \\\




More information about the Forum mailing list