FLINT3.7.0-dev

mpn_mod_set_mpn

Synopsis#include <flint/mpn_mod.h>
int mpn_mod_set_mpn(nn_ptr res, nn_srcptr x, slong xn, gr_ctx_t ctx)source

Sets res to x \bmod n, where x \ge 0 is given by the xn limbs at x (\mathit{xn} \ge 0; the top limb may be zero). This is the reduction used throughout the module for unreduced sums and products. res may be the same pointer as x but must not overlap it otherwise.

Values with fewer limbs than n, or with \ell limbs and less than n, are copied. Otherwise x is shifted left by \nu bits and divided by n 2^{\nu}, with GMP's mpn_divrem_2 for \ell = 2 and with flint_mpn_mod_preinvn and the precomputed inverse of the context for \ell \ge 3.

Cite this page

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