Skip to content

Commit

Permalink
Tweak Dihedral/GeneralisedQuaternion recognition
Browse files Browse the repository at this point in the history
  • Loading branch information
markuspf authored and Markus Pfeiffer committed Sep 4, 2018
1 parent a3a0471 commit f4605ad
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 27 deletions.
15 changes: 7 additions & 8 deletions grp/basic.gd
Original file line number Diff line number Diff line change
Expand Up @@ -392,21 +392,20 @@ function(args, quaternion)
local size;

if Length(args) = 1 then
res := [ IsPcGroup, args[1] ];
args := [ IsPcGroup, args[1] ];
elif Length(args) = 2 then
res := args;
# 2 inputs are valid, but we just reuse args
# args := args;
elif Length(args) = 3 then
res := args;

if not IsField(res[2]) then
if not IsField(args[2]) then
ErrorNoReturn("usage: <field> must be a field");
fi;
else
ErrorNoReturn("usage: DicyclicGroup( [<filter>, [<field>, ] ] <size> )");
fi;

size := res[Length(res)];
if not IsFilter(res[1]) then
size := args[Length(args)];
if not IsFilter(args[1]) then
ErrorNoReturn("usage: <filter> must be a filter");
fi;

Expand All @@ -428,7 +427,7 @@ function(args, quaternion)
fi;
fi;

return res;
return args;
end);

BindGlobal( "DicyclicGroup",
Expand Down
5 changes: 4 additions & 1 deletion lib/grpnames.gd
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,8 @@ DeclareProperty( "IsDihedralGroup", IsGroup );
DeclareAttribute( "DihedralGenerators", IsGroup );

InstallTrueMethod( IsGroup, IsDihedralGroup );
InstallTrueMethod( IsDihedralGroup, HasDihedralGenerators );


#############################################################################
##
Expand Down Expand Up @@ -484,8 +486,9 @@ DeclareAttribute( "GeneralisedQuaternionGenerators", IsGroup );
DeclareSynonymAttr( "IsQuaternionGroup", IsGeneralisedQuaternionGroup );
DeclareSynonymAttr( "QuaternionGenerators", GeneralisedQuaternionGenerators );


InstallTrueMethod( IsGroup, IsQuaternionGroup );
InstallTrueMethod( IsGeneralisedQuaternionGroup, HasGeneralisedQuaternionGenerators );


#############################################################################
##
Expand Down
28 changes: 12 additions & 16 deletions lib/grpnames.gi
Original file line number Diff line number Diff line change
Expand Up @@ -994,13 +994,11 @@ InstallMethod( IsDihedralGroup,
function(G)
local gens;

if not HasDihedralGenerators(G) then
gens := DoComputeDihedralGenerators(G);
if gens = fail then
return false;
else
SetDihedralGenerators(G, gens);
fi;
gens := DoComputeDihedralGenerators(G);
if gens = fail then
return false;
else
SetDihedralGenerators(G, gens);
fi;
return true;
end);
Expand All @@ -1012,10 +1010,10 @@ function(G)
local gens;

gens := DoComputeDihedralGenerators(G);
SetIsDihedralGroup(G, gens <> fail);
if gens = fail then
ErrorNoReturn("G is not a dihedral group");
fi;
SetIsDihedralGroup(G, true);
return gens;
end);

Expand Down Expand Up @@ -1072,13 +1070,11 @@ InstallMethod( IsGeneralisedQuaternionGroup,
function(G)
local gens;

if not HasGeneralisedQuaternionGenerators(G) then
gens := DoComputeGeneralisedQuaternionGenerators(G);
if gens = fail then
return false;
else
SetGeneralisedQuaternionGenerators(G, gens);
fi;
gens := DoComputeGeneralisedQuaternionGenerators(G);
if gens = fail then
return false;
else
SetGeneralisedQuaternionGenerators(G, gens);
fi;
return true;
end);
Expand All @@ -1090,10 +1086,10 @@ function(G)
local gens;

gens := DoComputeGeneralisedQuaternionGenerators(G);
SetIsGeneralisedQuaternionGroup(G, gens <> fail);
if gens = fail then
ErrorNoReturn("G is not a generalised quaternion group");
fi;
SetIsGeneralisedQuaternionGroup(G, true);
return gens;
end);
#############################################################################
Expand Down
4 changes: 2 additions & 2 deletions tst/testinstall/grp/basic.tst
Original file line number Diff line number Diff line change
Expand Up @@ -303,12 +303,12 @@ Error, usage: <size> must be a positive integer divisible by 4
# (generalised) quaternion groups
#
gap> QuaternionGroup(4);
#I Warning: QuaternionGroup called with <size> 4 which is less than 8, or not a power of 2.
#I Warning: QuaternionGroup called with <size> 4 which is less than 8
<pc group of size 4 with 2 generators>
gap> QuaternionGroup(8);
<pc group of size 8 with 3 generators>
gap> QuaternionGroup(12);
#I Warning: QuaternionGroup called with <size> 12 which is less than 8, or not a power of 2.
#I Warning: QuaternionGroup called with <size> 12 which is not a power of 2
<pc group of size 12 with 3 generators>
gap> QuaternionGroup(11);
Error, usage: <size> must be a positive integer divisible by 4
Expand Down

0 comments on commit f4605ad

Please sign in to comment.