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 Z/nZ\mathbb{Z}/n\mathbb{Z} with elements stored as arrays of as many limbs as nn. Returns GR_DOMAIN if n≤0n \le 0 and GR_UNABLE if nn 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 nn 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 nn (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-11-02).