fmpq_mpoly_factor.h
#include <flint/fmpq_mpoly_factor.h>This module factors polynomials in \mathbb{Q}[x_0, \ldots, x_{n-1}] (see fmpq_mpoly.h). Since an fmpq_mpoly_t is stored as a rational content times an integer polynomial, factoring over \mathbb{Q} amounts to factoring the integer part with fmpz_mpoly_factor and multiplying the rational content into the constant. The factorisation over \mathbb{Q} is unique up to multiplying the bases by nonzero rationals; the two normalising functions below fix this freedom.
Types#
A factored polynomial c \prod_{i < \mathit{num}} p_i^{e_i} with a rational constant: the fields are constant (an fmpq_t), poly (the bases, of type fmpq_mpoly_struct), exp (the exponents, of type fmpz), num and alloc.
Memory management#
void fmpq_mpoly_factor_init(fmpq_mpoly_factor_t f, const fmpq_mpoly_ctx_t ctx)Initialises f as the empty product with constant 1.
void fmpq_mpoly_factor_realloc(fmpq_mpoly_factor_t f, slong alloc, const fmpq_mpoly_ctx_t ctx)void fmpq_mpoly_factor_fit_length(fmpq_mpoly_factor_t f, slong len, const fmpq_mpoly_ctx_t ctx)Change the allocation to exactly alloc factors (freeing the factors beyond it, and everything if \mathit{alloc} \le 0), respectively ensure room for at least len factors.
void fmpq_mpoly_factor_clear(fmpq_mpoly_factor_t f, const fmpq_mpoly_ctx_t ctx)Frees the memory used by f.
Basic manipulation#
slong fmpq_mpoly_factor_length(const fmpq_mpoly_factor_t f, const fmpq_mpoly_ctx_t ctx)Returns the number of bases of f.
void fmpq_mpoly_factor_get_constant_fmpq(fmpq_t c, const fmpq_mpoly_factor_t f, const fmpq_mpoly_ctx_t ctx)Sets c to the constant of f.
void fmpq_mpoly_factor_get_base(fmpq_mpoly_t p, const fmpq_mpoly_factor_t f, slong i, const fmpq_mpoly_ctx_t ctx)void fmpq_mpoly_factor_swap_base(fmpq_mpoly_t p, fmpq_mpoly_factor_t f, slong i, const fmpq_mpoly_ctx_t ctx)Set p to, respectively swap p with, the base of index i.
slong fmpq_mpoly_factor_get_exp_si(fmpq_mpoly_factor_t f, slong i, const fmpq_mpoly_ctx_t ctx)Returns the exponent of the base of index i, which must fit an slong.
void fmpq_mpoly_factor_sort(fmpq_mpoly_factor_t f, const fmpq_mpoly_ctx_t ctx)Sorts the factors by increasing exponent, and factors with equal exponents by fmpq_mpoly_cmp.
int fmpq_mpoly_factor_expand(fmpq_mpoly_t A, const fmpq_mpoly_factor_t f, const fmpq_mpoly_ctx_t ctx)Sets A to the product represented by f. Returns 0 if an exponent is negative or a power cannot be computed, and 1 otherwise.
int fmpq_mpoly_factor_make_monic(fmpq_mpoly_factor_t f, const fmpq_mpoly_ctx_t ctx)int fmpq_mpoly_factor_make_integral(fmpq_mpoly_factor_t f, const fmpq_mpoly_ctx_t ctx)Rescale the bases and adjust the constant so that the product is unchanged: make_monic makes every base monic (leading coefficient 1 in the monomial ordering), and make_integral moves the rational content of every base into the constant, leaving the integer part (primitive, with positive leading coefficient). Return 0 if a base is zero or a power of a content cannot be computed, and 1 otherwise.
Factorisation#
The factoring functions return 1 for success and 0 for failure, in which case f is unspecified; failure happens only in the circumstances described for fmpz_mpoly_factor. They overwrite f. The normalisation of the bases is not part of the specification: currently they are integral, primitive and with positive leading coefficients, as after fmpq_mpoly_factor_make_integral, but code that depends on a normalisation should call one of the normalising functions.
int fmpq_mpoly_factor_squarefree(fmpq_mpoly_factor_t f, const fmpq_mpoly_t A, const fmpq_mpoly_ctx_t ctx)Sets f to a factorisation of A whose bases are squarefree and pairwise coprime, computed with fmpz_mpoly_factor_squarefree on the integer part of A. One multiplicity can occur in several bases; to get one base for each multiplicity, sort with fmpq_mpoly_factor_sort and multiply the bases with equal exponents.
int fmpq_mpoly_factor(fmpq_mpoly_factor_t f, const fmpq_mpoly_t A, const fmpq_mpoly_ctx_t ctx)Sets f to the factorisation of A into a rational constant and distinct irreducible polynomials, computed with fmpz_mpoly_factor on the integer part of A. See Factoring multivariate polynomials over the integers for the methods.
Internal functions#
void _fmpq_mpoly_factor_swap_fmpz_mpoly_factor(fmpq_mpoly_factor_t f, fmpz_mpoly_factor_t g, const fmpq_t c, const fmpq_mpoly_ctx_t ctx)Sets f to c times the factorisation g over the integers, moving the bases out of g (which is left with unspecified bases). g must be over the integer context ctx->zctx.
The FLINT team, “fmpq_mpoly_factor.h (module overview),” FLINT: Fast Library for Number Theory, documentation, version 3.7.0-dev, 2026. https://flintlib.org/doc/fmpq_mpoly_factor/index.html (generated 2026-10-20).
@misc{flint-doc-fmpq-mpoly-factor-index,
author = {{The FLINT team}},
title = {{fmpq\_mpoly\_factor.h (module overview)}},
howpublished = {FLINT: Fast Library for Number Theory, documentation, version 3.7.0-dev},
year = {2026},
url = {https://flintlib.org/doc/fmpq_mpoly_factor/index.html},
note = {Generated 2026-10-20}
}