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 mod nx \bmod n, where x≥0x \ge 0 is given by the xn limbs at x (xn≥0\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 nn, or with ℓ\ell limbs and less than nn, are copied. Otherwise xx is shifted left by ν\nu bits and divided by n2νn 2^{\nu}, with GMP's mpn_divrem_2 for ℓ=2\ell = 2 and with flint_mpn_mod_preinvn and the precomputed inverse of the context for ℓ≥3\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-11-02).