Skip to content

Commit

Permalink
fix AbelianGroup w.r.t. generators of order 1
Browse files Browse the repository at this point in the history
- support `AbelianGroup( IsPermGroup, [] )` and `AbelianGroup( IsFpGroup, [] )`
- changed the output of `AbelianGroup( IsPcGroup, ints )` such that also
  generators of order 1 appear
  • Loading branch information
ThomasBreuer authored and fingolfin committed Apr 5, 2023
1 parent 9d6fe77 commit 47f077b
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 3 deletions.
2 changes: 1 addition & 1 deletion grp/basicfp.gi
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ InstallMethod( AbelianGroupCons, "fp group", true,
function( filter, ints )
local f,g,i,j,rels,gfam,fam;

if Length(ints)=0 or not ForAll( ints, x -> IsInfinity(x) or (IsInt(x) and x >= 0) ) then
if not ForAll( ints, x -> IsInfinity(x) or (IsInt(x) and x >= 0) ) then
Error( "<ints> must be a list of integers" );
fi;

Expand Down
7 changes: 6 additions & 1 deletion grp/basicpcg.gi
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,12 @@ local pis, f, g, r, k, pi, i, geni, j, name, ps;
fi;
if ForAll(ints,i->i=1) then
# the stupid trivial group case
return CyclicGroup( IsPcGroup, 1 );
g:= CyclicGroup( IsPcGroup, 1 );
if Length( ints ) > 0 then
g:= GroupWithGenerators(
ListWithIdenticalEntries( Length( ints ), One( g ) ) );
fi;
return g;
fi;

pis := List( ints, Factors );
Expand Down
6 changes: 5 additions & 1 deletion grp/basicprm.gi
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ InstallMethod( AbelianGroupCons,
function( filter, ints )
local grp, grps;

if IsEmpty( ints ) then
# Create a group with empty list of generators
return GroupWithGenerators( [], () );
fi;
if not ForAll( ints, IsInt ) then
Error( "<ints> must be a list of integers" );
fi;
Expand All @@ -48,7 +52,7 @@ function( filter, ints )

grps := List( ints, x -> CyclicGroupCons( IsPermGroup, x ) );
# the way a direct product is constructed guarantees the right
# generators
# generators (also generators of order 1)
grp := CallFuncList( DirectProduct, grps );
SetSize( grp, Product(ints) );
SetIsAbelian( grp, true );
Expand Down
11 changes: 11 additions & 0 deletions tst/testinstall/grp/basic.tst
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,17 @@ f1
gap> A.2^-1;
f2^2
#
gap> inputs:= [ [], [ 1 ], [ 2, 3, 4 ], [ 1, 2, 1, 3, 1 ] ];;
gap> for ints in inputs do
> for filt in [ IsPcGroup, IsPermGroup, IsFpGroup ] do
> G:= AbelianGroup( ints );
> if List( GeneratorsOfGroup( G ), Order ) <> ints then
> Error( "orders of the generators do not fit" );
> fi;
> od;
> od;
#
gap> AbelianGroup([2,0]);
<fp group of size infinity on the generators [ f1, f2 ]>
Expand Down

0 comments on commit 47f077b

Please sign in to comment.