FLINT3.7.0-dev

flint_mpn_gcdext

Synopsis#include <flint/mpn_extras.h>
mp_size_t flint_mpn_gcdext(mp_ptr gp, mp_ptr sp, mp_size_t * sn, mp_srcptr ap, mp_size_t an, mp_srcptr bp, mp_size_t bn)source

Sets (gp,ℓ)(\mathit{gp}, \ell) to g=gcd⁡(a,b)g = \gcd(a, b), returning ℓ\ell, and (sp,∣∗sn∣)(\mathit{sp}, |{*\mathit{sn}}|) with the sign of ∗sn*\mathit{sn} to the cofactor ss of aa in g=sa+tbg = s a + t b that mpz_gcdext gives: normally ∣s∣<b/(2g)|s| < b/(2g), and the conventions for the exceptional cases determine ss uniquely. The other cofactor is t=(g−sa)/bt = (g - s a)/b. The operands must be nonzero with nonzero top limbs; they are not modified. gp needs room for min⁡(an,bn)\min(\mathit{an}, \mathit{bn}) limbs and sp for bn\mathit{bn} limbs. The outputs must not overlap each other; each may be equal to ap or bp (if that has the room) but must not otherwise overlap them. When an<bn\mathit{an} < \mathit{bn}, ss is obtained from the cofactor of bb by a multiplication and an exact division.

Cite this page

The FLINT team, “flint_mpn_gcdext (mpn_extras.h),” FLINT: Fast Library for Number Theory, documentation, version 3.7.0-dev, 2026. https://flintlib.org/doc/mpn_extras/flint_mpn_gcdext.html (generated 2026-11-02).