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

Collection of minor improvements #618

Merged
merged 8 commits into from
Feb 17, 2016
36 changes: 20 additions & 16 deletions lib/factgrp.gi
Original file line number Diff line number Diff line change
Expand Up @@ -715,28 +715,32 @@ end;
InstallGlobalFunction(SmallerDegreePermutationRepresentation,function(G)
local o, s, k, gut, erg, H, hom, b, ihom, improve, map, loop,
i,cheap,first;
#if not HasSize(G) then Error("SZ");fi;
Info(InfoFactor,1,"Smaller degree for order ",Size(G),", deg: ",NrMovedPoints(G));
cheap:=ValueOption("cheap");
if cheap="skip" then
return IdentityMapping(G);
fi;

cheap:=cheap=true;

# deal with large abelian cases first (which could be direct)
hom:=MaximalAbelianQuotient(G);
i:=IndependentGeneratorsOfAbelianGroup(Image(hom));
o:=List(i,Order);
if ValueOption("norecurse")<>true and
Product(o)>20 and Sum(o)*4<NrMovedPoints(G) then
Info(InfoFactor,2,"append abelian rep");
s:=AbelianGroup(IsPermGroup,o);
ihom:=GroupHomomorphismByImagesNC(Image(hom),s,i,GeneratorsOfGroup(s));
erg:=SubdirectDiagonalPerms(
List(GeneratorsOfGroup(G),x->Image(ihom,Image(hom,x))),
GeneratorsOfGroup(G));
k:=Group(erg);SetSize(k,Size(G));
hom:=GroupHomomorphismByImagesNC(G,k,GeneratorsOfGroup(G),erg);
return hom*SmallerDegreePermutationRepresentation(k:norecurse);
# deal with large abelian components first (which could be direct)
if cheap<>true then
hom:=MaximalAbelianQuotient(G);
i:=IndependentGeneratorsOfAbelianGroup(Image(hom));
o:=List(i,Order);
if ValueOption("norecurse")<>true and
Product(o)>20 and Sum(o)*4<NrMovedPoints(G) then
Info(InfoFactor,2,"append abelian rep");
s:=AbelianGroup(IsPermGroup,o);
ihom:=GroupHomomorphismByImagesNC(Image(hom),s,i,GeneratorsOfGroup(s));
erg:=SubdirectDiagonalPerms(
List(GeneratorsOfGroup(G),x->Image(ihom,Image(hom,x))),
GeneratorsOfGroup(G));
k:=Group(erg);SetSize(k,Size(G));
hom:=GroupHomomorphismByImagesNC(G,k,GeneratorsOfGroup(G),erg);
return hom*SmallerDegreePermutationRepresentation(k:norecurse);
fi;
fi;


Expand Down Expand Up @@ -779,7 +783,7 @@ local o, s, k, gut, erg, H, hom, b, ihom, improve, map, loop,
fi;
return IdentityMapping(G);
# simple test is comparatively cheap for permgrp
elif IsSimpleGroup(G) and not IsAbelian(G) then
elif HasIsSimpleGroup(G) and IsSimpleGroup(G) and not IsAbelian(G) then
H:=SimpleGroup(ClassicalIsomorphismTypeFiniteSimpleGroup(G));
if IsPermGroup(H) and NrMovedPoints(H)>=NrMovedPoints(G) then
return IdentityMapping(G);
Expand Down
6 changes: 6 additions & 0 deletions lib/ghomfp.gi
Original file line number Diff line number Diff line change
Expand Up @@ -1032,12 +1032,17 @@ local m,s,g,i,j,rel,gen,img,fin,hom,gens;
SetAbelianInvariants(f,AbelianInvariantsOfList(DiagonalOfMat(s.normal)));

if Length(m[1])>s.rank then
img:=[];
for i in [1..s.rank] do
Add(img,s.normal[i][i]);
Add(rel,g.(i)^s.normal[i][i]);
od;
Append(img,ListWithIdenticalEntries(Length(gen)-s.rank,0));
SetAbelianInvariants(f,img);
g:=g/rel;
fin:=false;
else
SetAbelianInvariants(f,DiagonalOfMat(s.normal));
g:=AbelianGroup(DiagonalOfMat(s.normal));
fin:=true;
fi;
Expand All @@ -1056,6 +1061,7 @@ local m,s,g,i,j,rel,gen,img,fin,hom,gens;
g:=g/rel;
fin:=Length(gen)=0;
img:=GeneratorsOfGroup(g);
SetAbelianInvariants(f,ListWithIdenticalEntries(Length(gen),0));
fi;

SetIsFinite(g,fin);
Expand Down
35 changes: 35 additions & 0 deletions lib/gprdmat.gi
Original file line number Diff line number Diff line change
Expand Up @@ -413,3 +413,38 @@ local info,proj,H;
return proj;
end);

# tensor wreath -- dimension d^e This is not a faithful representation of
# the tensor product if the matrix group has a center.
DeclareGlobalFunction("TensorWreathProduct");

