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

De-duplicate some functions #5657

Merged
merged 9 commits into from
Feb 28, 2024
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 @@
## 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;

Check warning on line 3789 in lib/alglie.gi

View check run for this annotation

Codecov / codecov/patch

lib/alglie.gi#L3789

Added line #L3789 was not covered by tests

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] );

Check warning on line 3800 in lib/alglie.gi

View check run for this annotation

Codecov / codecov/patch

lib/alglie.gi#L3791-L3800

Added lines #L3791 - L3800 were not covered by tests
else
w2:= [ t[2] ];
fi;

Check warning on line 3803 in lib/alglie.gi

View check run for this annotation

Codecov / codecov/patch

lib/alglie.gi#L3802-L3803

Added lines #L3802 - L3803 were not covered by tests

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

Check warning on line 3809 in lib/alglie.gi

View check run for this annotation

Codecov / codecov/patch

lib/alglie.gi#L3805-L3809

Added lines #L3805 - L3809 were not covered by tests
else
return false;
fi;

Check warning on line 3812 in lib/alglie.gi

View check run for this annotation

Codecov / codecov/patch

lib/alglie.gi#L3811-L3812

Added lines #L3811 - L3812 were not covered by tests

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

Check warning on line 3814 in lib/alglie.gi

View check run for this annotation

Codecov / codecov/patch

lib/alglie.gi#L3814

Added line #L3814 was not covered by tests
end);

InstallMethod( NormalizedElementOfMagmaRingModuloRelations,
"for family of free Lie algebra elements, and list",
true,
Expand All @@ -3790,52 +3828,14 @@
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 @@

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,
fingolfin marked this conversation as resolved.
Show resolved Hide resolved
[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;
fingolfin marked this conversation as resolved.
Show resolved Hide resolved
fi;
indstep:=IndicesEANormalSteps(home);

Expand Down
Loading
Loading