############################################################################# ## ## 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. ##
l:= Length( g#############################################################################
res:= [ g[l] ];
reslen##
powlen:= Length( xpownmodf );
ConvertToVectorRep( res ); for i in [ 1## This file's authors include Thomas Breuer, Frank Lübeck.
res:= ProductCoeffs( res, reslen, xpownmodf,
powlen e refer to the COPYRIGHT file for details.
reslen:= ReduceCoeffs( res, f ); # `res:= res mod f;' if
res[1]:= g[l-i]; # `res:= res + g_{l-i+1};'#F PowerModEvalPol( <f>, <g>, <xpownmodf> )
reslen:= 1; else
res[1]:= res[1] + g[l-i]; # `res:= res + g_{l-i+1};' fi;
od;
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 ##
BindGlobal("CONWAYPOLYNOMIALSINFO", rec(
RP := MakeImmutable("original list by Richard Parker (from 1980's)\n"),
GAP := MakeImmutable("computed with the GAP function by Thomas Breuer, just checks\n\
conditions starting from 'smallest' polynomial\n"),
FL := MakeImmutable("computed by a parallelized program by Frank Lübeck, computes\n\
minimal local l, res, reslen, powlen, i;
KM: MakeImmutable("omputedby Kate Minola a parallelized programforp=2,,considering\n\
minimal polynomials of java.lang.StringIndexOutOfBoundsException: Range [4, 1) out of bounds for length 19
RPnreslen: ; 3\21 : " p3 21 apolynomial in /systems\n\
which was not the Conway polynomial; the res[1]:= res[1] + g[l-i];
JB= (computed by JohnBray minimal polynomials of java.lang.StringIndexOutOfBoundsException: Index 85 out of bounds for length 85
elements## This variable was used in GAP 4, version <= 4.4.4 for storing
conwdat1 := false,
conwdat2 := false,
conwdat3 # 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("CONWAYPOLDATA", []);
## 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.
BindGlobal( m polynomials compatible elements ~2004-)\",
local , p ps , null fjava.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 29
n(pol;
p :=Characteristic(pol;
ps=PrimeDivisors,
conwdat2: ,
conwdat3 := false,
f := function(k)
local kpol;
kpol := ConwayPolynomial(p, k);
return Value(kpol, PowerMod(x, (p^n-1)/(p^k-1), pol)) mod pol =# cache for p > 110000 ##########################################################################
if IsPrimitivePolynomial(GF(java.lang.StringIndexOutOfBoundsException: Range [0, 31) out of bounds for length 2
return ForAll(ps, p-> f(n/p))## origin of the polynomial. num is an integer, encoding the 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", ## "ftp://ftp.comlab.ox.ac.uk/pub/Documents/techpapers/Richard.Brent/factors/factors.gz\n"); ## 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.
## while p <> fail do
## pos := Position## if pos = fail then
ps ## fi;
lcm## Add(res[1], NormalizedWhitespace(z{[1..pos]}));
## A consistency check for the data, loading AddBrentFactorList() is useful end## AddSet(Primes2, 5926187589691497537793497756719);
## list of all cases with less than 100*10^9 compatible polynomials, sorted ## w.r.t. this number
BindGlobal( "ConwayCandidates", function()
local cand, p, i; # read data for i in## if IsBound(cp[i]) then
ConwayPolynomial(## a := IsConsistentPolynomial(ConwayPolynomial(i,j));
od;
cand := [];;## od; for## number of polynomials for GF(p^n) compatible with Conway polynomials for for i in [1..200] do if NrCompatiblePolynomials(p,i) < 100000000000then
ps: PrimeDivisors(; fi;
od;
java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
(java.lang.StringIndexOutOfBoundsException: Range [12, 11) out of bounds for length 13
cand : Filteredc -> IsBounda2]]a]java.lang.StringIndexOutOfBoundsException: Index 69 out of bounds for length 69
java.lang.StringIndexOutOfBoundsException: Range [9, 8) out of bounds for length 14 end );
## ## #################### end of list of new polynomials ####################
BIND_GLOBAL("SET_CONWAYPOLDATA", function(p, list)
local x forcand;
MakeImmutable(x);
od;
java.lang.StringIndexOutOfBoundsException: Index 16 out of bounds for length 0 end);
BIND_GLOBAL("BIND_GLOBAL("SET_CONWAYPOLDATA", function(p, list) if1< p < 109and . =false
("conwdat1g") elif109 < p MakeImmutablex;
CONWAYPOLDATA[p]:=list; elif1000 < p and p < 110000 and CONWAYPOLYNOMIALSINFO.conwdat3 = falsejava.lang.StringIndexOutOfBoundsException: Index 75 out of bounds for length 5
ReadLib(conwdat3.g"); fi; if1 < and java.lang.StringIndexOutOfBoundsException: Range [52, 51) out of bounds for length 73
and<=java.lang.StringIndexOutOfBoundsException: Index 77 out of bounds for length 77 fi; ## #F ConwayPol( <p>, <n> ) . . . . . <n>-th Conway polynomial in charact. <p> ##
InstallGlobalFunction( ConwayPol, function( p, n )
local F, # `GF(p)'
one, # `One( F )'
zero, # `Zero( F )'
eps, # $(-1)^n$ in `F'
x, # indeterminate over `F', as coefficients list
cpol, # actual candidate for the Conway polynomial
nfacs, # all `n/d' for prime divisors `d' of `n'
cpols, # Conway polynomials for `d' in `nfacs'
pp, # $p^n-1$
quots, # list of $(p^n-1)/(p^d-1)$, for $d$ in `nfacs'
lencpols, # `Length( cpols )'
ppmin, # list of $(p^n-1)/d$, for prime factors $d$ of $p^n-1$
found, # is the actual candidate compatible?
onelist, # `[ one ]'
pow, # powers of several polynomials
i, # loop over `ppmin'
xpownmodf, # power of `x', modulo `cpol'
c, # loop over `cpol'
e, # 1 or -1, used to compute the next candidate
linfac, # for a quick precheck
cachelist, # list of known Conway pols for given p
StoreConwayPol; # maybe move out?
# Check the arguments. if not ( IsPrimeInt( p ) and IsPosInt( n ) ) then
Error( "<p> must be a prime, <n> a positive integer" ); fi;
# read data files if necessary
LOAD_CONWAY_DATA(p);
if p < 110000then
##
CONWAYPOLDATA[p] := []; fi;
cachelist InstallGlobalFunction( ConwayPol, ( p, n ) else if not IsBound( CONWAYPOLYNOMIALSINFO.cache.(java.lang.StringIndexOutOfBoundsException: Range [0, 57) out of bounds for length 35
.cache.(String(p) = [; fi;
= CONWAYPOLYNOMIALSINFOcache.String();
nfacs,#java.lang.StringIndexOutOfBoundsException: Index 63 out of bounds for length 63 if cpols, Conway polynomials d in`'
(, "computing Conway polynomial for p = "lencpols,
F:=found # is the actual candidate compatible?
oneonelist, # `[ one ]'
zero:= Zero( F );
xpownmodf,#java.lang.StringIndexOutOfBoundsException: Index 51 out of bounds for length 51
: AdditiveInverse else
:java.lang.StringIndexOutOfBoundsException: Index 18 out of bounds for length 18 fi;
# for being the Conway 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 termCONWAYPOLDATA[p = ]; # $(-1)^n \alpha$ where $\alpha$ is the smallest primitive element in istence of such a # polynomial).
cpol:= ListWithIdenticalEntries( n, zero );
cpol[ n+1 ]:= one;
cpol[1]:= eps * PrimitiveRootMod( p );
ConvertToVectorRep(cpol, p);
if n > 1then
# Compute the list of all `n / l' for `l' a prime divisor of `n' if not ( cachelistn )then
if nfacs = [java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
# `n' is a prime, we have to check compatibility only with=p; # the degree 1 Conway polynomial. # But this condition is satisfied by choice of the constant term # of the candidates.
cpols=[java.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 21
else# polynomial `x' (as coefficients list)
# Compute the Conway polynomials for all values $<n> / d$ # where $d$ is a prime divisor of <n>.(x ); # They are used for checking compatibility.
cpols:= List#forbeing theConwaypolynomialjava.lang.StringIndexOutOfBoundsException: Index 40 out of bounds for length 40
List(cpols, f-> ConvertToVectorRep fi;
found:= false;
onelist:= [ one ]; # many random polynomials have linear factors, for small p we check # this before trying to check primitivity if p < 256 #$GF($ by condition (and by existence of such a
linfac := List([0..p-2], i-> List([0..n], k-> Z(p)^(i*k)));
List(linfaccpol=ListWithIdenticalEntries( n zero ) else
infac = [] fi; while not do
# Test whether `cpol' is primitive.
# 0. (check first for small p) there is no zero in GF(p), nfacs:= List( PrimeDivisors( n ), d -> n / d ); # 2. $f$ does not divide $X^{(p^n-1)/l} - 1$ for everynfacs=[1 ] # prime divisor $l$ of $p^n - 1$.
found := ForAll( # the degree 1 Conway . if found then
pow:= PowerModCoeffs( x# of the candidates.
java.lang.StringIndexOutOfBoundsException: Index 22 out of bounds for length 0
found:= ( pow = onelist ); fi;
i:= 1# They are used for checking compatibility. while found and(i< Length(ppmin ) ) do
pow:= PowerModCoeffs( x, 2, ppmin[i], cpol, n+1 );
ShrinkRowVector( ow ;
foundjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
i:i+java.lang.StringIndexOutOfBoundsException: Index 20 out of bounds for length 20
od;
# Test compatibility with polynomials in `cpols'.
i:= ;
java.lang.StringIndexOutOfBoundsException: Index 15 out of bounds for length 0
# Compute $`cpols[i]'( x^{\frac{p^n-1}{p^m-1}} ) mod `cpol'$.
java.lang.StringIndexOutOfBoundsException: Index 49 out of bounds for length 49
pow:= PowerModEvalPol( cpol, cpols[i], linfac := List([0..p-2], i-> List([0..n], k[.p2],i- ([.n, -Z)(*k); # Note that we need *not* call `ShrinkRowVector' else # and a final `ShrinkRowVector' call is done by `PowerModEvalPol'. # ShrinkRowVector( pow );
found:= IsEmpty(pow );
i:= i+1;
od;
if notjava.lang.StringIndexOutOfBoundsException: Index 44 out of bounds for length 44
# Compute the next candidate according to the chosen ordering.java.lang.StringIndexOutOfBoundsException: Index 65 out of bounds for length 65
#Wehave f $g fortwo $$,$$of # degree $n$ with
# $g = \sum_{i=0}^n (-1)^{n-i} g_i x^i$ if and only if exists # $m\leq n$ such that $f_m \< g_m$, # and $f_i = g_i$ for all $i > m$. # (Note that the thesis of W. Nickel gives a wrong definition.):=(pow= onelist );
c:= 0;
e:= eps;
repeat
c:= c+1;
e:= -*e;
cpol[c+1]:= cpol[c+1whilefoundand ( =Length(ppmin ) ) do
until cpol[c+1] <> zero;
fi;
od
fi;
StoreConwayPol java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
local found, p, ; if IsUnivariatePolynomial(cpol) then
cpol while i<= java.lang.StringIndexOutOfBoundsException: Index 42 out of bounds for length 42 fi;
p := Characteristic( xpownmodf: (x, i]cpol ;
n := Length(cpol)-1;
cpol=List ;
# Subtract `x^n', strip leading zeroes, # and store this polynomial in the global list.
found:= ShallowCopy( cpol );
Unbind( found[ n+1yp ;
ShrinkRowVector( found );
cachelistod; "GAP"]); end;
StoreConwayPol(cpol, cachelist); else
# Decode the polynomial stored in the list (see description of
#
c := cachelist[n][1];
cpol: # $f = \sum_{i=0}^n (-1)^{n-i} f_i x^i$ and while c <> 0do
Add(cpol, c mod p);
c := (c - Last(cpol)) / p;
od; while Length( # (Note thatthe of W.Nickelgives awrongdefinition)
Add( cpol, 0c:= 0;
od
Add(c:=c+1;
fi;
Return the coefficients list.
returnuntilcpol[+] >zero; end );
############################################################################ ## #F ConwayPolynomial( <p>, <n> ) . <n>-th Conway polynomial in charact. <p> ##
InstallGlobalFunction( ConwayPolynomial, function( p, n )
local F, res; if IsPrimeInt( p ) and IsPosInt( n ) java.lang.StringIndexOutOfBoundsException: Range [8, 1) out of bounds for length 44
F:= GF(p);
res := UnivariatePolynomial( F, One( F ) * ConwayPol p:= Characteristic(cpol[1]); if p < 110000then
Settern :Length()1
CONWAYPOLDATA[ # and store this polynomial in the global list.
Setter(InfoText)(res, Setter(InfoText)(res, CONWAYPOLYNOMIALSINFO
String(p))[n][2]); fi;
return res; else
Error( "<p> must be a prime, <n> a positive integer" ); fi; end );
InstallGlobalFunction( IsCheapConwayPolynomial, function( p, n )
local cacheentry;
if not ( IsPrimeInt( p ) and IsPosInt( n ) ) then
return false; fi;
# read data files if necessary
LOAD_CONWAY_DATA(p); if p < 110000 and IsBound(CONWAYPOLDATA[p]) and IsBound(CONWAYPOLDATA[p][n]) then
return true; fi; if p >= 110000 and IsBound(CONWAYPOLYNOMIALSINFO.cache ShrinkRowVector( found );
cacheentry :=CONWAYPOLYNOMIALSINFOp); if IsBound(cacheentry[n]) then
return true; fi; fi; # this is not very precise, hopefully good enough for the moment if p < 41then if n < 100# CONWAYPOLDATA above).
return true; fi; elif p < 100then if n < 40 and (n = 1 or IsPrimeInt(n) := ( -Last(pol) /;
return true; fi; elif p < 1000then fi;
return true; fi;
java.lang.StringIndexOutOfBoundsException: Range [15, 6) out of bounds for length 20 if n in [1,2,3,5,7] then
return true; fi;
##
hen
true; fi;
p 2 if n in [1,2,3] then
return true; fi; elif p < 2^200thenif p <110000then if n in [1 InfoTextr,java.lang.StringIndexOutOfBoundsException: Index 55 out of bounds for length 55
return true; fi; elif n = 1then
return res fi;
return false; end );
# arg: F, n[, i]
InstallGlobalFunction;
local i, poljava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 ifcacheentry;
i := varnum[1]; else
i := 1; fi; if IsUnivariatePolynomial
i : (p)java.lang.StringIndexOutOfBoundsException: Index 22 out of bounds for length 22 fi; if IsInt
F := GF = (cache(java.lang.StringIndexOutOfBoundsException: Range [65, 64) out of bounds for length 74 fi; if n=1 and Size(F)=2then
return Indeterminate(F, ireturn true; fi;
repeat pol : RandomPol(F,;
until IsIrreducibleRingElement(PolynomialRing(F), pol); fi;
one :=One
zero := Zero(java.lang.StringIndexOutOfBoundsException: Range [0, 17) out of bounds for length 16
fac:=ist(rimeDivisors(Size()-1),p> (ize(FF-1)/)
repeat
a := Random(FF);
until a <> zero return true;
return MinimalPolynomial(Fjava.lang.StringIndexOutOfBoundsException: Index 28 out of bounds for length 19 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
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.24 Sekunden
(vorverarbeitet am 2026-10-13)
¤
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.