_gr_poly_divrem, gr_poly_divrem, _gr_poly_divrem_basecase_preinv1, _gr_poly_divrem_basecase_noinv, _gr_poly_divrem_basecase, gr_poly_divrem_basecase, _gr_poly_divrem_divconquer_preinv1, _gr_poly_divrem_divconquer_noinv, _gr_poly_divrem_divconquer, gr_poly_divrem_divconquer, _gr_poly_divrem_newton, gr_poly_divrem_newton
#include <flint/gr_poly.h>int _gr_poly_divrem(gr_ptr Q, gr_ptr R, gr_srcptr A, slong lenA, gr_srcptr B, slong lenB, gr_ctx_t ctx)sourceint gr_poly_divrem(gr_poly_t Q, gr_poly_t R, const gr_poly_t A, const gr_poly_t B, gr_ctx_t ctx)sourceint _gr_poly_divrem_basecase_preinv1(gr_ptr Q, gr_ptr R, gr_srcptr A, slong lenA, gr_srcptr B, slong lenB, gr_srcptr invB, gr_ctx_t ctx)sourceint _gr_poly_divrem_basecase_noinv(gr_ptr Q, gr_ptr R, gr_srcptr A, slong lenA, gr_srcptr B, slong lenB, gr_ctx_t ctx)sourceint _gr_poly_divrem_basecase(gr_ptr Q, gr_ptr R, gr_srcptr A, slong lenA, gr_srcptr B, slong lenB, gr_ctx_t ctx)sourceint gr_poly_divrem_basecase(gr_poly_t Q, gr_poly_t R, const gr_poly_t A, const gr_poly_t B, gr_ctx_t ctx)sourceint _gr_poly_divrem_divconquer_preinv1(gr_ptr Q, gr_ptr R, gr_srcptr A, slong lenA, gr_srcptr B, slong lenB, gr_srcptr invB, slong cutoff, gr_ctx_t ctx)sourceint _gr_poly_divrem_divconquer_noinv(gr_ptr Q, gr_ptr R, gr_srcptr A, slong lenA, gr_srcptr B, slong lenB, slong cutoff, gr_ctx_t ctx)sourceint _gr_poly_divrem_divconquer(gr_ptr Q, gr_ptr R, gr_srcptr A, slong lenA, gr_srcptr B, slong lenB, slong cutoff, gr_ctx_t ctx)sourceint gr_poly_divrem_divconquer(gr_poly_t Q, gr_poly_t R, const gr_poly_t A, const gr_poly_t B, slong cutoff, gr_ctx_t ctx)sourceint _gr_poly_divrem_newton(gr_ptr Q, gr_ptr R, gr_srcptr A, slong lenA, gr_srcptr B, slong lenB, gr_ctx_t ctx)sourceint gr_poly_divrem_newton(gr_poly_t Q, gr_poly_t R, const gr_poly_t A, const gr_poly_t B, gr_ctx_t ctx)sourceSet and to the quotient and remainder of by . The non-underscore functions return GR_DOMAIN if is zero and GR_UNABLE if the leading coefficient of is not provably nonzero. gr_poly_divrem calls the ring method GR_METHOD_POLY_DIVREM.
The basecase versions perform long division. The divconquer versions divide blocks of coefficients of the dividend by recursively, with two divisions by the upper half of and products by its lower half, and use long division for divisors shorter than cutoff. The newton versions use Newton division. The preinv1 versions take a precomputed inverse invB of the leading coefficient, the noinv versions divide by the leading coefficient with gr_div at each step, and the plain versions try to invert the leading coefficient and fall back to the noinv algorithm.
The default method _gr_poly_divrem_generic uses long division when or , and over finite rings also when the divisor or the quotient has at most 10 coefficients; otherwise it uses Newton division, falling back to long or divide-and-conquer division without inversion when the leading coefficient is not invertible. Rings with fast arithmetic override the method: nmod, fmpz_mod, mpn_mod, fq, fq_nmod, fq_zech, arb and acb call the division of their own polynomial modules.
The underscore functions assume:
- and a nonzero leading coefficient of ;
- has room for and for coefficients;
- is not aliased with or , and is not aliased with ;
- may be aliased with , in which case all coefficients are used as scratch space and only the low are meaningful on output.
Guides#
The FLINT team, “_gr_poly_divrem, gr_poly_divrem, _gr_poly_divrem_basecase_preinv1, _gr_poly_divrem_basecase_noinv, _gr_poly_divrem_basecase, gr_poly_divrem_basecase, _gr_poly_divrem_divconquer_preinv1, _gr_poly_divrem_divconquer_noinv, _gr_poly_divrem_divconquer, gr_poly_divrem_divconquer, _gr_poly_divrem_newton, gr_poly_divrem_newton (gr_poly.h),” FLINT: Fast Library for Number Theory, documentation, version 3.7.0-dev, 2026. https://flintlib.org/doc/gr_poly/_gr_poly_divrem.html (generated 2026-11-02).
@misc{flint-doc-gr-poly-gr-poly-divrem,
author = {{The FLINT team}},
title = {{\_gr\_poly\_divrem, gr\_poly\_divrem, \_gr\_poly\_divrem\_basecase\_preinv1, \_gr\_poly\_divrem\_basecase\_noinv, \_gr\_poly\_divrem\_basecase, gr\_poly\_divrem\_basecase, \_gr\_poly\_divrem\_divconquer\_preinv1, \_gr\_poly\_divrem\_divconquer\_noinv, \_gr\_poly\_divrem\_divconquer, gr\_poly\_divrem\_divconquer, \_gr\_poly\_divrem\_newton, gr\_poly\_divrem\_newton (gr\_poly.h)}},
howpublished = {FLINT: Fast Library for Number Theory, documentation, version 3.7.0-dev},
year = {2026},
url = {https://flintlib.org/doc/gr_poly/_gr_poly_divrem.html},
note = {Generated 2026-11-02}
}