FLINT3.7.0-dev

gr_ctx_init_mpn_mod, _gr_ctx_init_mpn_mod

Synopsis#include <flint/mpn_mod.h>
int gr_ctx_init_mpn_mod(gr_ctx_t ctx, const fmpz_t n)source
int _gr_ctx_init_mpn_mod(gr_ctx_t ctx, nn_srcptr n, slong nlimbs)source

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#

Cite this page

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).