@@ -222,14 +222,47 @@ Randomization
222222
223223 Generates a random polynomial with length up to ``len ``.
224224
225- .. function :: void nmod_poly_randtest_irreducible(nmod_poly_t poly, flint_rand_t state, slong len)
226-
227- Generates a random irreducible polynomial with length up to ``len ``.
228-
229225.. function :: void nmod_poly_randtest_monic(nmod_poly_t poly, flint_rand_t state, slong len)
230226
231227 Generates a random monic polynomial with length ``len ``.
232228
229+ .. function :: void nmod_poly_randtest_trinomial(nmod_poly_t poly, flint_rand_t state, slong len)
230+
231+ Generates a random monic trinomial of length ``len ``.
232+
233+ .. function :: void nmod_poly_randtest_pentomial(nmod_poly_t poly, flint_rand_t state, slong len)
234+
235+ Generates a random monic pentomial of length ``len ``.
236+
237+ Construction of irreducible polynomials
238+ --------------------------------------------------------------------------------
239+
240+ The following functions assume a prime modulus.
241+
242+ .. function :: void nmod_poly_minimal_irreducible(nmod_poly_t res, ulong n)
243+
244+ Generates a monic irreducible polynomial of degree ``n `` with minimal
245+ weight (minimal number of nonzero terms). We generate a binomial
246+ if possible, otherwise a trinomial, etc.
247+ It is conjectured that one never needs more than a pentanomial
248+ modulo `p = 2 ` and a tetranomial modulo `p > 2 `.
249+
250+ More specifically, this function returns the first among all minimal-weight
251+ polynomials in the following ordering.
252+ Firstly, for trinomials, `x^n + a x^k + b ` comes before
253+ its monic reversal `x^n + a' x^{n-k} + b' ` if `k < n - k `.
254+ Secondly, writing
255+ `f = x^n + a_1 x^{k_1} + a_2 x^{k_2} + \ldots + a_t x^{k_t} `
256+ with `n > k_1 > k_2 \ldots > k_t `, we order tuples
257+ `(a_1, \ldots, a_{t}, k_1, \ldots, k_t) ` lexicographically.
258+ We thus favor polynomials with smaller coefficients
259+ (all 1 if possible), and secondly with smaller degrees for the
260+ middle terms.
261+
262+ .. function :: void nmod_poly_randtest_irreducible(nmod_poly_t poly, flint_rand_t state, slong len)
263+
264+ Generates a random irreducible polynomial with length up to ``len ``.
265+
233266.. function :: void nmod_poly_randtest_monic_irreducible(nmod_poly_t poly, flint_rand_t state, slong len)
234267
235268 Generates a random monic irreducible polynomial with length ``len ``.
@@ -239,11 +272,6 @@ Randomization
239272 Generates a random monic irreducible primitive polynomial with
240273 length ``len ``.
241274
242-
243- .. function :: void nmod_poly_randtest_trinomial(nmod_poly_t poly, flint_rand_t state, slong len)
244-
245- Generates a random monic trinomial of length ``len ``.
246-
247275.. function :: int nmod_poly_randtest_trinomial_irreducible(nmod_poly_t poly, flint_rand_t state, slong len, slong max_attempts)
248276
249277 Attempts to set ``poly `` to a monic irreducible trinomial of
@@ -253,10 +281,6 @@ Randomization
253281 trinomials until an irreducible one is found. Returns `1 ` if one
254282 is found and `0 ` otherwise.
255283
256- .. function :: void nmod_poly_randtest_pentomial(nmod_poly_t poly, flint_rand_t state, slong len)
257-
258- Generates a random monic pentomial of length ``len ``.
259-
260284.. function :: int nmod_poly_randtest_pentomial_irreducible(nmod_poly_t poly, flint_rand_t state, slong len, slong max_attempts)
261285
262286 Attempts to set ``poly `` to a monic irreducible pentomial of
0 commit comments