flint_mpn_sqrt
Synopsis
#include <flint/mpn_extras.h>int flint_mpn_sqrt(mp_ptr s, mp_srcptr a, mp_size_t an)sourceChecked exact square root, the analogue of flint_mpn_div: if is a perfect square, sets to its square root and returns 1; otherwise returns 0, the contents of being undefined. Requires .
Nonsquares are usually rejected before any root is computed by quadratic residue tests modulo 256 and modulo the factors 9, 5, 7, 13, 17, 97, 241 and 257 of , all obtained from one reduction modulo (flint_mpn_mod_2exp48m1); about one random nonsquare in 900 survives. On 32-bit builds the residues come from two mpn_mod_1 calls instead.
Cite this page
The FLINT team, “flint_mpn_sqrt (mpn_extras.h),” FLINT: Fast Library for Number Theory, documentation, version 3.7.0-dev, 2026. https://flintlib.org/doc/mpn_extras/flint_mpn_sqrt.html (generated 2026-11-02).
@misc{flint-doc-mpn-extras-flint-mpn-sqrt,
author = {{The FLINT team}},
title = {{flint\_mpn\_sqrt (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_sqrt.html},
note = {Generated 2026-11-02}
}