Last Saturday I finished the first big part of my project: I ported Cantor-Zassenhaus algorithm with all helper functions from nmod_poly module to fmpz_mod_poly module.
I think it was an important part of my job because it helped me to familiarise myself with the code: I found some important differences between nmod and fmpz modules (I spent a lot of time debugging my stupid errors relates to these differences).
During the last month I got a good impression of the code of FLINT. I like it's clearness: every function has it's own file and detailed description, the function names are easy-to-understand (I mean that one can guess what the function should do according to it's name), pieces of code doing one distinct thing are organised in separate functions (so the complex algorithms don't look ugly).
Now I'm going to describe Cantor-Zassenhaus algorithm (the complete description can be found in Modern Computer Algebra book).
Input and output
The algorithm gets on input a nonconstant polynomial P over a field Zq (q is an odd prime number). On output it gives all monic irreducible factors of P with their multipliсities.
Short description
In brief the algorithm can be described as follows: in a cycle for i=1,2,... it computes distinct-degree polynomial gi (a product of all squarefree irreducible factors of P of degree i), then it decomposes gi into equal degree factors fij (each of degree i) and for all j removes the highest possible degree of fij (say eij) from P simply dividing P by fij. The cycle continues for P=P′ (P′ is P without feijij) while degP′>1.
Distinct-degree factorisation
This algorithm is based on Fermat's little theorem, more precisely on the consequence of the following
Theorem. For any d≥1(xqd−x)∈Fq[x] is the product of all monic irreducible polynomials in Fq[x] whose degree divides d.
Now we can easily construct an algorithm: for d=1,2,... compute h=xqd−x and find g=gcd(h,f), continue this procedure for f=fg until f=1.
Equal-degree factorisation
It is a recursive algorithm: it calls a probabilistic procedure of finding a factor g of a given degree of a polynomial P, then it removes the found factor g from P and calls itself for P=Pf.
Equal-degree splitting
It is a probabilistic procedure of finding a factor g of a given degree of a polynomial P. It is based on the following
Lemma. Let q be an odd prime number. Then a(q−1)/2∈{1,−1}∀a∈F∗q (F∗q is a multiplicative group of Fq).
Let the polynomial P have the degree n=rd and every it's single factor have the degree d. Then the probabilistic algorithm is as follows: choose a∈Fq[x] with dega<n at random. If dega=0 return "failure". Else compute g1=gcd(a,f). If degg1>0 return g1. Else (if degg1=0) compute b=a(qd−1)/2remf (see Lemma) and g2=gcd(b−1,f). If g2≠1,g2≠f return g2, else return "failure".
Some technical remarks
To compute powers of q the binary exponentiation method can be applied.
To compute the gcd euclidean method can be used.
According to my project proposal I'm out of schedule, so I would like to change the order of the next two algorithms and to continue now with "baby/giant step" algorithm (and to implement Berlekamp after it if there is time left).
Hello,
ReplyDeleteYou say:
The algorithm gets on input a nonconstant polynomial P over a field Zq (q is an odd prime number).
Wouldn't it work too for q = 2 ? If not, what would prevent it to work ?
Regards,
Colin