flint_mpn_pow
#include <flint/mpn_extras.h>Sets \mathit{res} to x^e by left-to-right binary exponentiation and returns the number of limbs of the result. res must have room for flint_mpn_pow_bound_limbs(x, xn, e) limbs and must not overlap x. Requires \mathit{xn} \ge 1 and x_{xn-1} \ne 0; e = 0 gives 1.
Low zero limbs of x are stripped and restored as an offset in the output; trailing zero bits are shifted out only when the base is short (at most 8 limbs) and restored with one shift of the result. While the power fits in one or two limbs, fixed-size arithmetic is used. Afterwards the running power alternates between res and a scratch buffer without copying: the parity of the remaining out-of-place operations is chosen so that the final product lands in res, and multiplications by a single-limb base are done in place with mpn_mul_1.
The FLINT team, “flint_mpn_pow (mpn_extras.h),” FLINT: Fast Library for Number Theory, documentation, version 3.7.0-dev, 2026. https://flintlib.org/doc/mpn_extras/flint_mpn_pow.html (generated 2026-10-20).
@misc{flint-doc-mpn-extras-flint-mpn-pow,
author = {{The FLINT team}},
title = {{flint\_mpn\_pow (mpn\_extras.h)}},
howpublished = {FLINT: Fast Library for Number Theory, documentation, version 3.7.0-dev},
year = {2026},
url = {https://flintlib.org/doc/mpn_extras/flint_mpn_pow.html},
note = {Generated 2026-10-20}
}