fmpq_mpoly.h – multivariate polynomials over the rational numbers¶
The exponents follow the
mpoly
interface. No references to the coefficients are available.
Types, macros and constants¶
-
fmpq_mpoly_ctx_struct
¶ Context structure for
fmpq_mpoly
.
-
fmpq_mpoly_ctx_t
¶ An array of length 1 of
fmpq_mpoly_ctx_struct
.
-
fmpq_mpoly_struct
¶ A structure holding a multivariate rational polynomial. It is implemented as a
fmpq_t
holding the content of the polynomial and a primitive integer polynomial.
-
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_DEGLEX
andORD_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
A
for 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
A
for use with the given an initialised context object. Its value is set to zero. It is allocated with space foralloc
terms and at leastMPOLY_MIN_BITS
bits for the exponents.
-
void
fmpq_mpoly_init3
(fmpq_mpoly_t A, slong alloc, flint_bitcnt_t bits, const fmpq_mpoly_ctx_t ctx)¶ Initialise
A
for use with the given an initialised context object. Its value is set to zero. It is allocated with space foralloc
terms andbits
bits for the exponents.
-
void
fmpq_mpoly_fit_length
(fmpq_mpoly_t A, slong len, const fmpq_mpoly_ctx_t ctx)¶ Ensure that
A
has space for at leastlen
terms.
-
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
A
have at leastbits
bits.
-
void
fmpq_mpoly_realloc
(fmpq_mpoly_t A, slong alloc, const fmpq_mpoly_ctx_t ctx)¶ Reallocate
A
to have space foralloc
terms. 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
x
start with the variable of most significance at index0
. Ifx
isNULL
, 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
A
tofile
.
-
int
fmpq_mpoly_print_pretty
(const fmpq_mpoly_t A, const char ** x, const fmpq_mpoly_ctx_t ctx)¶ Print a string representing
A
tostdout
.
-
int
fmpq_mpoly_set_str_pretty
(fmpq_mpoly_t A, const char * str, const char ** x, const fmpq_mpoly_ctx_t ctx)¶ Set
A
to the polynomial in the null-terminates stringstr
given an arrayx
of variable strings. If parsingstr
fails,A
is set to zero, and-1
is returned. Otherwise,0
is 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
A
to the variable of indexvar
, wherevar = 0
corresponds 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
1
ifA
is equal to the \(var\)-th generator, otherwise return0
. If \(var < 0\), return1
if 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
A
toB
.
-
int
fmpq_mpoly_equal
(fmpq_mpoly_t A, const fmpq_mpoly_t B, const fmpq_mpoly_ctx_t ctx)¶ Return
1
ifA
is equal toB
, else return0
.
-
void
fmpq_mpoly_swap
(fmpq_mpoly_t A, fmpq_mpoly_t B, const fmpq_mpoly_ctx_t ctx)¶ Efficiently swap
A
andB
.
Constants¶
-
int
fmpq_mpoly_is_fmpq
(const fmpq_mpoly_t A, const fmpq_mpoly_ctx_t ctx)¶ Return
1
ifA
is 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
A
is a constant, setc
to this constant. This function throws ifA
is 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
A
to the constantc
.
-
void
fmpq_mpoly_zero
(fmpq_mpoly_t A, const fmpq_mpoly_ctx_t ctx)¶ Set
A
to the constant0
.
-
void
fmpq_mpoly_one
(fmpq_mpoly_t A, const fmpq_mpoly_ctx_t ctx)¶ Set
A
to 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
1
ifA
is equal to the constantc
, else return0
.
-
int
fmpq_mpoly_is_zero
(const fmpq_mpoly_t A, const fmpq_mpoly_ctx_t ctx)¶ Return
1
ifA
is equal to the constant0
, else return0
.
-
int
fmpq_mpoly_is_one
(const fmpq_mpoly_t A, const fmpq_mpoly_ctx_t ctx)¶ Return
1
ifA
is 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
1
if the degrees ofA
with 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
degs
to the degrees ofA
with respect to each variable. IfA
is 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
deg
to the degree ofA
with respect to the variable of indexvar
. IfA
is 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
1
if the total degree ofA
fits 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
tdeg
to the total degree ofA
. IfA
is 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
d
to 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
M
is a monomial, setc
to the coefficient of the corresponding monomial inA
. This function thows ifM
is 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
M
is a monomial, set the coefficient of the corresponding monomial inA
toc
. This function thows ifM
is 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
c
to 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
exp
toc
.
-
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
C
to the coefficient ofA
with respect to the variables invars
with powers in the corresponding arrayexps
. Bothvars
andexps
point to array of lengthlength
. It is assumed that \(0 < length \le nvars(A)\) and that the variables invars
are 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 ofA
is greater than (resp. less than, same as) the monomial ofB
.A
andB
should 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_mpoly
module, 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
1
ifA
is in canonical form. Otherwise, return0
. Anfmpq_mpoly_t
is represented as the product of anfmpq_t content
and anfmpz_mpoly_t zpoly
. The representation is considered canonical when either (1) bothcontent
andzpoly
are zero, or (2) bothcontent
andzpoly
are nonzero and canonical andzpoly
is reduced. A nonzerozpoly
is 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
A
tonew_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
1
if 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
exp
to 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
var
of 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
i
toexp
.
-
void
fmpq_mpoly_get_term
(fmpq_mpoly_t M, const fmpq_mpoly_t A, slong i, const fmpq_mpoly_ctx_t ctx)¶ Set
M
to the term of indexi
inA
.
-
void
fmpq_mpoly_get_term_monomial
(fmpq_mpoly_t M, const fmpq_mpoly_t A, slong i, const fmpq_mpoly_ctx_t ctx)¶ Set
M
to the monomial of the term of indexi
inA
. The coefficient ofM
will 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
A
with coefficientc
and 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->zpoly
so that it is reduced. If the terms ofA
were 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->zpoly
into 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->zpoly
and then factor out content via a call tofmpq_mpoly_reduce()
. If the terms ofA
were 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
A
to 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
length
and 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
length
and exponents in the range[0, exp_bounds[i] - 1]
. The exponents of the variable of indexi
are 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_bits
to 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
A
toB
plusc
.
-
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
A
toB
minusc
.
-
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
A
toB
plusC
.
-
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
A
toB
minusC
.
Scalar operations¶
-
void
fmpq_mpoly_neg
(fmpq_mpoly_t A, const fmpq_mpoly_t B, const fmpq_mpoly_ctx_t ctx)¶ Set
A
to \(-\).
-
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
A
toB
times \(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
A
toB
divided by \(c\).
-
void
fmpq_mpoly_make_monic
(fmpq_mpoly_t A, fmpq_mpoly_t B, const fmpq_mpoly_ctx_t ctx)¶ Set
A
toB
divided by the leading coefficient ofB
. This throws ifB
is zero.All of these functions run quickly if
A
andB
are 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
A
to the derivative ofB
with 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
A
to the integral with the fewest number of terms ofB
with 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
ev
the evaluation ofA
where 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
A
to the evaluation ofB
where the variable of indexvar
is 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
A
to the evaluation ofB
where the variables are replaced by the corresponding elements of the arrayC
. The context object ofB
isctxB
. 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
A
to the evaluation ofB
where the variables are replaced by the corresponding elements of the arrayC
. BothA
and the elements ofC
have context objectctxAC
, whileB
has context objectctxB
. NeitherA
norB
is 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
A
to the evaluation ofB
where the variable of indexi
inctxB
is replaced by the variable of indexc[i]
inctxAC
. The length of the arrayC
is the number of variables inctxB
. If anyc[i]
is negative, the corresponding variable ofB
is 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
A
toB
timesC
.
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
A
toB
raised 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
A
toB
raised 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
A
is divisible byB
, setQ
to the exact quotient and return1
. Otherwise, setQ
to 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
Q
to the quotient ofA
byB
, 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
Q
andR
to the quotient and remainder ofA
divided 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 polynomialsB
and 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
g
to 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
M
to the GCD of the terms ofA
. IfA
is zero,M
will be zero. Otherwise,M
will 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
G
to the monic GCD ofA
andB
. The GCD of zero and zero is defined to be zero. If the return is1
the function was successful. Otherwise the return is0
andG
is 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/G
andBbar = B/G
if successful.
Univariate Functions¶
An
fmpq_mpoly_univar_t
holds a univariate polynomial in some main variable withfmpq_mpoly_t
coefficients 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
A
to a univariate form ofB
by pulling out the variable of indexvar
. The coefficients ofA
will still belong to the contentctx
but 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
A
to the normal form ofB
by putting in the variable of indexvar
. This function is undefined if the coefficients ofB
depend 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
A
with 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
A
with 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
i
ofA
.
-
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)
c
to (resp. with) the coefficient of the term of indexi
ofA
.