FLINT3.7.0-dev

_nmod_mul_bounded, _nmod_addmul_bounded, _nmod_fmma_bounded

Synopsis#include <flint/nmod.h>
ulong _nmod_mul_bounded(ulong a, ulong b, nmod_t mod)source
ulong _nmod_addmul_bounded(ulong s, ulong a, ulong b, nmod_t mod)source
ulong _nmod_fmma_bounded(ulong a, ulong b, ulong c, ulong d, nmod_t mod)source

Return abab, s+abs + ab and ab+cdab + cd modulo nn, for reduced operands, with one reduction by NMOD_RED2_BOUNDED (Low-level macros), which is cheaper than the reductions of nmod_mul, nmod_addmul and nmod_fmma. The first two require NMOD_CAN_USE_MUL_BOUNDED(mod), that is 3≤ν≤FLINT_BITS−23 \le \nu \le \mathtt{FLINT\_BITS} - 2 where ν\nu is the number of bits of nn; the third requires NMOD_CAN_USE_FMMA_BOUNDED(mod), that is 3≤ν≤FLINT_BITS−33 \le \nu \le \mathtt{FLINT\_BITS} - 3. For other nn the result is wrong. As for _nmod_mul_halflimb, test the modulus once and write two loops rather than testing it at each product: a test inside nmod_mul was measured to make some compilers evaluate both reductions, or branch, at each product. For n≤2FLINT_BITS/2n \le 2^{\mathtt{FLINT\_BITS} / 2}, abab and s+abs + ab fit in one word, and _nmod_mul_halflimb, or NMOD_RED of s+abs + ab, is cheaper still; so is NMOD_RED of ab+cdab + cd for n≤2FLINT_BITS/2−1n \le 2^{\mathtt{FLINT\_BITS} / 2 - 1}. The loops of FLINT test for these moduli first.

Guides#

Cite this page

The FLINT team, “_nmod_mul_bounded, _nmod_addmul_bounded, _nmod_fmma_bounded (nmod.h),” FLINT: Fast Library for Number Theory, documentation, version 3.7.0-dev, 2026. https://flintlib.org/doc/nmod/_nmod_mul_bounded.html (generated 2026-11-20).