Skip to content

Commit

Permalink
De-duplicate some functions (#5657)
Browse files Browse the repository at this point in the history
  • Loading branch information
james-d-mitchell authored Feb 28, 2024
1 parent 93d56cf commit b93b8b7
Show file tree
Hide file tree
Showing 9 changed files with 83 additions and 282 deletions.
28 changes: 0 additions & 28 deletions hpcgap/lib/ffeconway.gi
Original file line number Diff line number Diff line change
Expand Up @@ -1214,34 +1214,6 @@ InstallMethod( LogFFE,
[ IsFFE and IsCoeffsModConwayPolRep, IsFFE and IsInternalRep],
DoDLog );

#############################################################################
##
#M Order -- multiplicative order of an FFE
##


InstallMethod( Order,
[IsFFE],
function(z)
local p, d, ord, facs, f, i, o;
p := Characteristic(z);
d := DegreeFFE(z);
ord := p^d-1;
facs := Collected(Factors(Integers,ord));
for f in facs do
for i in [1..f[2]] do
o := ord/f[1];
if not IsOne(z^o) then
break;
fi;
ord := o;
od;
od;
return ord;
end);



#############################################################################
##
#M LargeGaloisField(p,d) -- construct GFs in this size range
Expand Down
31 changes: 7 additions & 24 deletions lib/algebra.gi
Original file line number Diff line number Diff line change
Expand Up @@ -2843,10 +2843,8 @@ InstallMethod( Basis,
##
#M Basis( <A> ) . . . . . . basis from FLMLOR gens. for associative FLMLOR
##
InstallMethod( Basis,
"for an associative FLMLOR",
[ IsFLMLOR and IsAssociative ],
function( A )
BindGlobal("BasisLieAlgebraAndAssociativeFLMOR",
function( A )
local mb;

# If generators as left module are known
Expand All @@ -2864,8 +2862,11 @@ InstallMethod( Basis,
Zero( A ),
infinity );
return ImmutableBasis( mb, A );

end );
InstallMethod( Basis,
"for an associative FLMLOR",
[ IsFLMLOR and IsAssociative ],
BasisLieAlgebraAndAssociativeFLMOR );


#############################################################################
Expand Down Expand Up @@ -2906,25 +2907,7 @@ InstallMethod( Basis,
InstallMethod( Basis,
"for a Lie algebra",
[ IsLieAlgebra ],
function( A )
local mb;

# If generators as left module are known
# we do not need to multiply at all.
if HasGeneratorsOfLeftModule( A ) then
TryNextMethod();
fi;

mb:= MutableBasisOfClosureUnderAction(
LeftActingDomain( A ),
GeneratorsOfLeftOperatorRing( A ),
"left",
GeneratorsOfLeftOperatorRing( A ),
\*,
Zero( A ),
infinity );
return ImmutableBasis( mb, A );
end );
BasisLieAlgebraAndAssociativeFLMOR );


#############################################################################
Expand Down
118 changes: 40 additions & 78 deletions lib/alglie.gi
Original file line number Diff line number Diff line change
Expand Up @@ -3776,6 +3776,44 @@ end );
## For the algorithm we refer to C. Reutenauer, Free Lie Algebras, Clarendon
## Press, Oxford, 1993.
##
DeclareGlobalName( "IsLyndonT" );

BindGlobal( "IsLyndonT",
function( t )

# This function tests whether the bracketed expression `t' is
# a Lyndon tree.

local w,w1,w2,b,y;

if not IsList( t ) then return true; fi;

w:= Flat( t );
if IsList( t[1] ) then
w1:= Flat( t[1] );
b:= false;
else
w1:= [ t[1] ];
b:=true;
fi;
if IsList( t[2] ) then
w2:= Flat( t[2] );
else
w2:= [ t[2] ];
fi;

if w<w2 and w1<w2 then
if not b then
y:= Flat( [ t[1][2] ] );
if y < w2 then return false; fi;
fi;
else
return false;
fi;

return IsLyndonT(t[1]) and IsLyndonT(t[2]);
end);

InstallMethod( NormalizedElementOfMagmaRingModuloRelations,
"for family of free Lie algebra elements, and list",
true,
Expand All @@ -3790,52 +3828,14 @@ InstallMethod( NormalizedElementOfMagmaRingModuloRelations,
ll, #List
zero, #The zero element of the field
tlist, #List of elements of the free Lie algebra
Dcopy,IsLyndonT; #Two functions
Dcopy; #Two functions

Dcopy:=function( l )

if not IsList(l) then return ShallowCopy( l ); fi;
return List( l, Dcopy );
end;

IsLyndonT:= function( t )

# This function tests whether the bracketed expression `t' is
# a Lyndon tree.

local w,w1,w2,b,y;

if not IsList( t ) then return true; fi;

w:= Flat( t );
if IsList( t[1] ) then
w1:= Flat( t[1] );
b:= false;
else
w1:= [ t[1] ];
b:=true;
fi;
if IsList( t[2] ) then
w2:= Flat( t[2] );
else
w2:= [ t[2] ];
fi;

if w<w2 and w1<w2 then
if not b then
y:= Flat( [ t[1][2] ] );
if y < w2 then return false; fi;
fi;
else
return false;
fi;

if not IsLyndonT( t[1] ) then return false; fi;
if not IsLyndonT( t[2] ) then return false; fi;
return true;

end;

zero:= descr[1];
todo:= [ ];
i:= 1;
Expand Down Expand Up @@ -4038,48 +4038,10 @@ InstallMethod( PreImagesRepresentative,

function( f, x )

local IsLyndonT, dim, e, gens, imgs, b1, b2, levs,
local dim, e, gens, imgs, b1, b2, levs,
brackets, sp, deg, newlev, newbracks, d, br1, br2,
i, j, a, b, c, z, imz, cf;

IsLyndonT:= function( t )

# This function tests whether the bracketed expression `t' is
# a Lyndon tree.

local w,w1,w2,b,y;

if not IsList( t ) then return true; fi;

w:= Flat( t );
if IsList( t[1] ) then
w1:= Flat( t[1] );
b:= false;
else
w1:= [ t[1] ];
b:=true;
fi;
if IsList( t[2] ) then
w2:= Flat( t[2] );
else
w2:= [ t[2] ];
fi;

if w<w2 and w1<w2 then
if not b then
y:= Flat( [ t[1][2] ] );
if y < w2 then return false; fi;
fi;
else
return false;
fi;

if not IsLyndonT( t[1] ) then return false; fi;
if not IsLyndonT( t[2] ) then return false; fi;
return true;

end;

if not IsBound( f!.bases ) then

# We find bases of the source and the range that are mapped to
Expand Down
27 changes: 0 additions & 27 deletions lib/ffeconway.gi
Original file line number Diff line number Diff line change
Expand Up @@ -1184,33 +1184,6 @@ InstallMethod( LogFFE,
[ IsFFE and IsCoeffsModConwayPolRep, IsFFE and IsInternalRep],
DoDLog );

#############################################################################
##
#M Order -- multiplicative order of an FFE
##


InstallMethod( Order,
[IsFFE],
function(z)
local p, d, ord, facs, f, i, o;
p := Characteristic(z);
d := DegreeFFE(z);
ord := p^d-1;
facs := Collected(Factors(Integers,ord));
for f in facs do
for i in [1..f[2]] do
o := ord/f[1];
if not IsOne(z^o) then
break;
fi;
ord := o;
od;
od;
return ord;
end);



#############################################################################
##
Expand Down
13 changes: 1 addition & 12 deletions lib/grppc.gi
Original file line number Diff line number Diff line change
Expand Up @@ -1491,18 +1491,7 @@ local G, # common parent
if eas=fail then
home:=PcgsElementaryAbelianSeries([G,NT]);
eas:=EANormalSeriesByPcgs(home);
cent:=function(pcgs,grpg,Npcgs,dep)
local i,j;
for i in grpg do
for j in Npcgs do
if DepthOfPcElement(pcgs,Comm(j,i))<dep then
return false;
fi;
od;
od;
return true;
end;

cent:=PcClassFactorCentralityTest;
fi;
indstep:=IndicesEANormalSteps(home);

Expand Down
Loading

0 comments on commit b93b8b7

Please sign in to comment.