FLINT3.7.0-dev

fq_zech_ctx_init_modulus, fq_zech_ctx_init_modulus_check

Synopsis#include <flint/fq_zech.h>
void fq_zech_ctx_init_modulus(fq_zech_ctx_t ctx, const nmod_poly_t modulus, const char * var)source
int fq_zech_ctx_init_modulus_check(fq_zech_ctx_t ctx, const nmod_poly_t modulus, const char * var)source

Initialise ctx with the given defining polynomial, which must be primitive; it is copied into a new fq_nmod context owned by ctx. While the tables are built, primitivity is checked: the powers g^0, \ldots, g^{q-2} must be distinct. fq_zech_ctx_init_modulus throws FLINT_ERROR for a non-primitive polynomial; fq_zech_ctx_init_modulus_check returns 1 on success and 0 if the polynomial is not primitive. After a return value of 0, all memory has already been freed: ctx must not be used, and need not be cleared (clearing it is allowed and has no effect). fq_default_ctx_init_modulus_nmod falls back to fq_nmod for a non-primitive modulus.

In FLINT 3.6 and earlier, fq_zech_ctx_init_modulus did not throw but returned an unusable context, and clearing a context after a failed check freed the tables twice.

Cite this page

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