fq_zech_ctx_init_modulus, fq_zech_ctx_init_modulus_check
#include <flint/fq_zech.h>void fq_zech_ctx_init_modulus(fq_zech_ctx_t ctx, const nmod_poly_t modulus, const char * var)sourceint fq_zech_ctx_init_modulus_check(fq_zech_ctx_t ctx, const nmod_poly_t modulus, const char * var)sourceInitialise 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.
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).
@misc{flint-doc-fq-zech-fq-zech-ctx-init-modulus,
author = {{The FLINT team}},
title = {{fq\_zech\_ctx\_init\_modulus, fq\_zech\_ctx\_init\_modulus\_check (fq\_zech.h)}},
howpublished = {FLINT: Fast Library for Number Theory, documentation, version 3.7.0-dev},
year = {2026},
url = {https://flintlib.org/doc/fq_zech/fq_zech_ctx_init_modulus.html},
note = {Generated 2026-10-20}
}