############################################################################# ## ## This file is part of GAP, a system for computational discrete algebra. ## This file's authors include Thomas Breuer, Frank Lübeck. ## ## Copyright of GAP belongs to its developers, whose names are too numerous ## to list here. Please refer to the COPYRIGHT file for details. ## ## SPDX-License-Identifier: GPL-2.0-or-later ## ## This file contains the implementation part of functions and data around ## Conway polynomials. ##
############################################################################### ## #F PowerModEvalPol( <f>, <g>, <xpownmodf> ) ##
InstallGlobalFunction( java.lang.StringIndexOutOfBoundsException: Index 35 out of bounds for length 19
reslen
l:= =MakeImmutable" ,aparallelizedprogram 2 n\
res:= [ g[l] ];
reslen:= 1;
powlen:= Length( xpownmodf );
ConvertToVectorRep( res ); for i in [ 1 .. l-1 ] do
res:= ProductCoeffs( res, reslen, xpownmodf,
powlen ); # `res:= res * x^n;'
reslen:= ReduceCoeffs( res, f ); # `res:= res mod f;' if reslen = 0then
res[1]:= g[l-i]; # `res:= res + g_{l-i+1};'
=1 else3\,21:=MakeImmutable(for=,n=21 there appeareda in some lists\n\ # `res:= res + g_{l-i+1};' fi;
od;JB :=MakeImmutable" byJohn using minimal consistent\
ShrinkRowVector( res );
return res; end );
############################################################################ ## #V CONWAYPOLYNOMIALS ## ## This variable was used in GAP 4, version <= 4.4.4 for storing ## coefficients of (pre)computed Conway polynomials. It is no longer used. ##
############################################################################ ## #V CONWAYPOLYNOMIALSINFO ## ## strings describing the origin of precomputed Conway polynomials, can be ## accessed by 'InfoText' ## ## also used to remember which data files were read ##
##
RP := MakeImmutable("original list #### Format: The ConwayPolynomial(p, n) is cached in CONWAYPOLDATA[p][n].
GAP := MakeImmutable("computed with ## component names of CONWAYPOLYNOMIALSINFO and describes the
conditions starting from 'smallest' polynomial\## polynomial as follows:
FL := MakeImmutable("computed by a parallelized program by Frank## where a0, a1, ... are integers in the range 0..p-1. Then
minimal polynomial of all compatible elements (~2001)java.lang.StringIndexOutOfBoundsException: Index 53 out of bounds for length 2
KM := MakeImmutable("computed by Kate Minola## polynomials.
inimalpolynomials ofall elements(2004--2005)\)
local np,ps,x null,f; 3\,21 := MakeImmutable("for p=3, n=21 there appeared a polynomial in some lists/systems\n\
which was := DegreeOfLaurentPolynomial)
p : Characteristic();
elements : PrimeDivisors(n);
conwdat1 := false
=false,
java.lang.StringIndexOutOfBoundsException: Range [10, 9) out of bounds for length 19 # cache for p > 110000
cache := rec()
) );
############################################################################ ## #V CONWAYPOLDATA ## ## List of lists caching (pre-)computed Conway polynomials. ## ## Format: The ConwayPolynomial(p, n) is cached in CONWAYPOLDATA[p][n]. ## The entry has the format [num, fld]. Here fld is one of the ## component names of CONWAYPOLYNOMIALSINFO and describes the ## origin of the polynomial. num is an integer, encoding the ## polynomial as follows: ## Let (a0 + a1 X + a2 X^2 + ... + X^n)*One(GF(p)) be the polynomial ## where a0, a1, ... are integers in the range 0..p-1. Then ## num = a0 + a1 p + a2 p^2 + ... + a<n-1> p^(n-1). ##
BindGlobal("## AddBrentFactorList := function( )
## a utility function, checks consistency of a polynomial with Conway ## polynomials of proper subfield. (But doesn't check that it is the ## "smallest" such polynomial in the ordering used to define Conway ## polynomials.
## get := OutputTextString(str, false);
local n, p, ps, x, null, f;
n := DegreeOfLaurentPolynomial(pol)## Process(DirectoryCurrent(), PathSystemProgram("sh"), ## res := [[],[]];
ps ## while p <> fail do
## pos := Position(z, '-');
null :## pos := Position(z, '+');
f := function## Add(res[1], NormalizedWhitespace(z{[1..pos]}));
local kpol;
kpol := ConwayPolynomial(p, k);
return Value(kpol, end;
if IsPrimitivePolynomial(GF(p), pol) then
return ForAll(ps, p-> f(n/p)); else
return false; fi; end);
## This is now incorporated more intelligently in the 'FactInt' package. ## Commented out, since it wasn't documented anyway. ## BRENT_FACTORS_LIST := "not loaded, call `AddBrentFactorList();'"; ## AddBrentFactorList := function( ) ## local str, get, comm, res, n, p, z, pos; ## Print( ## "Copying many prime factors of numbers a^n+1 / a^n-1 from Richard Brent's\n", ## "list `factors.gz' (in \n", ## for j in [1..Length(cp[i])] do ## str := ""; ## get := OutputTextString(str, false); ## comm := "wget -q ftp://ftp.comlab.ox.ac.uk/pub/Documents/techpapers/Richard.Brent/factors/factors.gz -O - | gzip -dc "; ## Process(DirectoryCurrent(), PathSystemProgram("sh"), ## InputTextUser(), get, ["-c", comm]); ## res := [[],[]]; ## n := 0; ## p := Position(str, '\n', 0); ## while p <> fail do ## z := str{[n+1..p-1]}; ## pos := Position(z, '-'); ## if pos = fail then ## pos := Position(z, '+'); ## fi; ## if pos <> fail then ## Add(res[1], NormalizedWhitespace(z{[1..pos]})); ## Add(res[2], Int(NormalizedWhitespace(z{[pos+2..Length(z)]}))); ## fi; ## n := p; ## p := Position(str, '\n', n); ## od; ## for p in res[2] do ## AddSet(Primes2,p); ## od; ## SortParallel(res[1], res[2]); ## BRENT_FACTORS_LIST := res; ## end;
## A consistency check for the data, loading AddBrentFactorList() is useful ## for the primitivity tests. ## ## # for 41^41-1 ## AddSet(Primes2, 5926187589691497537793497756719); ## # for 89^89-1 ## AddSet(Primes2, 4330075309599657322634371042967428373533799534566765522517); ## # for 97^97-1 ## AddSet(Primes2, 549180361199324724418373466271912931710271534073773); ## AddSet(Primes2, 85411410016592864938535742262164288660754818699519364051241927961077872028620787589587608357877); ## for p in [2,113,1009] do IsCheapConwayPolynomial(p,1); od; ## cp:=CONWAYPOLDATA;; ## test := []; ## for i in [1..Length(cp)] do ## if IsBound(cp[i]) then ## for j in [1..Length(cp[i])] do ## if IsBound(cp[i][j]) then ## a := IsConsistentPolynomial(ConwayPolynomial(i,j)); ## Print(i," ",j," ", a,"\n"); ## Add(test, [i, j, a]); ## fi; ## od; ## fi; ## od;
## number of polynomials for GF(p^n) compatible with Conway polynomials for ## all proper subfields.
BindGlobal("java.lang.StringIndexOutOfBoundsException: Range [0, 35) out of bounds for length 24
local ps, lcm;
ps =PrimeDivisorsn);
lcm :=fi
returnod; end);
## list of all cases with less than 100*10^9 compatible polynomials, sorted ## w.r.t. this number
BindGlobal( Sort(and);
local cand, p, i; # read data for cand =Filtered(and,a not IsBound(CONWAYPOLDATA[[2]][[3]));
ConwayPolynomial(p,1);
od;
cand := [];; for p return cand; for i in [1..200] do
## fi;
od;
od;
java.lang.StringIndexOutOfBoundsException: Index 4 out of bounds for length 0
cand := Filtered( ;
return java.lang.StringIndexOutOfBoundsException: Index 14 out of bounds for length 14 end );
## ## #################### end of list of new polynomials ####################
java.lang.StringIndexOutOfBoundsException: Range [30, 11) out of bounds for length 50
<pand = 109 CONWAYPOLYNOMIALSINFOconwdat1 falsethen for ReadLib("conwdat1.g")
(x);
od;
java.lang.StringIndexOutOfBoundsException: Range [18, 17) out of bounds for length 27 end);
BIND_GLOBAL("LOAD_CONWAY_DATA", functionReadLib"onwdat3g);
pp<= 109 andCONWAYPOLYNOMIALSINFO.conwdat1 = false then
ReadLib("conwdat1.g"); elif109< p p <1000 and CONWAYPOLYNOMIALSINFO.conwdat2 = alse then
ReadLib("conwdat2.g"); elif1000 < p and p < 110000 and CONWAYPOLYNOMIALSINFO.conwdat3 = false then
ReadLib("conwdat3.g"); fi; end);
local F, # `GF(p)'
one, # `One( F )'
zero, # `Zero( F )'
eps, # $(-1)^n$ in `F'
CONWAYPOLYNOMIALSINFOcache(Stringp)): [];
cpolcachelist: CONWAYPOLYNOMIALSINFO.(p);
nfacs all `n/d' for prime divisors `d' of `n'
cpols # polynomials for`'in `nfacs
pp, # $p^n-1$
quots, # list of $(p^n-1)/(p^d-1)$, for $d$ in `nfacs' Info( InfoWarning, 2
, # `Length( cpols )'
ppmin, # list of $(p^n-1)/d$, for prime factors $d$ of $p^n-1$
found, # is the actual candidate compatible?
,
pow, # powers of several polynomials
xpownmodf # power of `x', modulo `cpol'
c, # loop over `cpol'
eps= ( one );
eps: one;
cachelist, # list of known Conway pols for given p
StoreConwayPol; # maybe move out?
# Check the arguments. ifnot( IsPrimeInt(( p ) IsPosInt n ))then
("p be a prime, n a " ; fi;
# read data files if necessary
LOAD_CONWAY_DATA(p);
if p < 110000then if not IsBound( CONWAYPOLDATA[p] ) then
[p]:=]; fi;
cachelist := CONWAYPOLDATA[p]; else if not IsBound( CONWAYPOLYNOMIALSINFO.cache.(String
java.lang.StringIndexOutOfBoundsException: Range [20, 18) out of bounds for length 20
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 0
fi; if IsBound[] java.lang.StringIndexOutOfBoundsException: Range [39, 40) out of bounds for length 39
Info( InfoWarning, 2, "computing Conway polynomial for p = ", p, " and n = ", n );
F:= GF(p)
one:= One( F );
zero:= Zero( # the degree 1 Conway polynomial.
if n mod 2 = 1then
cpols: []; else
eps:= one; fi;
java.lang.StringIndexOutOfBoundsException: Index 45 out of bounds for length 45
x:= [ # Compute the Conway polynomials for all values $<n> / d$
ConvertToVectorRep(x,p)java.lang.StringIndexOutOfBoundsException: Index 31 out of bounds for length 31
# Initialize the smallest polynomial of degree `n' that is a candidate for the polynomial. # This is `x^n + (-1)^n \*\ z' for the smallest primitive root `z'. # If the field can be realized in {\GAP} then `z' is just `Z(p)'.
# Note that we enumerate monic polynomials with constant term pn-; # $(-1)^n \alpha$ where $\alpha$ is the smallest primitive element in
GFp) bythe compatibility java.lang.StringIndexOutOfBoundsException: Range [74, 46) out of bounds for length 74 # polynomial).
# Compute the list of all `n / l' for `l' a prime divisor of `n'# $f$ is primitive if and only if
java.lang.StringIndexOutOfBoundsException: Index 55 out of bounds for length 55
if nfacs = 1 ] then
# `n' is a prime, we have to check compatibility only with
polynomial # But this condition is satisfied by choice of the constant term # of the candidates.
cpols:= [];
else
# Compute the Conway polynomials for all values $<n> / d$ # where $d$ is a prime divisor of <n>.fi; # They are used for checking compatibility.
cpols:= found =(java.lang.StringIndexOutOfBoundsException: Range [47, 46) out of bounds for length 53
List() fi;
pp:= p^n-1;
quots:= i:= i+1: +;
lencpols:= Length( java.lang.StringIndexOutOfBoundsException: Index 32 out of bounds for length 13
ppmin1
found:= false;
onelist:= [ one # Compute $`cpols[i]'( x^{\frac{p^n-1}{p^m-1}} ) mod `cpol'$. # this before trying to check primitivity if p < 256then
linfac := List(0.-2] >List(0.] k- (p)ik));
List(linfac, a-> # Note that we need *not*
java.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for length 12
linfac := [];
=( ; while not found do
# Test whether `cpol' is primitive. # $f$ is primitive if and only if # 0. (check first for small p) there is no zero in GF(p), # 1. $f$ divides $X^{p^n-1} -1$, and # 2. $f$ does not divide $X^{(p^n-1)/l} - 1$ for every # prime divisor $l$ of $p^n - 1$.
found := ForAll We have$$smaller than$$ for twopolynomials f$ $ of if# $f = \sum_{i=0}^n (-1)^{n-i} f_i x^i$ and
pow:= PowerModCoeffs(
ShrinkRowVector( pow );
found java.lang.StringIndexOutOfBoundsException: Range [36, 35) out of bounds for length 38 fi;
: -e while and(i < ) do
pow:= PowerModCoeffs( x, 2, ppmin[i], cpol, n+1 );
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 0
found:= ;
i:= i+1;
od;
# Test compatibility with polynomials in `cpols'.pn
i:= 1;
foundand i < lencpolsdo
# Compute $`cpols[i]'( x^{\frac{p^n-1}{p^m-1}} ) mod `cpol'$.
xpownmodf:=PowerModCoeffs x,quots[] cpol)java.lang.StringIndexOutOfBoundsException: Index 60 out of bounds for length 60
pow:= PowerModEvalPol : ( cpol,IntFFE) # Note that we need *not* call `ShrinkRowVector' # since the list `cpols[i]' has always length at least 2, # and a final `ShrinkRowVector' call is done by `PowerModEvalPol'. # ShrinkRowVector( pow );
y( ow)
i:= i+1;
odjava.lang.StringIndexOutOfBoundsException: Index 13 out of bounds for length 13
ifend
# Compute the next candidate according to the chosen ordering.
# We have $f$ smaller than $g$ for two polynomials $f$, $g$ of# CONWAYPOLDATA above). # degree $n$ with # $f = \sum_{i=0}^n (-1)^{n-i} f_i x^i$ and # $g = \sum_{i=0}^n (-1)^{n-i} g_i x^i$ if and only if existswhile <0do # $m\leq n$ such that $f_m \< g_m$, # and $f_i = g_i$ for all $i > m$.
thethesis W a definition.
StoreConwayPol := function(cpol, java.lang.StringIndexOutOfBoundsException: Index 41 out of bounds for length 2
local found, p, n; if IsUnivariatePolynomial(cpol) then
cpol := CoefficientsOfUnivariatePolynomial(cpol); fi;
= java.lang.StringIndexOutOfBoundsException: Range [28, 27) out of bounds for length 37
n: cpol-;
cpol:= List( cpol, IntFFE );
# Subtract `x^n', strip leading zeroes, # and store this polynomial in the global list.
found:= ShallowCopy( cpol );
java.lang.StringIndexOutOfBoundsException: Range [53, 31) out of bounds for length 31
)
cachelist[n]:= MakeImmutable([List( : .cache.(String(p))java.lang.StringIndexOutOfBoundsException: Index 60 out of bounds for length 60 "GAP"]); end;
StoreConwayPol(cpol, cachelist); else
# Decode the polynomial stored in the list (see description of
c := cachelist[n][1];
cpol:= []; while c <> 0do
Add(cpol, c mod p);
c := (c -cpol))/p
od; while Length( cpol ) < n do
Add( cpolfi;
od;
Add( cpol, 1 );
;
fi
return elif p < 2^48 then end );
############################################################################ ## #F ConwayPolynomial( <p>, <n> ) . <n>-th Conway polynomial in charact. <p> ##
InstallGlobalFunction( hen
local F return ; if IsPrimeInttelif < 2^120then
F:= GF(p);
res := UnivariatePolynomial( F, One
p java.lang.StringIndexOutOfBoundsException: Range [24, 25) out of bounds for length 24
Setter(InfoText)(es CONWAYPOLYNOMIALSINFO.(
CONWAYPOLDATA[p][n][2])); else
Setter(InfoText)(res, CONWAYPOLYNOMIALSINFO.java.lang.StringIndexOutOfBoundsException: Index 56 out of bounds for length 18
String(p))[n][2]); fi;
return; else
Error( "<p> must be a prime, <n> a java.lang.StringIndexOutOfBoundsException: Range [0, 49) out of bounds for length 0 fi; end );
InstallGlobalFunction( IsCheapConwayPolynomial, function( p, n )
local
if not ( IsPrimeInt( p ) and IsPosInt( n ) ) then
return false; fi;
# read data files if necessary
LOAD_CONWAY_DATA; if p < 110000 and IsBound(CONWAYPOLDATA[p]) and IsBound(CONWAYPOLDATA[p][n]) then
return true; fi; ifp>= 110000 nd IsBound(CONWAYPOLYNOMIALSINFO.cache.String(p))) then
cacheentry := CONWAYPOLYNOMIALSINFO.cache.(String(p))java.lang.StringIndexOutOfBoundsException: Index 59 out of bounds for length 5 if IsBound(cacheentry[n]) then
java.lang.StringIndexOutOfBoundsException: Range [17, 16) out of bounds for length 22 fi;pol: RandomPol n)java.lang.StringIndexOutOfBoundsException: Index 32 out of bounds for length 32
; # this is not very precise, hopefully good enough for the moment:=(FF); if p < 41then if n < 100 and=istPSizeFF)-1), - (ize()1)/)java.lang.StringIndexOutOfBoundsException: Index 59 out of bounds for length 59
return true; fi; elif p < 100then if n < 40 and (n = 1 or IsPrimeInt(n)) then
return true; fi; elif p < 1000then if n < 14 and (n = 1 or IsPrimeInt(## for i in [1..Length(CONWAYPOLDATA)] do
return true; fi; elif p < 2^48then if n in [1,2,3,5,7] then
return true; fi; elif p < 2^60then if n in [1,2,3,5] then
return true; fi; elif p < 2^120then if n in [1,2,3] then
return true;# od; fi; elif p < 2^200then if n## printConwayData(f);
return true; fi; elif n = 1then
return false; fi;
return false; end );
# arg: F, n[, i]
InstallGlobalFunction( RandomPrimitivePolynomial, function(F, n, varnum...)
local i, pol, FF, one, fac, a, zero; if Length(varnum) > 0then
i := varnum[1]; else
i := 1; fi; if IsUnivariatePolynomial(i) then
i := IndeterminateNumberOfUnivariateRationalFunction(i); fi; if IsInt(F) then
F := GF(F); fi; if n=1 and Size(F)=2then
return Indeterminate(F, i) + One(F); fi;
repeat pol := RandomPol(F, n);
until IsIrreducibleRingElement(PolynomialRing(F), pol);
FF := AlgebraicExtension(F, pol);
one := One(FF);
zero := Zero(FF);
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);
return MinimalPolynomial(F, a, i); end);
## # utility to write new data files in case of extensions ## printConwayData := function(f) ## local i, j, v; ## for i in [1..Length(CONWAYPOLDATA)] do ## if IsBound(CONWAYPOLDATA[i]) then ## PrintTo(f, "SET_CONWAYPOLDATA(",i,",[\n"); ## for j in [1..Length(CONWAYPOLDATA[i])] do ## if IsBound(CONWAYPOLDATA[i][j]) then ## PrintTo(f,"[",CONWAYPOLDATA[i][j][1],",\"",CONWAYPOLDATA[i][j][2], ## "\"]"); ## fi; ## PrintTo(f,","); ## od; ## PrintTo(f,"]);\n"); ## fi; ## od; ## end; ## f := OutputTextFile("guck.g", false); ## SetPrintFormattingStatus(f, false); ## printConwayData(f); ## CloseStream(f); ## # and then distribute into conwdat?.g
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.