FLINT3.7.0-dev
Module · 113 functions

fq_zech_mpoly.h

#include <flint/fq_zech_mpoly.h>

This module implements multivariate polynomials over a finite field \mathbb{F}_q whose elements are represented by Zech logarithms (see fq_zech.h), which makes multiplication in the field cheap but limits q to fields small enough for the logarithm tables, which have q entries. The representation and the conventions are those of fq_nmod_mpoly (see fq_nmod_mpoly.h and Types and conventions): sorted terms with packed exponent vectors, and a context fq_zech_mpoly_ctx_t with the number of variables, the monomial ordering and the field. Unlike fq_nmod_mpoly, the coefficients are stored as an array of fq_zech_struct.

The module exists mainly to support the medprime factoring algorithms of nmod_mpoly_factor, which map a polynomial over \mathbb{F}_p to \mathbb{F}_{p^k} with p^k \le 10^6 and factor it there (Factoring over finite fields). Its interface is therefore incomplete: arithmetic, division, evaluation in one variable, derivatives, degrees and GCDs are implemented (with the algorithms of Sparse and dense multiplication, Division, exact division and square roots and Greatest common divisors), while parsing, most term access functions, random generation, composition and deflation, for example, are not available. GCDs and factorisations are computed by converting to fq_nmod_mpoly.

Unless stated otherwise, each function has the semantics of the fq_nmod_mpoly function with the same name, with fq_nmod replaced by fq_zech.

Types#

A multivariate polynomial over \mathbb{F}_q, with the fields coeffs (an array of fq_zech_struct), exps, alloc (the number of terms allocated, for both arrays), length and bits.

The context of a polynomial ring \mathbb{F}_q[x_0, \ldots, x_{m-1}], with the fields minfo (an mpoly_ctx_t) and fqctx (an fq_zech_ctx_t).

A polynomial in a main variable with fq_zech_mpoly_t coefficients and fmpz exponents, as fq_nmod_mpoly_univar_t.

Context objects#

Initialises ctx for polynomials in nvars variables with the ordering ord over \mathbb{F}_{p^{\mathit{deg}}}, defined by a Conway polynomial if the database has one and a random primitive polynomial otherwise (see fq_zech_ctx_init_ui); the generator is printed as #. This is the only way to create a context.

Replaces the field of ctx by \mathbb{F}_{p^{\mathit{deg}}} with the same characteristic. Polynomials of the context become invalid.

Return the number of variables and the ordering, and free the context.

Returns the nmod_t of the characteristic p of the field.

Memory management#

Initialise A as zero (allocating nothing, space for alloc terms, or space for alloc terms with bits-bit exponent fields), and free it.

Ensure space for length terms; ensure exponent fields of at least bits bits, repacking the exponents; ensure space for len terms with exactly bits bits, discarding the exponent data.

Keep only the newlen leading terms, and repack the exponents into Abits bits (returning 0 if they do not fit).

Input and output#

int fq_zech_mpoly_fprint_pretty(FILE * file, const fq_zech_mpoly_t A, const char ** x, const fq_zech_mpoly_ctx_t ctx)
int fq_zech_mpoly_print_pretty(const fq_zech_mpoly_t A, const char ** x, const fq_zech_mpoly_ctx_t ctx)

Print A to file or stdout with the variable names x (or x1, x2, ... if x is NULL).

Basic manipulation and constants#

The variable of index var, assignment, swap and equality test.

Test whether A is constant, set it to the constant c (an integer is reduced modulo p), to 0 or to 1, and test for 0 and 1.

Returns a pointer to the leading coefficient of the nonzero A.

Degrees and coefficients#

void fq_zech_mpoly_get_coeff_vars_ui(fq_zech_mpoly_t C, const fq_zech_mpoly_t A, const slong * vars, const ulong * exps, slong length, const fq_zech_mpoly_ctx_t ctx)

Sets C to the coefficient of \prod_i x_{v_i}^{e_i} in A viewed as a polynomial in the variables vars[i] with coefficients in the others.

Container operations#

Return the number of terms, whether A is canonical, or throw if it is not.

Return whether the exponents of the term of index i fit a ulong or slong.

Sort the terms into the order of the context, and combine equal adjacent monomials and remove zero coefficients.

Arithmetic#

Set A to c B, to B + d C, or to B divided by its leading coefficient (throwing if B is zero).

Sets A to the derivative of B with respect to the variable of index var.

Sets A to B with the variable of index var replaced by val.

Set A to B C by Johnson's heap algorithm [Joh1974].

If B divides A, set Q (poly1) to the quotient and return 1; otherwise return 0. Uses the heap algorithm of Monagan and Pearce [MonPea2011].

Set Q and R to the quotient and remainder of A divided by B.

Greatest common divisors#

Set G to the monic GCD of A and B (and the cofactors A/G, B/G), computed by converting to fq_nmod_mpoly and calling fq_nmod_mpoly_gcd or fq_nmod_mpoly_gcd_cofactors. Return 1 for success.

Univariate representation#

Convert B to a polynomial in the variable of index var, and back (with Abits-bit exponents in the last version).

Internal functions#

void _fq_zech_mpoly_fit_length(fq_zech_struct ** coeff, ulong ** exps, slong * alloc, slong len, slong N, const fq_zech_ctx_t fqctx)

Ensure room for len coefficients and exponent vectors of N words (the common allocation is alloc), and set the length.

void _fq_zech_mpoly_radix_sort1(fq_zech_mpoly_t A, slong left, slong right, flint_bitcnt_t pos, ulong cmpmask, ulong totalmask)
slong _fq_zech_mpoly_add(fq_zech_struct * coeff1, ulong * exp1, fq_zech_struct * coeff2, const ulong * exp2, slong len2, fq_zech_struct * coeff3, const ulong * exp3, slong len3, slong N, const ulong * cmpmask, const fq_zech_ctx_t fqctx)
slong _fq_zech_mpoly_mul_johnson(fq_zech_struct ** coeff1, ulong ** exp1, slong * alloc, const fq_zech_struct * coeff2, const ulong * exp2, slong len2, const fq_zech_struct * coeff3, const ulong * exp3, slong len3, flint_bitcnt_t bits, slong N, const ulong * cmpmask, const fq_zech_ctx_t fqctx)
void _fq_zech_mpoly_eval_all_fq_zech(fq_zech_t eval, const fq_zech_struct * Acoeffs, const ulong * Aexps, slong Alen, flint_bitcnt_t Abits, fq_zech_struct * const * alphas, const mpoly_ctx_t mctx, const fq_zech_ctx_t fqctx)

Radix sort of terms, merge-addition and heap multiplication of term arrays, and evaluation at a point.

_fq_zech_mpoly_get_nmod_mpoly sets s to t if all coefficients of t lie in the prime field \mathbb{F}_p and returns 1, and returns 0 otherwise. _fq_zech_mpoly_set_nmod_mpoly maps a polynomial over \mathbb{F}_p into \mathbb{F}_q. The two contexts must have the same variables and ordering.

Convert between Zech logarithm and polynomial representation of the same field (the fq_nmod_ctx of the Zech context) with the same variables and ordering.

Sets c to the leading coefficient of A viewed as a polynomial in its first num_vars variables.

References#

Cite this page

The FLINT team, “fq_zech_mpoly.h (module overview),” FLINT: Fast Library for Number Theory, documentation, version 3.7.0-dev, 2026. https://flintlib.org/doc/fq_zech_mpoly/index.html (generated 2026-10-20).