gr_ctx_init_mpn_mod, _gr_ctx_init_mpn_mod
#include <flint/mpn_mod.h>Initialises ctx to the ring \mathbb{Z}/n\mathbb{Z} with elements stored as arrays of as many limbs as n. Returns GR_DOMAIN if n \le 0 and GR_UNABLE if n does not have between MPN_MOD_MIN_LIMBS and MPN_MOD_MAX_LIMBS limbs; in both cases ctx is not initialised and must not be cleared. The underscore version takes n as nlimbs limbs, of which the top one must be nonzero.
The context allocates its _mpn_mod_ctx_struct on the heap and must be cleared with gr_ctx_clear. Initialisation costs one precomputed inverse of n (flint_mpn_preinvn). The primality flag starts as T_UNKNOWN.
A caller that handles all sizes typically uses gr_ctx_init_nmod for one limb, this function for 2 to 16 limbs and gr_ctx_init_fmpz_mod beyond.
Guides#
The FLINT team, “gr_ctx_init_mpn_mod, _gr_ctx_init_mpn_mod (mpn_mod.h),” FLINT: Fast Library for Number Theory, documentation, version 3.7.0-dev, 2026. https://flintlib.org/doc/mpn_mod/gr_ctx_init_mpn_mod.html (generated 2026-10-20).
@misc{flint-doc-mpn-mod-gr-ctx-init-mpn-mod,
author = {{The FLINT team}},
title = {{gr\_ctx\_init\_mpn\_mod, \_gr\_ctx\_init\_mpn\_mod (mpn\_mod.h)}},
howpublished = {FLINT: Fast Library for Number Theory, documentation, version 3.7.0-dev},
year = {2026},
url = {https://flintlib.org/doc/mpn_mod/gr_ctx_init_mpn_mod.html},
note = {Generated 2026-10-20}
}