Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions grp/simple.gd
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,9 @@ DeclareGlobalFunction("EpimorphismFromClassical");
##
## <Description>
## This function returns an iterator that will run over all nonabelian simple groups, starting
## at order <A>start</A> if specified, up to order <M>10^{27}</M> (or -- if specified
## -- order <A>end</A>). If the option <A>NOPSL2</A> is given, groups of type
## at order <A>start</A> if specified, and stopping at order <A>end</A> if specified.
## Only orders up to <M>10^{27}</M> are available. Attempting to iterate beyond that
## results in an error. If the option <A>NOPSL2</A> is given, groups of type
## <M>PSL_2(q)</M> are omitted.
## <Example><![CDATA[
## gap> it:=SimpleGroupsIterator(20000);
Expand Down
15 changes: 13 additions & 2 deletions grp/simple.gi
Original file line number Diff line number Diff line change
Expand Up @@ -787,6 +787,19 @@ InstallGlobalFunction(SimpleGroupsIterator,function(arg)
fi;
nopsl2:=ValueOption("NOPSL2")=true or ValueOption("nopsl2")=true;

# The non-L2 orders come in two lists, the second loaded on demand.
# We do so early, so that a `start' beyond the data is rejected at
# once rather than after searching for it.
pos:=PositionProperty(SIMPLEGPSNONL2,x->x[1]>=start);
if pos=fail then
LOADSIMPLE2();
pos:=PositionProperty(SIMPLEGPSNONL2,x->x[1]>=start);
if pos=fail then
Error("simple groups of order > ",SIMPLE_GROUPS_ITERATOR_RANGE,
" are not available");
fi;
fi;

# find relevant L2 order
a:=RootInt(start,3)-1;
stack:=fail;
Expand All @@ -796,8 +809,6 @@ InstallGlobalFunction(SimpleGroupsIterator,function(arg)
stack:=a[3];
a:=a[2];
until SizeL2Q(b)>=start;
if start>=10^18 then LOADSIMPLE2(); fi;
pos:=First([1..Length(SIMPLEGPSNONL2)],x->SIMPLEGPSNONL2[x][1]>=start);
return IteratorByFunctions(rec(
IsDoneIterator:=IsDoneIterator_SimGp,
NextIterator:=NextIterator_SimGp,
Expand Down
17 changes: 17 additions & 0 deletions tst/testbugfix/2026-08-15-SimpleGroupsIterator.tst
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# The orders of the non-PSL(2,q) simple groups come in two lists, the second
# loaded on demand. `SimpleGroupsIterator' asked for it when `start' reached
# 10^18, but the first list ends at 911215823217986880; in between nothing was
# loaded, `pos' stayed `fail', and building the iterator broke on indexing the
# list with it.
gap> it := SimpleGroupsIterator(10^18-1, 10^18-1);;
gap> IsDoneIterator(it);
true
gap> it := SimpleGroupsIterator(10^18-1, 11*10^17 : NOPSL2);;
gap> l := [];; for g in it do Add(l, g); od;
gap> List(l, Size);
[ 1053927211015007280 ]

# An order beyond the data is rejected when the iterator is built, before the
# search for the PSL(2,q) order to start from.
gap> SimpleGroupsIterator(10^28, 10^28);
Error, simple groups of order > 1000000000000000000000000000 are not available
Loading