Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Constructors #611

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
13 changes: 12 additions & 1 deletion doc/ref/methsel.xml
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,18 @@ Note that in both these cases there are methods that actually produce results
of the required types, but they have not been installed with this information,
so are not selected.

<Example>
gap> XCons(IsRegularSemigroup,4);
&lt;pc group of size 4 with 2 generators&gt;
</Example>

Finally note the possibly unexpected behaviour in this example. Since
all groups are regular semigroups, the cyclic group constructor is
applicable.

The exact details of method ranking for constructors are under review
at this time and may be changed, so do not rely on them.

<#Include Label="NewConstructor">
<#Include Label="DeclareConstructor">

Expand Down Expand Up @@ -336,7 +348,6 @@ one can install also <E>immediate methods</E>.

</Section>


<!-- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -->
<Section Label="Operations and Mathematical Terms">
<Heading>Operations and Mathematical Terms</Heading>
Expand Down
2 changes: 2 additions & 0 deletions grp/basic.gd
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ end );
## </ManSection>
##
DeclareConstructor( "AlternatingGroupCons", [ IsGroup, IsInt ] );
DeclareConstructor( "AlternatingGroupCons", [ IsGroup, IsDenseList ] );


#############################################################################
Expand Down Expand Up @@ -693,6 +694,7 @@ end );
## </ManSection>
##
DeclareConstructor( "SymmetricGroupCons", [ IsGroup, IsInt ] );
DeclareConstructor( "SymmetricGroupCons", [ IsGroup, IsDenseList ] );


#############################################################################
Expand Down
4 changes: 2 additions & 2 deletions grp/basicpcg.gi
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ function( filter, deg )
local alt;

