Skip to content

Commit

Permalink
Change Set(Factors(n)) to PrimeDivisors(n)
Browse files Browse the repository at this point in the history
  • Loading branch information
fingolfin authored and ChrisJefferson committed Jan 20, 2018
1 parent 6e30bd4 commit be0b0ae
Show file tree
Hide file tree
Showing 31 changed files with 85 additions and 86 deletions.
4 changes: 2 additions & 2 deletions benchmark/transgrp/examine4
Original file line number Diff line number Diff line change
Expand Up @@ -2902,7 +2902,7 @@ local b,w,a,fno,cnt,normalsyl,tf,nt,tno,ntno,i,j,k,com,hom,cs,ker,nf;
fno:=PreImage(sys.blockhom,fno); # factor normalizer

# are we effectively working modulo a prime?
normalsyl:=Filtered(Set(Factors(Size(fno))),p->
normalsyl:=Filtered(PrimeDivisors(Size(fno)),p->
(not IsInt(Index(w,b)/p)) and
IsNormal(fno,SylowSubgroup(b,p)) );

Expand Down Expand Up @@ -3559,7 +3559,7 @@ local bls, # block size
else
# see, whether it's worth to use subgroups of minops
p:=List(minops,i->Factors(Size(i)));
c:=Set(Factors(Size(i)));
c:=PrimeDivisors(Size(i));
c:=List(p,i->Filtered(i,j->not j in c));
p:=Minimum(List(c,Product));
if p>1 and bla>5 and bls*bla>23 then
Expand Down
3 changes: 1 addition & 2 deletions doc/ref/intrfc.xml
Original file line number Diff line number Diff line change
Expand Up @@ -335,8 +335,7 @@ operation:
InstallMethod(PrimesDividingSize,"for finite groups",
[IsGroup and IsFinite],
function(G)
if Size(G)=1 then return [];
else return Set(Factors(Size(G)));fi;
return PrimeDivisors(Size(G));
end);
]]></Log>
<P/>
Expand Down
4 changes: 2 additions & 2 deletions grp/simple.gi
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ local brg,str,p,a,param,g,s,small,plus,sets;
SetIsSimpleGroup(g,true);
return g;
elif Length(param)=1 and param[1]>7 and
Set(Factors(param[1]))=[2] and IsOddInt(LogInt(param[1],2)) then
PrimeDivisors(param[1])=[2] and IsOddInt(LogInt(param[1],2)) then
g:=SuzukiGroup(IsPermGroup,param[1]);
SetName(g,Concatenation("Sz(",String(param),")"));
SetIsSimpleGroup(g,true);
Expand All @@ -422,7 +422,7 @@ local brg,str,p,a,param,g,s,small,plus,sets;
fi;
elif str="R" or str="REE" or str="2G" then
if Length(param)=1 and param[1]>26 and
Set(Factors(param[1]))=[3] and IsOddInt(LogInt(param[1],3)) then
PrimeDivisors(param[1])=[3] and IsOddInt(LogInt(param[1],3)) then
g:=ReeGroup(IsMatrixGroup,param[1]);
SetName(g,Concatenation("Ree(",String(param[1]),")"));
SetIsSimpleGroup(g,true);
Expand Down
10 changes: 5 additions & 5 deletions hpcgap/lib/polyconw.gi
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ BindGlobal( "IsConsistentPolynomial", function( pol )
local n, p, ps, x, null, f;
n := DegreeOfLaurentPolynomial(pol);
p := Characteristic(pol);
ps := Set(FactorsInt(n));
ps := PrimeDivisors(n);
x := IndeterminateOfLaurentPolynomial(pol);
null := 0*pol;
f := function(k)
Expand Down Expand Up @@ -187,7 +187,7 @@ end);
## all proper subfields.
BindGlobal("NrCompatiblePolynomials", function(p, n)
local ps, lcm;
ps := Set(Factors(n));
ps := PrimeDivisors(n);
lcm := Lcm(List(ps, r-> p^(n/r)-1));
return (p^n-1)/lcm;
end);
Expand Down Expand Up @@ -320,7 +320,7 @@ InstallGlobalFunction( ConwayPol, function( p, n )
if n > 1 then

# Compute the list of all `n / l' for `l' a prime divisor of `n'
nfacs:= List( Set( Factors( n ) ), d -> n / d );
nfacs:= List( PrimeDivisors( n ), d -> n / d );

if nfacs = [ 1 ] then

Expand All @@ -343,7 +343,7 @@ InstallGlobalFunction( ConwayPol, function( p, n )

quots:= List( nfacs, x -> pp / ( p^x -1 ) );
lencpols:= Length( cpols );
ppmin:= List( Set( Factors( pp ) ), d -> pp/d );
ppmin:= List( PrimeDivisors( pp ), d -> pp/d );

found:= false;
onelist:= [ one ];
Expand Down Expand Up @@ -557,7 +557,7 @@ InstallGlobalFunction( RandomPrimitivePolynomial, function(F, n, varnum...)
FF := AlgebraicExtension(F, pol);
one := One(FF);
zero := Zero(FF);
fac:=List(Set(Factors(Size(FF)-1)), p-> (Size(FF)-1)/p);
fac:=List(PrimeDivisors(Size(FF)-1), p-> (Size(FF)-1)/p);
repeat
a := Random(FF);
until a <> zero and ForAll(fac, d-> a^d <> one);
Expand Down
4 changes: 2 additions & 2 deletions lib/autsr.gi
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ local ff,r,d,ser,u,v,i,j,k,p,bd,e,gens,lhom,M,N,hom,Q,Mim,q,ocr,split,MPcgs,
d:=RefinedSubnormalSeries(d,i);
od;
fi;
for i in Set(Factors(Size(r))) do
for i in PrimeDivisors(Size(r)) do
u:=PCore(r,i);
if Size(u)>1 then
d:=RefinedSubnormalSeries(d,u);
Expand Down Expand Up @@ -288,7 +288,7 @@ local ff,r,d,ser,u,v,i,j,k,p,bd,e,gens,lhom,M,N,hom,Q,Mim,q,ocr,split,MPcgs,
ser:=[TrivialSubgroup(G)];
for i in d{[2..Length(d)]} do
u:=ser[Length(ser)];
for p in Set(Factors(Size(i)/Size(u))) do
for p in PrimeDivisors(Size(i)/Size(u)) do
bd:=PValuation(Size(i)/Size(u),p); # max p-exponent
u:=ClosureSubgroup(u,SylowSubgroup(i,p));
v:=ser[Length(ser)];
Expand Down
2 changes: 1 addition & 1 deletion lib/clas.gi
Original file line number Diff line number Diff line change
Expand Up @@ -725,7 +725,7 @@ InstallGlobalFunction( RationalClassesTry, function( G, classes, elm )
Add( classes, C );

# try the powers of this element that reduce the order
for i in Set(FactorsInt(Order(elm))) do
for i in PrimeDivisors(Order(elm)) do
RationalClassesTry( G, classes, elm ^ i );
od;

Expand Down
20 changes: 10 additions & 10 deletions lib/ctbl.gi
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ InstallGlobalFunction( CompatibleConjugacyClassesDefault,
fi;

# Use power maps.
primes:= Set( Factors( Size( tbl ) ) );
primes:= PrimeDivisors( Size( tbl ) );

# store power maps of the group, in order to identify the class
# of the power only once.
Expand Down Expand Up @@ -1130,7 +1130,7 @@ InstallMethod( AbelianInvariants,

# For all prime divisors $p$ of the size,
# compute the element of maximal $p$ power order.
primes:= Set( FactorsInt( Size( tbl ) ) );
primes:= PrimeDivisors( Size( tbl ) );
max:= List( primes, x -> 1 );
pos:= [];
orders:= OrdersClassRepresentatives( tbl );
Expand Down Expand Up @@ -1618,7 +1618,7 @@ InstallMethod( OrdersClassRepresentatives,

# If these maps do not suffice, compute the missing power maps
# and then try again.
for p in Set( Factors( Size( tbl ) ) ) do
for p in PrimeDivisors( Size( tbl ) ) do
PowerMap( tbl, p );
od;
ord:= ElementOrdersPowerMap( ComputedPowerMaps( tbl ) );
Expand Down Expand Up @@ -2659,7 +2659,7 @@ InstallMethod( ClassRoots,
orders := OrdersClassRepresentatives( tbl );
root := List([1..nccl], x->[]);

for p in Set( Factors( Size( tbl ) ) ) do
for p in PrimeDivisors( Size( tbl ) ) do
pmap:= PowerMap( tbl, p );
for i in [1..nccl] do
if i <> pmap[i] and orders[i] <> orders[pmap[i]] then
Expand Down Expand Up @@ -3495,7 +3495,7 @@ InstallMethod( IsInternallyConsistent,
# If the power maps of all prime divisors of the order are stored,
# check if they are consistent with the representative orders.
if IsBound( orders )
and ForAll( Set( FactorsInt( order ) ), x -> IsBound(powermap[x]) )
and ForAll( PrimeDivisors( order ), x -> IsBound(powermap[x]) )
and orders <> ElementOrdersPowerMap( powermap ) then
Info( InfoWarning, 1,
"IsInternallyConsistent(", tbl, "):\n",
Expand Down Expand Up @@ -3656,7 +3656,7 @@ InstallMethod( IsInternallyConsistent,
# If the power maps of all prime divisors of the order are stored,
# check if they are consistent with the representative orders.
if IsBound( orders )
and ForAll( Set( FactorsInt( order ) ), x -> IsBound(powermap[x]) )
and ForAll( PrimeDivisors( order ), x -> IsBound(powermap[x]) )
and orders <> ElementOrdersPowerMap( powermap ) then
flag:= false;
Info( InfoWarning, 1,
Expand Down Expand Up @@ -3775,7 +3775,7 @@ InstallMethod( IsPSolvableCharacterTableOp,
# \ldots and its size.
nextsize:= Sum( classes{ nsg[i] }, 0 );

facts:= Set( FactorsInt( nextsize / size ) );
facts:= PrimeDivisors( nextsize / size );
if 1 < Length( facts ) and ( p = 0 or p in facts ) then

# The chief factor `nsg[i] / n' is not a prime power,
Expand Down Expand Up @@ -4820,7 +4820,7 @@ BindGlobal( "CharacterTableDisplayDefault", function( tbl, options )
tbl_centralizers:= SizesCentralizers( tbl );
elif centralizers = true then
tbl_centralizers:= SizesCentralizers( tbl );
primes:= Set( FactorsInt( Size( tbl ) ) );
primes:= PrimeDivisors( Size( tbl ) );
cen:= [];
for prime in primes do
cen[ prime ]:= [];
Expand Down Expand Up @@ -5650,7 +5650,7 @@ InstallMethod( CharacterTableFactorGroup,
# Transfer necessary power maps of `tbl' to `F'.
inverse:= ProjectionMap( factorfusion );
maps:= ComputedPowerMaps( F );
for p in Set( Factors( Size( F ) ) ) do
for p in PrimeDivisors( Size( F ) ) do
if not IsBound( maps[p] ) then
maps[p]:= factorfusion{ PowerMap( tbl, p ){ inverse } };
fi;
Expand Down Expand Up @@ -5923,7 +5923,7 @@ InstallOtherMethod( CharacterTableIsoclinic,
invfusion:= InverseMap( factorfusion );

# Adjust the power maps.
for p in Set( Factors( size ) ) do
for p in PrimeDivisors( size ) do

map:= ShallowCopy( PowerMap( tbl, p ) );

Expand Down
4 changes: 2 additions & 2 deletions lib/ctblauto.gi
Original file line number Diff line number Diff line change
Expand Up @@ -596,7 +596,7 @@ InstallMethod( TableAutomorphisms,
nccl:= NrConjugacyClasses( tbl );

# Check whether all generators commute with all power maps.
powermap:= List( Set( Factors( Size( tbl ) ) ),
powermap:= List( PrimeDivisors( Size( tbl ) ),
p -> PowerMap( tbl, p ) );
admissible:= Filtered( gens,
perm -> ForAll( powermap,
Expand Down Expand Up @@ -1011,7 +1011,7 @@ InstallMethod( TransformingPermutationsCharacterTables,
# - If the group orders differ then return `fail'.
# - If irreducibles are stored in the two tables and coincide,
# and if the power maps are known and equal then return the identity.
primes:= Set( Factors( Size( tbl1 ) ) );
primes:= PrimeDivisors( Size( tbl1 ) );
if Size( tbl1 ) <> Size( tbl2 ) then
return fail;
elif HasIrr( tbl1 ) and HasIrr( tbl2 ) and Irr( tbl1 ) = Irr( tbl2 )
Expand Down
2 changes: 1 addition & 1 deletion lib/ctblfuns.gi
Original file line number Diff line number Diff line change
Expand Up @@ -4323,7 +4323,7 @@ InstallGlobalFunction( ReductionToFiniteField, function( value, p )

if k <> 1 then

primes:= Set( Factors( m ) );
primes:= PrimeDivisors( m );
sol:= fail;

while not IsEmpty( primes ) do
Expand Down
4 changes: 2 additions & 2 deletions lib/ctblmono.gi
Original file line number Diff line number Diff line change
Expand Up @@ -1105,7 +1105,7 @@ InstallMethod( TestMonomialQuick,
# This follows from Theorem~(2D) in~\cite{Fon62}.
if IsSolvableGroup( G ) then

pi := Set( FactorsInt( codegree ) );
pi := PrimeDivisors( codegree );
hall := Product( Filtered( FactorsInt( factsize ), x -> x in pi ), 1 );

if factsize / hall = chi[1] then
Expand Down Expand Up @@ -1245,7 +1245,7 @@ InstallOtherMethod( TestMonomialQuick,
test:= rec( isMonomial := true,
comment := "abelian by supersolvable group" );

elif ForAll( Set( FactorsInt( Size( ssr ) ) ),
elif ForAll( PrimeDivisors( Size( ssr ) ),
x -> IsAbelian( SylowSubgroup( ssr, x ) ) ) then

# Sylow abelian by supersolvable groups are monomial.
Expand Down
4 changes: 2 additions & 2 deletions lib/ctblpope.gi
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ InstallGlobalFunction( TestPerm2, function(tbl, char)
od;

# TEST 5:
subfak:= Set(Factors(subord));
subfak:= PrimeDivisors(subord);
for prime in subfak do
if subord mod prime^2 <> 0 then

Expand Down Expand Up @@ -205,7 +205,7 @@ InstallGlobalFunction( TestPerm4, function( tbl, chars )
size:= Size( tbl );
orders:= OrdersClassRepresentatives( tbl );

for p in Set( Factors( Size( tbl ) ) ) do
for p in PrimeDivisors( Size( tbl ) ) do

# Compute the distribution of characters to blocks.
bl:= PrimeBlocks( tbl, p );
Expand Down
4 changes: 2 additions & 2 deletions lib/ctblsymm.gi
Original file line number Diff line number Diff line change
Expand Up @@ -1185,7 +1185,7 @@ InstallGlobalFunction( CharacterTableWreathSymmetric, function( sub, n )
# \ldots, `ComputedPowerMaps', \ldots
tbl.ComputedPowerMaps:= [];
powermap:= tbl.ComputedPowerMaps;
for prime in Set( Factors( tbl.Size ) ) do
for prime in PrimeDivisors( tbl.Size ) do
spm:= PowerMap( sub, prime );
powermap[prime]:= List( [ 1 .. nccl ],
i -> Position(parts, PowerWreath(spm, parts[i], prime)) );
Expand Down Expand Up @@ -1250,7 +1250,7 @@ InstallMethod( Irr,
# Compute and store the power maps.
pow:= ComputedPowerMaps( cG );
fun:= gentbl.powermap[1];
for p in Set( Factors( Size( G ) ) ) do
for p in PrimeDivisors( Size( G ) ) do
if not IsBound( pow[p] ) then
pow[p]:= List( cp, x -> Position( cp, fun( deg, x[2], p ) ) );
fi;
Expand Down
12 changes: 6 additions & 6 deletions lib/cyclotom.gi
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ InstallGlobalFunction( CoeffsCyc, function( z, N )
# and $n / s$, and hence remain in the reduced expression,
# - all primes but the squarefree part of the rest.

factors:= Set( FactorsInt( s ) );
factors:= PrimeDivisors( s );
second:= 1;
for p in factors do
if s mod p <> 0 or ( n / s ) mod p <> 0 then
Expand Down Expand Up @@ -301,7 +301,7 @@ InstallGlobalFunction( CoeffsCyc, function( z, N )
# `E(n)^k' by $ - \sum_{j=1}^{p-1} `E(n*p)^(p*k+j*n)'$.
if quo <> 1 then

for p in Set( FactorsInt( quo ) ) do
for p in PrimeDivisors( quo ) do
if p <> 2 and n mod p <> 0 then
nn := n * p;
quo := quo / p;
Expand Down Expand Up @@ -634,7 +634,7 @@ InstallGlobalFunction( NK, function( n, k, deriv )
od;
elif k in [ 3, 5, 7 ] then # for odd primes
if ( n mod ( k*k ) <> 0 ) and
ForAll( Set( FactorsInt( n ) ), p -> (p-1) mod k <> 0 ) then
ForAll( PrimeDivisors( n ), p -> (p-1) mod k <> 0 ) then
return fail;
fi;
while true do
Expand Down Expand Up @@ -666,7 +666,7 @@ InstallGlobalFunction( NK, function( n, k, deriv )
elif k = 4 then
# An automorphism of order 4 exists if 4 divides $p-1$ for an odd
# prime divisor $p$ of `n', or if 16 divides `n'.
if ForAll( Set( FactorsInt( n ) ), p -> (p-1) mod k <> 0 )
if ForAll( PrimeDivisors( n ), p -> (p-1) mod k <> 0 )
and n mod 16 <> 0 then
return fail;
fi;
Expand All @@ -691,7 +691,7 @@ InstallGlobalFunction( NK, function( n, k, deriv )
# An automorphism of order 6 exists if automorphisms of the orders
# 2 and 3 exist; the former is always true.
if ( n mod 9 <> 0 ) and
ForAll( Set( FactorsInt( n ) ), p -> (p-1) mod 3 <> 0 ) then
ForAll( PrimeDivisors( n ), p -> (p-1) mod 3 <> 0 ) then
return fail;
fi;
while true do
Expand Down Expand Up @@ -721,7 +721,7 @@ InstallGlobalFunction( NK, function( n, k, deriv )
elif k = 8 then
# An automorphism of order 8 exists if 8 divides $p-1$ for an odd
# prime divisor $p$ of `n', or if 32 divides `n'.
if ForAll( Set( FactorsInt( n ) ), p -> (p-1) mod k <> 0 )
if ForAll( PrimeDivisors( n ), p -> (p-1) mod k <> 0 )
and n mod 32 <> 0 then
return fail;
fi;
Expand Down
6 changes: 3 additions & 3 deletions lib/fitfree.gi
Original file line number Diff line number Diff line change
Expand Up @@ -887,7 +887,7 @@ local o,C;
Append(o,List(Orbits(C,MovedPoints(G)),Length));
fi;
o:=Lcm(o);
if Set(Factors(Size(G)))=Set(Factors(o)) then
if PrimeDivisors(Size(G))=PrimeDivisors(o) then
# all primes in -- useless
return G;
fi;
Expand All @@ -898,7 +898,7 @@ end);
BindGlobal("Halleen",function(arg)
local G,gp,p,r,s,c,i,a,pp,prime,sy,k,b,dc,H,e,j,forbid;
G:=arg[1];
gp:=Set(Factors(Size(G)));
gp:=PrimeDivisors(Size(G));
if Length(arg)>1 then
r:=arg[2];
forbid:=Difference(gp,r);
Expand Down Expand Up @@ -1012,7 +1012,7 @@ local s,d,c,act,o,i,j,h,p,hf,img,n,prd,k,nk,map,ns,all,hl,hcomp,
return [TrivialSubgroup(G)];
elif false and Length(pi)=1 then
return [SylowSubgroup(G,pi[1])];
elif pi=Set(Factors(Size(G))) then
elif pi=PrimeDivisors(Size(G)) then
return [G];
fi;

Expand Down
2 changes: 1 addition & 1 deletion lib/gaussian.gi
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ InstallMethod( Factors,

# loop over all factors of the norm of x
facs := [];
for prm in Set( FactorsInt( EuclideanDegree( GaussianIntegers, x ) ) ) do
for prm in PrimeDivisors( EuclideanDegree( GaussianIntegers, x ) ) do

# $p = 2$ and primes $p = 1$ mod 4 split according to $p = x^2 + y^2$
if prm = 2 or prm mod 4 = 1 then
Expand Down
2 changes: 1 addition & 1 deletion lib/gpprmsya.gi
Original file line number Diff line number Diff line change
Expand Up @@ -1187,7 +1187,7 @@ syll, act, typ, sel, bas, wdom, comp, lperm, other, away, i, j,b0,opg,bp;
Info(InfoGroup,1,"SymmAlt normalizer: orbits ",List(o,Length));

if Length(o)=1 and IsAbelian(u) then
b:=List(Set(Factors(Size(u))),p->Omega(SylowSubgroup(u,p),p,1));
b:=List(PrimeDivisors(Size(u)),p->Omega(SylowSubgroup(u,p),p,1));
if Length(b)=1 and IsTransitive(b[1],dom) then
# elementary abelian, regular -- construct the correct AGL
b:=b[1];
Expand Down
Loading

0 comments on commit be0b0ae

Please sign in to comment.