Counts give estimate for time. Nice feature of sbcl profiler
is that it gives you also estimate for time spent in functions
called from given function. One needs to look for times that
are suspicously high, in this case:
10654 98.1 |FFPOLY;createIrreduciblePoly;PiSup;16| [364]
25 0.2 10654 98.1 |FFPOLY;nextIrreduciblePoly;SupU;11| [62]
1 0.0 |DDFACT;ddffact1| [39]
1 0.0 SB-KERNEL::INTEXP [75]
6 0.1 |LIST;setfirst!;$2S;12| [101]
2 0.0 |FFP;index;Pi$;17| [137]
4 0.0 TRUNCATE [11]
11 0.1 |FFPOLY;revListToSUP| [99]
200 1.8 |SAE;index;Pi$;35| [56]
10399 95.7 |DDFACT;irreducible?;FPB;8| [94]
Indented line ('nextIrreduciblePoly') is function under consideration.
Before is infor about callers, in this case 'createIrreduciblePoly'.
After is info about called functions, clearly 'irreducible?'
dominates here. You can see that also 'index' takes some time.
This is hint that 'nextIrreduciblePoly' makes many iterations.
Looking at 'createIrreduciblePoly' we can see the problem, namely
it starts at x^2. 'nextIrreduciblePoly' linearly increases
constant term checking if result is irreducible. But your
base field is extention of degree 2 of Z_p, so _all_ polynomials
with coefficients in Z_p of degree 2 are reducible over your
field. So 'nextIrreduciblePoly' has any chance of success only
when it passes all 1000002 nonzero elements of Z_p and starts
using elements of the extention.
Attached is a patch that works around the problem: if base field
is an extention of Z_p it starts in place intended to be in
appropriate extention. I wrote "intended" because we have
no warranty that represention of the field is by polynomials
and 'index' may work differently. But in any case it should
avoid long streches of trials in base field where we have
no chance.
Idealy we should make 'createIrreduciblePoly' smarter. For
binomial polynomal there is an easy criterion for existence
of irreducible polynomial: all prime diving n must divide
q - 1 (size of multiplicative group of the field) and if 4
divides n then 4 must divide q - 1. It may happen that
fraction of irreducible binomials is quite low, but there
is systematic procedure to generate them.
I am not sure about trinomials x^n + x + c. It seems that
when there is no irreducible binomial in many cases there is
irreducible trinomial of such a form. But if not, then
we can spent a lot of time trying trinomials of such a form.
So it would be nice to have some results about possiblity
of finding trinomials of such a form.
Another question is rationale for current method. It seems
that Johannes wanted deterministic procedure, that is in each
run generate the same polynomial. Also, there is some gain
if we can use "simple" irreducible polynomials. But then
there is question if "simple" irreducible polynomials
exist and home much time we need to spent to generate
them. Note that in general dense monic polynomial is
irreducible with probablity of order 1/n (where n is
degree of the polynomial), so we could get random
irreducible polynomial in resonable expected time.
--
Waldek Hebisch