InstallGlobalFunction(TensorWreathProduct,function(M,P)
local d,e,f,s,dim,gens,mimgs,pimgs,tup,act,a,g,i;
d:=Length(One(M));
f:=DefaultFieldOfMatrixGroup(M);
e:=LargestMovedPoint(P);
s:=SymmetricGroup(e);
dim:=d^e;
gens:=[];
mimgs:=[];
for g in GeneratorsOfGroup(M) do
a:=NullMat(dim,dim,f);
for i in [1..dim/d] do
tup:=[1..d]+(i-1)*d;
a{tup}{tup}:=g;
od;
a:=ImmutableMatrix(f,a);
Add(gens,a);
Add(mimgs,a);
od;
tup:=List(Tuples([1..d],e),Reversed); # reverse to be consistent with Magma
act:=ActionHomomorphism(s,tup,Permuted,"surjective");
pimgs:=[];
for g in GeneratorsOfGroup(P) do
a:=PermutationMat(Image(act,g),dim,f);
a:=ImmutableMatrix(f,a);
Add(gens,a);
Add(pimgs,a);
od;
return Group(gens);
end);

3 changes: 3 additions & 0 deletions lib/groebner.gd
Original file line number Diff line number Diff line change
Expand Up @@ -485,6 +485,8 @@ DeclareOperation("GroebnerBasis",
DeclareOperation("GroebnerBasis",[IsPolynomialRingIdeal,IsMonomialOrdering]);
DeclareGlobalFunction("GroebnerBasisNC");

DeclareSynonym("GrobnerBasis",GroebnerBasis);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lib/helpbase.gi defines global variable TRANSATL which is currently

            [ [ "atalogue", "atalog" ],
              [ "olour", "olor" ],
              [ "entre", "enter" ],
              [ "isation", "ization" ],
              [ "ise", "ize" ],
              [ "abeling", "abelling" ],
              [ "olvable", "oluble" ],
              [ "yse", "yze" ] ] );

Do we want to add ["Groebner","Grobner"] pair there so the search ??Grobner will return all entries with Groebner? The only thing that stops me is that I do not know whether this spelling (or misspelling) is relevant to the Atlantic ocean...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If that would not be considered as a gratuitous abouse of the language feature, I'd be happy to do so.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maxima uses Groebner in the text in the manual, but grobner as a name of the package and some functions that it provides, so perhaps this makes sense.


#############################################################################
##
#O ReducedGroebnerBasis( <L>, <O> )
Expand Down Expand Up @@ -533,6 +535,7 @@ DeclareOperation("ReducedGroebnerBasis",
[IsHomogeneousList and IsRationalFunctionCollection,IsMonomialOrdering]);
DeclareOperation("ReducedGroebnerBasis",
[IsPolynomialRingIdeal,IsMonomialOrdering]);
DeclareSynonym("ReducedGrobnerBasis",ReducedGroebnerBasis);

#############################################################################
##
Expand Down
8 changes: 7 additions & 1 deletion lib/grp.gi
Original file line number Diff line number Diff line change
Expand Up @@ -781,7 +781,13 @@ InstallMethod( DerivedSeriesOfGroup,
S := [ G ];
Info( InfoGroup, 2, "DerivedSeriesOfGroup: step ", Length(S) );
D := DerivedSubgroup( G );
while D <> S[ Length(S) ] do

while
# we don't know that the group has no generators
(not HasGeneratorsOfGroup(S[Length(S)]) or
Length(GeneratorsOfGroup(S[Length(S)]))>0) and
( (not HasAbelianInvariants(S[Length(S)]) and D <> S[ Length(S) ]) or
Length(AbelianInvariants(S[Length(S)]))>0) do
Add( S, D );
Info( InfoGroup, 2, "DerivedSeriesOfGroup: step ", Length(S) );
D := DerivedSubgroup( D );
Expand Down
9 changes: 8 additions & 1 deletion lib/grpfp.gi
Original file line number Diff line number Diff line change
Expand Up @@ -937,7 +937,14 @@ function(G)
local iso,hom,u;
iso:=IsomorphismFpGroup(G);
hom:=MaximalAbelianQuotient(Range(iso));
if Size(Range(hom))=1 then
if HasAbelianInvariants(Range(iso)) then
SetAbelianInvariants(G,AbelianInvariants(Range(iso)));
fi;
if HasIsAbelian(G) and IsAbelian(G) then
return TrivialSubgroup(G);
elif Size(Image(hom))=infinity then
Error("Derived subgroup has infinite index, cannot represent");
elif Size(Range(hom))=1 then
return G; # this is needed because the trivial quotient is represented
# as fp group on no generators
fi;
Expand Down
3 changes: 2 additions & 1 deletion lib/helpbase.gi
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,8 @@ BindGlobal( "TRANSATL",
[ "ise", "ize" ],
[ "abeling", "abelling" ],
[ "olvable", "oluble" ],
[ "yse", "yze" ] ] );
[ "yse", "yze" ],
[ "roebner", "robner"]] );


