FLINT3.7.0-dev

_fmpz_mod_poly_gcd, fmpz_mod_poly_gcd

Synopsis#include <flint/fmpz_mod_poly.h>
slong _fmpz_mod_poly_gcd(fmpz * G, const fmpz * A, slong lenA, const fmpz * B, slong lenB, const fmpz_mod_ctx_t ctx)source
void fmpz_mod_poly_gcd(fmpz_mod_poly_t G, const fmpz_mod_poly_t A, const fmpz_mod_poly_t B, const fmpz_mod_ctx_t ctx)source

Set G to the greatest common divisor of A and B, which is made monic by the non-underscore version (the gcd of two zero polynomials is zero). The underscore version requires \mathit{lenA} \ge \mathit{lenB} > 0 and space for \mathit{lenB} coefficients in G, returns the length of G and does not normalise its leading coefficient. The modulus must be prime.

For \min(\mathit{lenA}, \mathit{lenB}) < 256 the Euclidean algorithm is used (_gr_poly_gcd_euclidean), and above that the half-GCD algorithm (_gr_poly_gcd_hgcd with base case cutoff 128), in O(M(n) \log n) operations; see Half-GCD.

Guides#

Cite this page

The FLINT team, “_fmpz_mod_poly_gcd, fmpz_mod_poly_gcd (fmpz_mod_poly.h),” FLINT: Fast Library for Number Theory, documentation, version 3.7.0-dev, 2026. https://flintlib.org/doc/fmpz_mod_poly/_fmpz_mod_poly_gcd.html (generated 2026-10-20).