fmpq_mpoly.h – multivariate polynomials over the rational numbers¶
The exponents follow the
mpolyinterface. No references to the coefficients are available.
Types, macros and constants¶
-
type
fmpq_mpoly_ctx_struct¶ Context structure for
fmpq_mpoly.
-
type
fmpq_mpoly_ctx_t¶ An array of length 1 of
fmpq_mpoly_ctx_struct.
-
type
fmpq_mpoly_struct¶ A structure holding a multivariate rational polynomial. It is implemented as a
fmpq_tholding the content of the polynomial and a primitive integer polynomial.
-
type
fmpq_mpoly_t¶ An array of length 1 of
fmpq_mpoly_struct.
Context object¶
-
void
fmpq_mpoly_ctx_init(fmpq_mpoly_ctx_t ctx, slong nvars, const ordering_t ord)¶ Initialise a context object for a polynomial ring with the given number of variables and the given ordering. The possibilities for the ordering are
ORD_LEX,ORD_DEGLEXandORD_DEGREVLEX.
-
slong
fmpq_mpoly_ctx_nvars(const fmpq_mpoly_ctx_t ctx)¶ Return the number of variables used to initialize the context.
-
ordering_t
fmpq_mpoly_ctx_ord(const fmpq_mpoly_ctx_t ctx)¶ Return the ordering used to initialize the context.
-
void
fmpq_mpoly_ctx_clear(fmpq_mpoly_ctx_t ctx)¶ Release up any space allocated by an
fmpq_mpoly_ctx_t.
Memory management¶
-
void
fmpq_mpoly_init(fmpq_mpoly_t A, const fmpq_mpoly_ctx_t ctx)¶ Initialise
Afor use with the given an initialised context object. Its value is set to zero.
-
void
fmpq_mpoly_init2(fmpq_mpoly_t A, slong alloc, const fmpq_mpoly_ctx_t ctx)¶ Initialise
Afor use with the given an initialised context object. Its value is set to zero. It is allocated with space forallocterms and at leastMPOLY_MIN_BITSbits for the exponents.
-
void
fmpq_mpoly_init3(fmpq_mpoly_t A, slong alloc, flint_bitcnt_t bits, const fmpq_mpoly_ctx_t ctx)¶ Initialise
Afor use with the given an initialised context object. Its value is set to zero. It is allocated with space forallocterms andbitsbits for the exponents.
-
void
fmpq_mpoly_fit_length(fmpq_mpoly_t A, slong len, const fmpq_mpoly_ctx_t ctx)¶ Ensure that
Ahas space for at leastlenterms.
-
void
fmpq_mpoly_fit_bits(fmpq_mpoly_t A, flint_bitcnt_t bits, const fmpq_mpoly_ctx_t ctx)¶ Ensure that the exponent fields of
Ahave at leastbitsbits.
-
void
fmpq_mpoly_realloc(fmpq_mpoly_t A, slong alloc, const fmpq_mpoly_ctx_t ctx)¶ Reallocate
Ato have space forallocterms. Assumes the current length of the polynomial is not greater thanalloc.
-
void
fmpq_mpoly_clear(fmpq_mpoly_t A, const fmpq_mpoly_ctx_t ctx)¶ Release any space allocated for
A.
Input/Output¶
The variable strings in
xstart with the variable of most significance at index0. IfxisNULL, the variables are namedx1,x2, ect.
-
char *
fmpq_mpoly_get_str_pretty(const fmpq_mpoly_t A, const char **x, const fmpq_mpoly_ctx_t ctx)¶ Return a string, which the user is responsible for cleaning up, representing
A, given an array of variable stringsx.
-
int
fmpq_mpoly_fprint_pretty(FILE *file, const fmpq_mpoly_t A, const char **x, const fmpq_mpoly_ctx_t ctx)¶ Print a string representing
Atofile.
-
int
fmpq_mpoly_print_pretty(const fmpq_mpoly_t A, const char **x, const fmpq_mpoly_ctx_t ctx)¶ Print a string representing
Atostdout.
-
int
fmpq_mpoly_set_str_pretty(fmpq_mpoly_t A, const char *str, const char **x, const fmpq_mpoly_ctx_t ctx)¶ Set
Ato the polynomial in the null-terminates stringstrgiven an arrayxof variable strings. If parsingstrfails,Ais set to zero, and-1is returned. Otherwise,0is returned. The operations+,-,*, and/are permitted along with integers and the variables inx. The character^must be immediately followed by the (integer) exponent. If any division is not exact, parsing fails.
Basic manipulation¶
-
void
fmpq_mpoly_gen(fmpq_mpoly_t A, slong var, const fmpq_mpoly_ctx_t ctx)¶ Set
Ato the variable of indexvar, wherevar = 0corresponds to the variable with the most significance with respect to the ordering.
-
int
fmpq_mpoly_is_gen(const fmpq_mpoly_t A, slong var, const fmpq_mpoly_ctx_t ctx)¶ If \(var \ge 0\), return
1ifAis equal to the \(var\)-th generator, otherwise return0. If \(var < 0\), return1if the polynomial is equal to any generator, otherwise return0.
-
void
fmpq_mpoly_set(fmpq_mpoly_t A, const fmpq_mpoly_t B, const fmpq_mpoly_ctx_t ctx)¶ Set
AtoB.
-
int
fmpq_mpoly_equal(fmpq_mpoly_t A, const fmpq_mpoly_t B, const fmpq_mpoly_ctx_t ctx)¶ Return
1ifAis equal toB, else return0.
-
void
fmpq_mpoly_swap(fmpq_mpoly_t A, fmpq_mpoly_t B, const fmpq_mpoly_ctx_t ctx)¶ Efficiently swap
AandB.
Constants¶
-
int
fmpq_mpoly_is_fmpq(const fmpq_mpoly_t A, const fmpq_mpoly_ctx_t ctx)¶ Return
1ifAis a constant, else return0.
-
void
fmpq_mpoly_get_fmpq(fmpq_t c, const fmpq_mpoly_t A, const fmpq_mpoly_ctx_t ctx)¶ Assuming that
Ais a constant, setcto this constant. This function throws ifAis not a constant.
-
void
fmpq_mpoly_set_fmpq(fmpq_mpoly_t A, const fmpq_t c, const fmpq_mpoly_ctx_t ctx)¶ -
void
fmpq_mpoly_set_fmpz(fmpq_mpoly_t A, const fmpz_t c, const fmpq_mpoly_ctx_t ctx)¶ -
void
fmpq_mpoly_set_ui(fmpq_mpoly_t A, ulong c, const fmpq_mpoly_ctx_t ctx)¶ -
void
fmpq_mpoly_set_si(fmpq_mpoly_t A, slong c, const fmpq_mpoly_ctx_t ctx)¶ Set
Ato the constantc.
-
void
fmpq_mpoly_zero(fmpq_mpoly_t A, const fmpq_mpoly_ctx_t ctx)¶ Set
Ato the constant0.
-
void
fmpq_mpoly_one(fmpq_mpoly_t A, const fmpq_mpoly_ctx_t ctx)¶ Set
Ato the constant1.
-
int
fmpq_mpoly_equal_fmpq(const fmpq_mpoly_t A, fmpq_t c, const fmpq_mpoly_ctx_t ctx)¶ -
int
fmpq_mpoly_equal_fmpz(const fmpq_mpoly_t A, fmpz_t c, const fmpq_mpoly_ctx_t ctx)¶ -
int
fmpq_mpoly_equal_ui(const fmpq_mpoly_t A, ulong c, const fmpq_mpoly_ctx_t ctx)¶ -
int
fmpq_mpoly_equal_si(const fmpq_mpoly_t A, slong c, const fmpq_mpoly_ctx_t ctx)¶ Return
1ifAis equal to the constantc, else return0.
-
int
fmpq_mpoly_is_zero(const fmpq_mpoly_t A, const fmpq_mpoly_ctx_t ctx)¶ Return
1ifAis equal to the constant0, else return0.
-
int
fmpq_mpoly_is_one(const fmpq_mpoly_t A, const fmpq_mpoly_ctx_t ctx)¶ Return
1ifAis equal to the constant1, else return0.
Degrees¶
-
int
fmpq_mpoly_degrees_fit_si(const fmpq_mpoly_t A, const fmpq_mpoly_ctx_t ctx)¶ Return
1if the degrees ofAwith respect to each variable fit into anslong, otherwise return0.
-
void
fmpq_mpoly_degrees_fmpz(fmpz **degs, const fmpq_mpoly_t A, const fmpq_mpoly_ctx_t ctx)¶ -
void
fmpq_mpoly_degrees_si(slong *degs, const fmpq_mpoly_t A, const fmpq_mpoly_ctx_t ctx)¶ Set
degsto the degrees ofAwith respect to each variable. IfAis zero, all degrees are set to-1.
-
void
fmpq_mpoly_degree_fmpz(fmpz_t deg, const fmpq_mpoly_t A, slong var, const fmpq_mpoly_ctx_t ctx)¶ -
slong
fmpq_mpoly_degree_si(const fmpq_mpoly_t A, slong var, const fmpq_mpoly_ctx_t ctx)¶ Either return or set
degto the degree ofAwith respect to the variable of indexvar. IfAis zero, the degree is defined to be-1.
-
int
fmpq_mpoly_total_degree_fits_si(const fmpq_mpoly_t A, const fmpq_mpoly_ctx_t ctx)¶ Return
1if the total degree ofAfits into anslong, otherwise return0.
-
void
fmpq_mpoly_total_degree_fmpz(fmpz_t tdeg, const fmpq_mpoly_t A, const fmpq_mpoly_ctx_t ctx)¶ -
slong
fmpq_mpoly_total_degree_si(const fmpq_mpoly_t A, const fmpq_mpoly_ctx_t ctx)¶ Either return or set
tdegto the total degree ofA. IfAis zero, the total degree is defined to be-1.
Coefficients¶
-
void
fmpq_mpoly_get_denominator(fmpz_t d, const fmpq_mpoly_t A, const fmpq_mpoly_ctx_t ctx)¶ Set
dto the denominator ofA, the smallest positive integer \(d\) such that \(d*A\) has integer coefficients.
-
void
fmpq_mpoly_get_coeff_fmpq_monomial(fmpq_t c, const fmpq_mpoly_t A, const fmpq_mpoly_t M, const fmpq_mpoly_ctx_t ctx)¶ Assuming that
Mis a monomial, setcto the coefficient of the corresponding monomial inA. This function thows ifMis not a monomial.
-
void
fmpq_mpoly_set_coeff_fmpq_monomial(fmpq_mpoly_t A, const fmpq_t c, const fmpq_mpoly_t M, const fmpq_mpoly_ctx_t ctx)¶ Assuming that
Mis a monomial, set the coefficient of the corresponding monomial inAtoc. This function thows ifMis not a monomial.
-
void
fmpq_mpoly_get_coeff_fmpq_fmpz(fmpq_t c, const fmpq_mpoly_t A, fmpz *const *exp, const fmpq_mpoly_ctx_t ctx)¶ -
void
fmpq_mpoly_get_coeff_fmpq_ui(fmpq_t c, const fmpq_mpoly_t A, ulong const *exp, const fmpq_mpoly_ctx_t ctx)¶ Set
cto the coefficient of the monomial with exponentexp.
-
void
fmpq_mpoly_set_coeff_fmpq_fmpz(fmpq_mpoly_t A, const fmpq_t c, fmpz *const *exp, fmpq_mpoly_ctx_t ctx)¶ -
void
fmpq_mpoly_set_coeff_fmpq_ui(fmpq_mpoly_t A, const fmpq_t c, ulong const *exp, fmpq_mpoly_ctx_t ctx)¶ Set the coefficient of the monomial with exponent
exptoc.
-
void
fmpq_mpoly_get_coeff_vars_ui(fmpq_mpoly_t C, const fmpq_mpoly_t A, const slong *vars, const ulong *exps, slong length, const fmpq_mpoly_ctx_t ctx)¶ Set
Cto the coefficient ofAwith respect to the variables invarswith powers in the corresponding arrayexps. Bothvarsandexpspoint to array of lengthlength. It is assumed that \(0 < length \le nvars(A)\) and that the variables invarsare distinct.
Comparison¶
-
int
fmpq_mpoly_cmp(const fmpq_mpoly_t A, const fmpq_mpoly_t B, const fmpq_mpoly_ctx_t ctx)¶ Return
1(resp.-1, or0) if the monomial ofAis greater than (resp. less than, same as) the monomial ofB.AandBshould both have length one with coefficient one. This function will throw otherwise.
Container operations¶
These function try to deal efficiently with violations of the internal canonical representation. If a term index is negative or not strictly less than the length of the polynomial, the function will throw. The mutating functions here are not guaranteed to leave the polynomial in reduced form (see
fmpq_mpoly_is_canonical()for a definition of reduced). This means that even if nonzero terms with distinct exponents have been constructed in the correct order, a call tofmpq_mpoly_reduce()is necessary to ensure that the polynomial is in canonical form. As with thefmpz_mpolymodule, a call tofmpq_mpoly_sort_terms()followed by a call tofmpq_mpoly_combine_like_terms()should leave the polynomial in canoncial form.
-
fmpq *
fmpq_mpoly_content_ref(fmpq_mpoly_t A, const fmpq_mpoly_ctx_t ctx)¶ Return a reference to the content of
A.
-
fmpz_mpoly_struct *
fmpq_mpoly_zpoly_ref(fmpq_mpoly_t A, const fmpq_mpoly_ctx_t ctx)¶ Return a reference to the integer polynomial of
A.
-
fmpz *
fmpq_mpoly_zpoly_term_coeff_ref(fmpq_mpoly_t A, slong i, const fmpq_mpoly_ctx_t ctx)¶ Return a reference to the coefficient of index \(i\) of the integer polynomial of
A.
-
int
fmpq_mpoly_is_canonical(const fmpq_mpoly_t A, const fmpq_mpoly_ctx_t ctx)¶ Return
1ifAis in canonical form. Otherwise, return0. Anfmpq_mpoly_tis represented as the product of anfmpq_t contentand anfmpz_mpoly_t zpoly. The representation is considered canonical when either (1) bothcontentandzpolyare zero, or (2) bothcontentandzpolyare nonzero and canonical andzpolyis reduced. A nonzerozpolyis considered reduced when the coefficients have GCD one and the leading coefficient is positive.
-
slong
fmpq_mpoly_length(const fmpq_mpoly_t A, const fmpq_mpoly_ctx_t ctx)¶ Return the number of terms stored in
A. If the polynomial is in canonical form, this will be the number of nonzero coefficients.
-
void
fmpq_mpoly_resize(fmpq_mpoly_t A, slong new_length, const fmpq_mpoly_ctx_t ctx)¶ Set the length of
Atonew_length. Terms are either deleted from the end, or new zero terms are appended.
-
void
fmpq_mpoly_get_term_coeff_fmpq(fmpq_t c, const fmpq_mpoly_t A, slong i, const fmpq_mpoly_ctx_t ctx)¶ Set \(c\) to coefficient of index \(i\)
-
void
fmpq_mpoly_set_term_coeff_fmpq(fmpq_mpoly_t A, slong i, const fmpq_t c, const fmpq_mpoly_ctx_t ctx)¶ Set the coefficient of index \(i\) to \(c\).
-
int
fmpq_mpoly_term_exp_fits_si(const fmpq_mpoly_t A, slong i, const fmpq_mpoly_ctx_t ctx)¶ -
int
fmpq_mpoly_term_exp_fits_ui(const fmpq_mpoly_t A, slong i, const fmpq_mpoly_ctx_t ctx)¶ Return
1if all entries of the exponent vector of the term of index \(i\) fit into anslong(resp. aulong). Otherwise, return0.
-
void
fmpq_mpoly_get_term_exp_fmpz(fmpz **exps, const fmpq_mpoly_t A, slong i, const fmpq_mpoly_ctx_t ctx)¶ -
void
fmpq_mpoly_get_term_exp_ui(ulong *exps, const fmpq_mpoly_t A, slong i, const fmpq_mpoly_ctx_t ctx)¶ -
void
fmpq_mpoly_get_term_exp_si(slong *exps, const fmpq_mpoly_t A, slong i, const fmpq_mpoly_ctx_t ctx)¶ Set
expto the exponent vector of the term of indexi. The_ui(resp._si) version throws if any entry does not fit into aulong(resp.slong).
-
ulong
fmpq_mpoly_get_term_var_exp_ui(const fmpq_mpoly_t A, slong i, slong var, const fmpq_mpoly_ctx_t ctx)¶ -
slong
fmpq_mpoly_get_term_var_exp_si(const fmpq_mpoly_t A, slong i, slong var, const fmpq_mpoly_ctx_t ctx)¶ Return the exponent of the variable
varof the term of indexi. This function throws if the exponent does not fit into aulong(resp.slong).
-
void
fmpq_mpoly_set_term_exp_fmpz(fmpq_mpoly_t A, slong i, fmpz *const *exps, const fmpq_mpoly_ctx_t ctx)¶ -
void
fmpq_mpoly_set_term_exp_ui(fmpq_mpoly_t A, slong i, const ulong *exps, const fmpq_mpoly_ctx_t ctx)¶ Set the exponent vector of the term of index
itoexp.
-
void
fmpq_mpoly_get_term(fmpq_mpoly_t M, const fmpq_mpoly_t A, slong i, const fmpq_mpoly_ctx_t ctx)¶ Set
Mto the term of indexiinA.
-
void
fmpq_mpoly_get_term_monomial(fmpq_mpoly_t M, const fmpq_mpoly_t A, slong i, const fmpq_mpoly_ctx_t ctx)¶ Set
Mto the monomial of the term of indexiinA. The coefficient ofMwill be one.
-
void
fmpq_mpoly_push_term_fmpq_fmpz(fmpq_mpoly_t A, const fmpq_t c, fmpz *const *exp, const fmpq_mpoly_ctx_t ctx)¶ -
void
fmpq_mpoly_push_term_fmpz_fmpz(fmpq_mpoly_t A, const fmpz_t c, fmpz *const *exp, const fmpq_mpoly_ctx_t ctx)¶ -
void
fmpq_mpoly_push_term_ui_fmpz(fmpq_mpoly_t A, ulong c, fmpz *const *exp, const fmpq_mpoly_ctx_t ctx)¶ -
void
fmpq_mpoly_push_term_si_fmpz(fmpq_mpoly_t A, slong c, fmpz *const *exp, const fmpq_mpoly_ctx_t ctx)¶ -
void
fmpq_mpoly_push_term_fmpq_ui(fmpq_mpoly_t A, const fmpq_t c, const ulong *exp, const fmpq_mpoly_ctx_t ctx)¶ -
void
fmpq_mpoly_push_term_fmpz_ui(fmpq_mpoly_t A, const fmpz_t c, const ulong *exp, const fmpq_mpoly_ctx_t ctx)¶ -
void
fmpq_mpoly_push_term_ui_ui(fmpq_mpoly_t A, ulong c, const ulong *exp, const fmpq_mpoly_ctx_t ctx)¶ -
void
fmpq_mpoly_push_term_si_ui(fmpq_mpoly_t A, slong c, const ulong *exp, const fmpq_mpoly_ctx_t ctx)¶ Append a term to
Awith coefficientcand exponent vectorexp. This function should run in constant average time if the terms pushed have bounded denominator.
-
void
fmpq_mpoly_reduce(fmpq_mpoly_t A, const fmpq_mpoly_ctx_t ctx)¶ Factor out necessary content from
A->zpolyso that it is reduced. If the terms ofAwere nonzero and sorted with distinct exponents to begin with, the result will be in canonical form.
-
void
fmpq_mpoly_sort_terms(fmpq_mpoly_t A, const fmpq_mpoly_ctx_t ctx)¶ Sort the internal
A->zpolyinto the canonical ordering dictated by the ordering inctx. This function does not combine like terms, nor does it delete terms with coefficient zero, nor does it reduce.
-
void
fmpq_mpoly_combine_like_terms(fmpq_mpoly_t A, const fmpq_mpoly_ctx_t ctx)¶ Combine adjacent like terms in the internal
A->zpolyand then factor out content via a call tofmpq_mpoly_reduce(). If the terms ofAwere sorted to begin with, the result will be in canonical form.
-
void
fmpq_mpoly_reverse(fmpq_mpoly_t A, const fmpq_mpoly_t B, const fmpq_mpoly_ctx_t ctx)¶ Set
Ato the reversal ofB.
Random generation¶
-
void
fmpq_mpoly_randtest_bound(fmpq_mpoly_t A, flint_rand_t state, slong length, mp_limb_t coeff_bits, ulong exp_bound, const fmpq_mpoly_ctx_t ctx)¶ Generate a random polynomial with length up to
lengthand exponents in the range[0, exp_bound - 1]. The exponents of each variable are generated by calls ton_randint(state, exp_bound).
-
void
fmpq_mpoly_randtest_bounds(fmpq_mpoly_t A, flint_rand_t state, slong length, mp_limb_t coeff_bits, ulong *exp_bounds, const fmpq_mpoly_ctx_t ctx)¶ Generate a random polynomial with length up to
lengthand exponents in the range[0, exp_bounds[i] - 1]. The exponents of the variable of indexiare generated by calls ton_randint(state, exp_bounds[i]).
-
void
fmpq_mpoly_randtest_bits(fmpq_mpoly_t A, flint_rand_t state, slong length, mp_limb_t coeff_bits, mp_limb_t exp_bits, const fmpq_mpoly_ctx_t ctx)¶ Generate a random polynomial with length up to the given length and exponents whose packed form does not exceed the given bit count.
The parameter
coeff_bitsto the three functionsfmpq_mpoly_randtest_{bound|bounds|bits}is merely a suggestion for the approximate bit count of the resulting coefficients.
Addition/Subtraction¶
-
void
fmpq_mpoly_add_fmpq(fmpq_mpoly_t A, const fmpq_mpoly_t B, const fmpq_t c, const fmpq_mpoly_ctx_t ctx)¶ -
void
fmpq_mpoly_add_fmpz(fmpq_mpoly_t A, const fmpq_mpoly_t B, const fmpz_t c, const fmpq_mpoly_ctx_t ctx)¶ -
void
fmpq_mpoly_add_ui(fmpq_mpoly_t A, const fmpq_mpoly_t B, ulong c, const fmpq_mpoly_ctx_t ctx)¶ -
void
fmpq_mpoly_add_si(fmpq_mpoly_t A, const fmpq_mpoly_t B, slong c, const fmpq_mpoly_ctx_t ctx)¶ Set
AtoBplusc.
-
void
fmpq_mpoly_sub_fmpq(fmpq_mpoly_t A, const fmpq_mpoly_t B, const fmpq_t c, const fmpq_mpoly_ctx_t ctx)¶ -
void
fmpq_mpoly_sub_fmpz(fmpq_mpoly_t A, const fmpq_mpoly_t B, const fmpz_t c, const fmpq_mpoly_ctx_t ctx)¶ -
void
fmpq_mpoly_sub_ui(fmpq_mpoly_t A, const fmpq_mpoly_t B, ulong c, const fmpq_mpoly_ctx_t ctx)¶ -
void
fmpq_mpoly_sub_si(fmpq_mpoly_t A, const fmpq_mpoly_t B, slong c, const fmpq_mpoly_ctx_t ctx)¶ Set
AtoBminusc.
-
void
fmpq_mpoly_add(fmpq_mpoly_t A, const fmpq_mpoly_t B, const fmpq_mpoly_t C, const fmpq_mpoly_ctx_t ctx)¶ Set
AtoBplusC.
-
void
fmpq_mpoly_sub(fmpq_mpoly_t A, const fmpq_mpoly_t B, const fmpq_mpoly_t C, const fmpq_mpoly_ctx_t ctx)¶ Set
AtoBminusC.
Scalar operations¶
-
void
fmpq_mpoly_neg(fmpq_mpoly_t A, const fmpq_mpoly_t B, const fmpq_mpoly_ctx_t ctx)¶ Set
Ato \(-\).
-
void
fmpq_mpoly_scalar_mul_fmpq(fmpq_mpoly_t A, const fmpq_mpoly_t B, const fmpq_t c, const fmpq_mpoly_ctx_t ctx)¶ -
void
fmpq_mpoly_scalar_mul_fmpz(fmpq_mpoly_t A, const fmpq_mpoly_t B, const fmpz_t c, const fmpq_mpoly_ctx_t ctx)¶ -
void
fmpq_mpoly_scalar_mul_ui(fmpq_mpoly_t A, const fmpq_mpoly_t B, ulong c, const fmpq_mpoly_ctx_t ctx)¶ -
void
fmpq_mpoly_scalar_mul_si(fmpq_mpoly_t A, const fmpq_mpoly_t B, slong c, const fmpq_mpoly_ctx_t ctx)¶ Set
AtoBtimes \(c\).
-
void
fmpq_mpoly_scalar_div_fmpq(fmpq_mpoly_t A, const fmpq_mpoly_t B, const fmpq_t c, const fmpq_mpoly_ctx_t ctx)¶ -
void
fmpq_mpoly_scalar_div_fmpz(fmpq_mpoly_t A, const fmpq_mpoly_t B, const fmpz_t c, const fmpq_mpoly_ctx_t ctx)¶ -
void
fmpq_mpoly_scalar_div_ui(fmpq_mpoly_t A, const fmpq_mpoly_t B, ulong c, const fmpq_mpoly_ctx_t ctx)¶ -
void
fmpq_mpoly_scalar_div_si(fmpq_mpoly_t A, const fmpq_mpoly_t B, slong c, const fmpq_mpoly_ctx_t ctx)¶ Set
AtoBdivided by \(c\).
-
void
fmpq_mpoly_make_monic(fmpq_mpoly_t A, fmpq_mpoly_t B, const fmpq_mpoly_ctx_t ctx)¶ Set
AtoBdivided by the leading coefficient ofB. This throws ifBis zero.All of these functions run quickly if
AandBare aliased.
Differentiation/Integration¶
-
void
fmpq_mpoly_derivative(fmpq_mpoly_t A, const fmpq_mpoly_t B, slong var, const fmpq_mpoly_ctx_t ctx)¶ Set
Ato the derivative ofBwith respect to the variable of indexvar.
-
void
fmpq_mpoly_integral(fmpq_mpoly_t A, const fmpq_mpoly_t B, slong var, const fmpq_mpoly_ctx_t ctx)¶ Set
Ato the integral with the fewest number of terms ofBwith respect to the variable of indexvar.
Evaluation¶
These functions return \(0\) when the operation would imply unreasonable arithmetic.
-
int
fmpq_mpoly_evaluate_all_fmpq(fmpq_t ev, const fmpq_mpoly_t A, fmpq *const *vals, const fmpq_mpoly_ctx_t ctx)¶ Set
evthe evaluation ofAwhere the variables are replaced by the corresponding elements of the arrayvals. Return \(1\) for success and \(0\) for failure.
-
int
fmpq_mpoly_evaluate_one_fmpq(fmpq_mpoly_t A, const fmpq_mpoly_t B, slong var, const fmpq_t val, const fmpq_mpoly_ctx_t ctx)¶ Set
Ato the evaluation ofBwhere the variable of indexvaris replaced byval. Return \(1\) for success and \(0\) for failure.
-
int
fmpq_mpoly_compose_fmpq_poly(fmpq_poly_t A, const fmpq_mpoly_t B, fmpq_poly_struct *const *C, const fmpq_mpoly_ctx_t ctxB)¶ Set
Ato the evaluation ofBwhere the variables are replaced by the corresponding elements of the arrayC. The context object ofBisctxB. Return \(1\) for success and \(0\) for failure.
-
int
fmpq_mpoly_compose_fmpq_mpoly(fmpq_mpoly_t A, const fmpq_mpoly_t B, fmpq_mpoly_struct *const *C, const fmpq_mpoly_ctx_t ctxB, const fmpq_mpoly_ctx_t ctxAC)¶ Set
Ato the evaluation ofBwhere the variables are replaced by the corresponding elements of the arrayC. BothAand the elements ofChave context objectctxAC, whileBhas context objectctxB. NeitherAnorBis allowed to alias any other polynomial. Return \(1\) for success and \(0\) for failure.
-
void
fmpq_mpoly_compose_fmpq_mpoly_gen(fmpq_mpoly_t A, const fmpq_mpoly_t B, const slong *c, const fmpq_mpoly_ctx_t ctxB, const fmpq_mpoly_ctx_t ctxAC)¶ Set
Ato the evaluation ofBwhere the variable of indexiinctxBis replaced by the variable of indexc[i]inctxAC. The length of the arrayCis the number of variables inctxB. If anyc[i]is negative, the corresponding variable ofBis replaced by zero. Otherwise, it is expected thatc[i]is less than the number of variables inctxAC.
Multiplication¶
-
void
fmpq_mpoly_mul(fmpq_mpoly_t A, const fmpq_mpoly_t B, const fmpq_mpoly_t C, const fmpq_mpoly_ctx_t ctx)¶ Set
AtoBtimesC.
Powering¶
These functions return \(0\) when the operation would imply unreasonable arithmetic.
-
int
fmpq_mpoly_pow_fmpz(fmpq_mpoly_t A, const fmpq_mpoly_t B, const fmpz_t k, const fmpq_mpoly_ctx_t ctx)¶ Set
AtoBraised to the \(k\)-th power. Return \(1\) for success and \(0\) for failure.
-
int
fmpq_mpoly_pow_ui(fmpq_mpoly_t A, const fmpq_mpoly_t B, ulong k, const fmpq_mpoly_ctx_t ctx)¶ Set
AtoBraised to the \(k\)-th power. Return \(1\) for success and \(0\) for failure.
Division¶
-
int
fmpq_mpoly_divides(fmpq_mpoly_t Q, const fmpq_mpoly_t A, const fmpq_mpoly_t B, const fmpq_mpoly_ctx_t ctx)¶ If
Ais divisible byB, setQto the exact quotient and return1. Otherwise, setQto zero and return0. Note that the functionfmpq_mpoly_div()may be faster if the quotient is known to be exact.
-
void
fmpq_mpoly_div(fmpq_mpoly_t Q, const fmpq_mpoly_t A, const fmpq_mpoly_t B, const fmpq_mpoly_ctx_t ctx)¶ Set
Qto the quotient ofAbyB, discarding the remainder.
-
void
fmpq_mpoly_divrem(fmpq_mpoly_t Q, fmpq_mpoly_t R, const fmpq_mpoly_t A, const fmpq_mpoly_t B, const fmpq_mpoly_ctx_t ctx)¶ Set
QandRto the quotient and remainder ofAdivided byB.
-
void
fmpq_mpoly_divrem_ideal(fmpq_mpoly_struct **Q, fmpq_mpoly_t R, const fmpq_mpoly_t A, fmpq_mpoly_struct *const *B, slong len, const fmpq_mpoly_ctx_t ctx)¶ This function is as per
fmpq_mpoly_divrem()except that it takes an array of divisor polynomialsBand it returns an array of quotient polynomialsQ. The number of divisor (and hence quotient) polynomials, is given bylen.
Greatest Common Divisor¶
-
void
fmpq_mpoly_content(fmpq_t g, const fmpq_mpoly_t A, const fmpq_mpoly_ctx_t ctx)¶ Set
gto the (nonnegative) gcd of the coefficients ofA.
-
void
fmpq_mpoly_term_content(fmpq_mpoly_t M, const fmpq_mpoly_t A, const fmpq_mpoly_ctx_t ctx)¶ Set
Mto the GCD of the terms ofA. IfAis zero,Mwill be zero. Otherwise,Mwill be a monomial with coefficient one.
-
int
fmpq_mpoly_gcd(fmpq_mpoly_t G, const fmpq_mpoly_t A, const fmpq_mpoly_t B, const fmpq_mpoly_ctx_t ctx)¶ -
int
fmpq_mpoly_gcd_threaded(fmpq_mpoly_t G, const fmpq_mpoly_t A, const fmpq_mpoly_t B, const fmpq_mpoly_ctx_t ctx, slong thread_limit)¶ Try to set
Gto the monic GCD ofAandB. The GCD of zero and zero is defined to be zero. If the return is1the function was successful. Otherwise the return is0andGis left untouched.
-
int
fmpq_mpoly_gcd_cofactors(fmpq_mpoly_t G, fmpq_mpoly_t Abar, fmpq_mpoly_t Bbar, const fmpq_mpoly_t A, const fmpq_mpoly_t B, const fmpq_mpoly_ctx_t ctx)¶ Do the operation of
fmpq_mpoly_gcd()and also computeAbar = A/GandBbar = B/Gif successful.
Univariate Functions¶
An
fmpq_mpoly_univar_tholds a univariate polynomial in some main variable withfmpq_mpoly_tcoefficients in the remaining variables. These functions are useful when one wants to rewrite an element of \(\mathbb{Q}[x_1, \dots, x_m]\) as an element of \((\mathbb{Q}[x_1, \dots, x_{v-1}, x_{v+1}, \dots, x_m])[x_v]\) and vise versa.
-
void
fmpq_mpoly_univar_init(fmpq_mpoly_univar_t A, const fmpq_mpoly_ctx_t ctx)¶ Initialize \(A\).
-
void
fmpq_mpoly_univar_clear(fmpq_mpoly_univar_t A, const fmpq_mpoly_ctx_t ctx)¶ Clear \(A\).
-
void
fmpq_mpoly_univar_swap(fmpq_mpoly_univar_t A, fmpq_mpoly_univar_t B, const fmpq_mpoly_ctx_t ctx)¶ Swap \(A\) and \(B\).
-
void
fmpq_mpoly_to_univar(fmpq_mpoly_univar_t A, const fmpq_mpoly_t B, slong var, const fmpq_mpoly_ctx_t ctx)¶ Set
Ato a univariate form ofBby pulling out the variable of indexvar. The coefficients ofAwill still belong to the contentctxbut will not depend on the variable of indexvar.
-
void
fmpq_mpoly_from_univar(fmpq_mpoly_t A, const fmpq_mpoly_univar_t B, slong var, const fmpq_mpoly_ctx_t ctx)¶ Set
Ato the normal form ofBby putting in the variable of indexvar. This function is undefined if the coefficients ofBdepend on the variable of indexvar.
-
int
fmpq_mpoly_univar_degree_fits_si(const fmpq_mpoly_univar_t A, const fmpq_mpoly_ctx_t ctx)¶ Return \(1\) if the degree of
Awith respect to the main variable fits anslong. Otherwise, return \(0\).
-
slong
fmpq_mpoly_univar_length(const fmpq_mpoly_univar_t A, const fmpq_mpoly_ctx_t ctx)¶ Return the number of terms in
Awith respect to the main variable.
-
slong
fmpq_mpoly_univar_get_term_exp_si(fmpq_mpoly_univar_t A, slong i, const fmpq_mpoly_ctx_t ctx)¶ Return the exponent of the term of index
iofA.
-
void
fmpq_mpoly_univar_get_term_coeff(fmpq_mpoly_t c, const fmpq_mpoly_univar_t A, slong i, const fmpq_mpoly_ctx_t ctx)¶ -
void
fmpq_mpoly_univar_swap_term_coeff(fmpq_mpoly_t c, fmpq_mpoly_univar_t A, slong i, const fmpq_mpoly_ctx_t ctx)¶ Set (resp. swap)
cto (resp. with) the coefficient of the term of indexiofA.