#############################################################################
Expand Down
14 changes: 14 additions & 0 deletions lib/matobjplist.gi
Original file line number Diff line number Diff line change
Expand Up @@ -1172,6 +1172,20 @@ InstallMethod( CopySubMatrix, "for two plist matrices and four lists",
od;
end );

InstallOtherMethod( CopySubMatrix,
"for two plists -- fallback in case of bad rep.",
[ IsPlistRep, IsPlistRep and IsMutable,
IsList, IsList, IsList, IsList ],
function( m, n, srcrows, dstrows, srccols, dstcols )
local i;
# in this representation all access probably has to go through the
# generic method selection, so it is not clear whether there is an
# improvement in moving this into the kernel.
for i in [1..Length(srcrows)] do
n[dstrows[i]]{dstcols}:=m[srcrows[i]]{srccols};
od;
end );

InstallMethod( CopySubMatrix,
"for a plist matrix and a checking plist matrix and four lists",
[ IsPlistMatrixRep,
Expand Down
4 changes: 3 additions & 1 deletion lib/oprt.gd
Original file line number Diff line number Diff line change
Expand Up @@ -898,7 +898,9 @@ end );
## <Description>
## computes a homomorphism from <A>G</A> into the symmetric group on
## <M>|<A>Omega</A>|</M> points that gives the permutation action of
## <A>G</A> on <A>Omega</A>.
## <A>G</A> on <A>Omega</A>. (In particular, this homomorphism is a
## permutation equivalence, that is the permutation image of a group element
## is given by the positions of points in <A>Omega</A>.)
## <P/>
## By default the homomorphism returned by
## <Ref Func="ActionHomomorphism" Label="for a group, an action domain, etc."/>
Expand Down
1 change: 1 addition & 0 deletions lib/pcgs.gi
Original file line number Diff line number Diff line change
Expand Up @@ -1623,6 +1623,7 @@ local G,e,ind,s,m,i,p;
if not IsSolvableGroup(G) then
Error("<G> must be solvable");
fi;
IsFinite(G); # trigger finiteness test
e:=ElementaryAbelianSeriesLargeSteps(param);
ind:=[];
s:=[];
Expand Down
53 changes: 45 additions & 8 deletions lib/wordrep.gi
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,32 @@ end );
# code for printing words in factored form. This pattern searching clearly
# is improvable
BindGlobal("FindSubstringPowers",function(l,n)
local new,t,i,step,lstep,z,zz,j,a,k,good,bad,lim;
local new,t,i,step,lstep,z,zz,j,a,k,good,bad,lim,plim;
new:=0;
t:=[];
z:=Length(l);
# first deal with large powers to avoid x^1000 being an obstacle.
plim:=9; # length for treating large powers-1
j:=1;
while j+plim<=Length(l) do
if ForAll([1..plim],x->l[j]=l[j+x]) then
k:=j+plim;
while k<Length(l) and l[j]=l[k+1] do
k:=k+1;
od;
zz:=[0,l[j],k-j+1];
a:=Position(t,zz);
if a=fail then
new:=new+1;
t[new]:=zz;
a:=new;
fi;
l:=Concatenation(l{[1..j-1]},[a+n],l{[k+1..Length(l)]});
fi;
j:=j+1;
od;
z:=Length(l);

# long matches first, we then treat the subpatterns themselves again
j:=QuoInt(z,2);
lstep:=j;
Expand Down Expand Up @@ -186,8 +208,8 @@ end);
# threshold up to which to try.
PRINTWORDPOWERS:=true;

DoNSAW:=function(l,names)
local a,n,
DoNSAW:=function(l,names,tseed)
local a,n,t,
word,
exp,
i,j,
Expand All @@ -204,6 +226,7 @@ local a,n,
a:=[l,[]];
fi;
word:=a[1];
a[2]:=Concatenation(tseed,a[2]);

i:= 1;
str:= "";
Expand All @@ -213,10 +236,24 @@ local a,n,
fi;
exp:=1;
if word[i]>n then
# decode longer word -- it will occur as power, so use ()
Add(str,'(');
Append(str,DoNSAW(a[2][word[i]-n],names));
Add(str,')');
t:=a[2][word[i]-n];
# is it a power stored specially?
if t[1]=0 then
if t[2]<0 then
Append( str, names[ -t[2] ] );
Append( str, "^-" );
Append( str, String(t[3]));
else
Append( str, names[ t[2] ] );
Append( str, "^" );
Append( str, String(t[3]));
fi;
else
# decode longer word -- it will occur as power, so use ()
Add(str,'(');
Append(str,DoNSAW(t,names,Filtered(a[2],x->x[1]=0)));
Add(str,')');
fi;
elif word[i]<0 then
Append( str, names[ -word[i] ] );
exp:=-1;
Expand Down Expand Up @@ -251,7 +288,7 @@ local names,word;
if Length(word)=0 then
return "<identity ...>";
fi;
word:=DoNSAW(word,names);
word:=DoNSAW(word,names,[]);
return word;
end);

Expand Down