if 4 < deg then
Error( "<deg> must be at most 4" );
TryNextMethod();
fi;
alt := GroupByPcgs(Pcgs(AlternatingGroupCons(IsPermGroup,[1..deg])));
SetIsAlternatingGroup( alt, true );
Expand Down Expand Up @@ -396,7 +396,7 @@ InstallMethod( SymmetricGroupCons,

function( filter, deg )
if 4 < deg then
Error( "<deg> must be at most 4" );
TryNextMethod();
fi;
return GroupByPcgs(Pcgs(SymmetricGroupCons(IsPermGroup,[1..deg])));
end );
59 changes: 44 additions & 15 deletions grp/basicprm.gi
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ end);
InstallMethod( AlternatingGroupCons,
"perm group with degree",
true,
[ IsPermGroup and IsFinite,
[ IsNaturalAlternatingGroup and IsPermGroup and IsFinite,
IsInt],
0,

Expand All @@ -97,18 +97,28 @@ end );
##
#M AlternatingGroupCons( <IsPermGroup>, <dom> )
##
InstallOtherMethod( AlternatingGroupCons,

BindGlobal("ALTERNATING_GROUP_CACHE",[]);


InstallMethod( AlternatingGroupCons,
"perm group with domain",
true,
[ IsPermGroup and IsFinite,
[ IsPermGroup and IsNaturalAlternatingGroup and IsFinite,
IsDenseList ],
0,

function( filter, dom )
local alt, dl, g, l;
local alt, dl, g, l, cachable;

dom := Set(dom);
IsRange( dom );
cachable := -1;
if IsRange( dom ) and dom[1] = 1 and (Length(dom) = 1 or dom[2] = 2) then
cachable := Length(dom);
if IsBound(ALTERNATING_GROUP_CACHE[cachable]) then
return ALTERNATING_GROUP_CACHE[cachable];
fi;
fi;
if Length(dom) < 3 then
alt := GroupByGenerators( [], () );
SetSize( alt, 1 );
Expand Down Expand Up @@ -143,6 +153,10 @@ function( filter, dom )
fi;
SetIsAlternatingGroup( alt, true );
SetIsNaturalAlternatingGroup( alt, true );
if cachable > -1 then
ALTERNATING_GROUP_CACHE[cachable] := alt;
fi;

return alt;
end );

Expand All @@ -155,7 +169,7 @@ InstallMethod( AlternatingGroupCons,
true,
[ IsPermGroup and IsRegular and IsFinite,
IsInt],
0,
-RankFilter(IsRegular)-1,

function( filter, deg )
if deg<0 then TryNextMethod();fi;
Expand All @@ -173,12 +187,12 @@ InstallOtherMethod( AlternatingGroupCons,
true,
[ IsPermGroup and IsRegular and IsFinite,
IsDenseList ],
0,
-RankFilter(IsRegular)-1,

function( filter, dom )
local alt;

alt := AlternatingGroupCons( IsPermGroup, dom );
alt := AlternatingGroupCons( IsNaturalAlternatingGroup, dom );
alt := Action( alt, AsList(alt), OnRight );
SetIsAlternatingGroup( alt, true );
return alt;
Expand Down Expand Up @@ -359,26 +373,37 @@ InstallMethod( SymmetricGroupCons,

function( filter, deg )
if deg<0 then TryNextMethod();fi;
return SymmetricGroupCons( IsPermGroup, [ 1 .. deg ] );
return SymmetricGroupCons( IsPermGroup and IsNaturalSymmetricGroup, [ 1 .. deg ] );
end );


#############################################################################
##
#M SymmetricGroupCons( <IsPermGroup>, <dom> )
##

BindGlobal("SYMMETRIC_GROUP_CACHE", []);


InstallOtherMethod( SymmetricGroupCons,
"perm group with domain",
true,
[ IsPermGroup and IsFinite,
[ IsPermGroup and IsFinite and IsNaturalSymmetricGroup,
IsDenseList ],
0,

function( filters, dom )
local sym, g;
local cachable, sym, g;

dom := Set(dom);
IsRange( dom );
cachable := -1;
if IsRange( dom ) and dom[1] = 1 and (Length(dom) = 1 or dom[2] = 2) then
cachable := Length(dom);
if IsBound(SYMMETRIC_GROUP_CACHE[cachable]) then
return SYMMETRIC_GROUP_CACHE[cachable];
fi;
fi;

if Length(dom) < 2 then
sym := GroupByGenerators( [], () );
SetSize( sym, 1 );
Expand All @@ -402,6 +427,9 @@ function( filters, dom )
SetIsPrimitiveAffine( sym, Length( dom ) < 5 );
SetIsSymmetricGroup( sym, true );
SetIsNaturalSymmetricGroup( sym, true );
if cachable > -1 then
SYMMETRIC_GROUP_CACHE[cachable] := sym;
fi;
return sym;
end );

Expand All @@ -415,7 +443,7 @@ InstallMethod( SymmetricGroupCons,
true,
[ IsPermGroup and IsRegular and IsFinite,
IsInt],
0,
-RankFilter(IsRegular)-1,

function( filter, deg )
if deg<0 then TryNextMethod();fi;
Expand All @@ -433,12 +461,13 @@ InstallOtherMethod( SymmetricGroupCons,
true,
[ IsPermGroup and IsRegular and IsFinite,
IsDenseList ],
0,
-RankFilter(IsRegular)-1,


function( filter, dom )
local alt;

alt := SymmetricGroupCons( IsPermGroup, dom );
alt := SymmetricGroupCons( IsPermGroup and IsNaturalSymmetricGroup, dom );
alt := Action( alt, AsList(alt), OnRight );
SetIsSymmetricGroup( alt, true );
return alt;
Expand Down
5 changes: 5 additions & 0 deletions lib/oper1.g
Original file line number Diff line number Diff line change
Expand Up @@ -469,6 +469,11 @@ BIND_GLOBAL( "INSTALL_METHOD",
ADD_LIST( flags, FLAGS_FILTER( i ) );
od;

# Deal with constructors
if IS_CONSTRUCTOR( opr ) then
flags[1] := WITH_IMPS_FLAGS( flags[1] );
fi;

# Check the rank.
if not IsBound( arglist[ pos ] ) then
Error( "the method is missing in <arglist>" );
Expand Down
Loading