nmod_mpoly.h – multivariate polynomials over integers mod n (word-size n)¶
The exponents follow the
mpolyinterface. A coefficient may be referenced as amp_limb_t *.
Types, macros and constants¶
-
type
nmod_mpoly_ctx_struct¶ Context structure for
nmod_mpoly.
-
type
nmod_mpoly_ctx_t¶ An array of length 1 of
nmod_mpoly_ctx_struct.
-
type
nmod_mpoly_struct¶ A structure holding a multivariate polynomial over the integers modulo \(n\) for word-sized \(n\).
-
type
nmod_mpoly_t¶ An array of length 1 of
nmod_mpoly_struct.
Context object¶
-
void
nmod_mpoly_ctx_init(nmod_mpoly_ctx_t ctx, slong nvars, const ordering_t ord, mp_limb_t n)¶ Initialise a context object for a polynomial ring with the given number of variables and the given ordering. It will have coefficients modulo \(n\). Setting \(n = 0\) or \(n = 1\) will currently give undefined behavior. The possibilities for the ordering are
ORD_LEX,ORD_DEGLEXandORD_DEGREVLEX.
-
slong
nmod_mpoly_ctx_nvars(nmod_mpoly_ctx_t ctx)¶ Return the number of variables used to initialize the context.
-
ordering_t
nmod_mpoly_ctx_ord(const nmod_mpoly_ctx_t ctx)¶ Return the ordering used to initialize the context.
-
mp_limb_t
nmod_mpoly_ctx_modulus(const nmod_mpoly_ctx_t ctx)¶ Return the modulus used to initialize the context.
-
void
nmod_mpoly_ctx_clear(nmod_mpoly_ctx_t ctx)¶ Release any space allocated by an
nmod_mpoly_ctx_t.
Memory management¶
-
void
nmod_mpoly_init(nmod_mpoly_t A, const nmod_mpoly_ctx_t ctx)¶ Initialise
Afor use with the given an initialised context object. Its value is set to zero.
-
void
nmod_mpoly_init2(nmod_mpoly_t A, slong alloc, const nmod_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 exponent widths.
-
void
nmod_mpoly_init3(nmod_mpoly_t A, slong alloc, flint_bitcnt_t bits, const nmod_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
nmod_mpoly_fit_length(nmod_mpoly_t A, slong len, const nmod_mpoly_ctx_t ctx)¶ Ensure that
Ahas space for at leastlenterms.
-
void
nmod_mpoly_fit_bits(nmod_mpoly_t A, flint_bitcnt_t bits, const nmod_mpoly_ctx_t ctx)¶ Ensure that the exponent fields of
Ahave at leastbitsbits.
-
void
nmod_mpoly_realloc(nmod_mpoly_t A, slong alloc, const nmod_mpoly_ctx_t ctx)¶ Reallocate
Ato have space forallocterms. Assumes the current length of the polynomial is not greater thanalloc.
-
void
nmod_mpoly_clear(nmod_mpoly_t A, const nmod_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 *
nmod_mpoly_get_str_pretty(const nmod_mpoly_t A, const char **x, const nmod_mpoly_ctx_t ctx)¶ Return a string, which the user is responsible for cleaning up, representing
A, given an array of variable stringsx.
-
int
nmod_mpoly_fprint_pretty(FILE *file, const nmod_mpoly_t A, const char **x, const nmod_mpoly_ctx_t ctx)¶ Print a string representing
Atofile.
-
int
nmod_mpoly_print_pretty(const nmod_mpoly_t A, const char **x, const nmod_mpoly_ctx_t ctx)¶ Print a string representing
Atostdout.
-
int
nmod_mpoly_set_str_pretty(nmod_mpoly_t A, const char *str, const char **x, const nmod_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
nmod_mpoly_gen(nmod_mpoly_t A, slong var, const nmod_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
nmod_mpoly_is_gen(const nmod_mpoly_t A, slong var, const nmod_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
nmod_mpoly_set(nmod_mpoly_t A, const nmod_mpoly_t B, const nmod_mpoly_ctx_t ctx)¶ Set
AtoB.
-
int
nmod_mpoly_equal(nmod_mpoly_t A, const nmod_mpoly_t B, const nmod_mpoly_ctx_t ctx)¶ Return
1ifAis equal toB, else return0.
-
void
nmod_mpoly_swap(nmod_mpoly_t A, nmod_mpoly_t B, const nmod_mpoly_ctx_t ctx)¶ Efficiently swap
AandB.
Constants¶
-
int
nmod_mpoly_is_ui(const nmod_mpoly_t A, const nmod_mpoly_ctx_t ctx)¶ Return
1ifAis a constant, else return0.
-
ulong
nmod_mpoly_get_ui(const nmod_mpoly_t A, const nmod_mpoly_ctx_t ctx)¶ Assuming that
Ais a constant, return this constant. This function throws ifAis not a constant.
-
void
nmod_mpoly_set_ui(nmod_mpoly_t A, ulong c, const nmod_mpoly_ctx_t ctx)¶ Set
Ato the constantc.
-
void
nmod_mpoly_zero(nmod_mpoly_t A, const nmod_mpoly_ctx_t ctx)¶ Set
Ato the constant0.
-
void
nmod_mpoly_one(nmod_mpoly_t A, const nmod_mpoly_ctx_t ctx)¶ Set
Ato the constant1.
-
int
nmod_mpoly_equal_ui(const nmod_mpoly_t A, ulong c, const nmod_mpoly_ctx_t ctx)¶ Return
1ifAis equal to the constantc, else return0.
-
int
nmod_mpoly_is_zero(const nmod_mpoly_t A, const nmod_mpoly_ctx_t ctx)¶ Return
1ifAis the constant0, else return0.
-
int
nmod_mpoly_is_one(const nmod_mpoly_t A, const nmod_mpoly_ctx_t ctx)¶ Return
1ifAis the constant1, else return0.
Degrees¶
-
int
nmod_mpoly_degrees_fit_si(const nmod_mpoly_t A, const nmod_mpoly_ctx_t ctx)¶ Return
1if the degrees ofAwith respect to each variable fit into anslong, otherwise return0.
-
void
nmod_mpoly_degrees_fmpz(fmpz **degs, const nmod_mpoly_t A, const nmod_mpoly_ctx_t ctx)¶ -
void
nmod_mpoly_degrees_si(slong *degs, const nmod_mpoly_t A, const nmod_mpoly_ctx_t ctx)¶ Set
degsto the degrees ofAwith respect to each variable. IfAis zero, all degrees are set to-1.
-
void
nmod_mpoly_degree_fmpz(fmpz_t deg, const nmod_mpoly_t A, slong var, const nmod_mpoly_ctx_t ctx)¶ -
slong
nmod_mpoly_degree_si(const nmod_mpoly_t A, slong var, const nmod_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
nmod_mpoly_total_degree_fits_si(const nmod_mpoly_t A, const nmod_mpoly_ctx_t ctx)¶ Return
1if the total degree ofAfits into anslong, otherwise return0.
-
void
nmod_mpoly_total_degree_fmpz(fmpz_t tdeg, const nmod_mpoly_t A, const nmod_mpoly_ctx_t ctx)¶ -
slong
nmod_mpoly_total_degree_si(const nmod_mpoly_t A, const nmod_mpoly_ctx_t ctx)¶ Either return or set
tdegto the total degree ofA. IfAis zero, the total degree is defined to be-1.
Coefficients¶
-
ulong
nmod_mpoly_get_coeff_ui_monomial(const nmod_mpoly_t A, const nmod_mpoly_t M, const nmod_mpoly_ctx_t ctx)¶ Assuming that
Mis a monomial, return the coefficient of the corresponding monomial inA. This function thows ifMis not a monomial.
-
void
nmod_mpoly_set_coeff_ui_monomial(nmod_mpoly_t A, ulong c, const nmod_mpoly_t M, const nmod_mpoly_ctx_t ctx)¶ Assuming that
Mis a monomial, set the coefficient of the corresponding monomial inAtoc. This function thows ifMis not a monomial.
-
ulong
nmod_mpoly_get_coeff_ui_fmpz(const nmod_mpoly_t A, fmpz *const *exp, const nmod_mpoly_ctx_t ctx)¶ -
ulong
nmod_mpoly_get_coeff_ui_ui(const nmod_mpoly_t A, ulong const *exp, const nmod_mpoly_ctx_t ctx)¶ Return the coefficient of the monomial with exponent
exp.
-
void
nmod_mpoly_set_coeff_ui_fmpz(nmod_mpoly_t A, ulong c, fmpz *const *exp, nmod_mpoly_ctx_t ctx)¶ -
void
nmod_mpoly_set_coeff_ui_ui(nmod_mpoly_t A, ulong c, ulong const *exp, nmod_mpoly_ctx_t ctx)¶ Set the coefficient of the monomial with exponent
expto \(c\).
-
void
nmod_mpoly_get_coeff_vars_ui(nmod_mpoly_t C, const nmod_mpoly_t A, const slong *vars, const ulong *exps, slong length, const nmod_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 that0 < length \le nvars(A)and that the variables invarsare distinct.
Comparison¶
-
int
nmod_mpoly_cmp(const nmod_mpoly_t A, const nmod_mpoly_t B, const nmod_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 functions deal 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.
-
mp_limb_t *
nmod_mpoly_term_coeff_ref(nmod_mpoly_t A, slong i, const nmod_mpoly_ctx_t ctx)¶ Return a reference to the coefficient of index \(i\) of
A.
-
int
nmod_mpoly_is_canonical(const nmod_mpoly_t A, const nmod_mpoly_ctx_t ctx)¶ Return
1ifAis in canonical form. Otherwise, return0. To be in canonical form, all of the terms must have nonzero coefficients, and the terms must be sorted from greatest to least.
-
slong
nmod_mpoly_length(const nmod_mpoly_t A, const nmod_mpoly_ctx_t ctx)¶ Return the number of terms in
A. If the polynomial is in canonical form, this will be the number of nonzero coefficients.
-
void
nmod_mpoly_resize(nmod_mpoly_t A, slong new_length, const nmod_mpoly_ctx_t ctx)¶ Set the length of
Atonew_length. Terms are either deleted from the end, or new zero terms are appended.
-
ulong
nmod_mpoly_get_term_coeff_ui(const nmod_mpoly_t A, slong i, const nmod_mpoly_ctx_t ctx)¶ Return the coefficient of the term of index
i.
-
void
nmod_mpoly_set_term_coeff_ui(nmod_mpoly_t A, slong i, ulong c, const nmod_mpoly_ctx_t ctx)¶ Set the coefficient of the term of index
itoc.
-
int
nmod_mpoly_term_exp_fits_si(const nmod_mpoly_t A, slong i, const nmod_mpoly_ctx_t ctx)¶ -
int
nmod_mpoly_term_exp_fits_ui(const nmod_mpoly_t A, slong i, const nmod_mpoly_ctx_t ctx)¶ Return
1if all entries of the exponent vector of the term of index \(i\) fit into anslong(resp. aulong). Otherwise, return ``0.
-
void
nmod_mpoly_get_term_exp_fmpz(fmpz **exp, const nmod_mpoly_t A, slong i, const nmod_mpoly_ctx_t ctx)¶ -
void
nmod_mpoly_get_term_exp_ui(ulong *exp, const nmod_mpoly_t A, slong i, const nmod_mpoly_ctx_t ctx)¶
-
void
nmod_mpoly_get_term_exp_si(slong *exp, const nmod_mpoly_t A, slong i, const nmod_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
nmod_mpoly_get_term_var_exp_ui(const nmod_mpoly_t A, slong i, slong var, const nmod_mpoly_ctx_t ctx)¶ -
slong
nmod_mpoly_get_term_var_exp_si(const nmod_mpoly_t A, slong i, slong var, const nmod_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
nmod_mpoly_set_term_exp_fmpz(nmod_mpoly_t A, slong i, fmpz *const *exp, const nmod_mpoly_ctx_t ctx)¶ -
void
nmod_mpoly_set_term_exp_ui(nmod_mpoly_t A, slong i, const ulong *exp, const nmod_mpoly_ctx_t ctx)¶ Set the exponent of the term of index
itoexp.
-
void
nmod_mpoly_get_term(nmod_mpoly_t M, const nmod_mpoly_t A, slong i, const nmod_mpoly_ctx_t ctx)¶ Set
Mto the term of indexiinA.
-
void
nmod_mpoly_get_term_monomial(nmod_mpoly_t M, const nmod_mpoly_t A, slong i, const nmod_mpoly_ctx_t ctx)¶ Set
Mto the monomial of the term of indexiinA. The coefficient ofMwill be one.
-
void
nmod_mpoly_push_term_ui_fmpz(nmod_mpoly_t A, ulong c, fmpz *const *exp, const nmod_mpoly_ctx_t ctx)¶ -
void
nmod_mpoly_push_term_ui_ui(nmod_mpoly_t A, ulong c, const ulong *exp, const nmod_mpoly_ctx_t ctx)¶ Append a term to
Awith coefficientcand exponent vectorexp. This function runs in constant average time.
-
void
nmod_mpoly_sort_terms(nmod_mpoly_t A, const nmod_mpoly_ctx_t ctx)¶ Sort the terms of
Ainto the canonical ordering dictated by the ordering inctx. This function simply reorders the terms: It does not combine like terms, nor does it delete terms with coefficient zero. This function runs in linear time in the bit size ofA.
-
void
nmod_mpoly_combine_like_terms(nmod_mpoly_t A, const nmod_mpoly_ctx_t ctx)¶ Combine adjacent like terms in
Aand delete terms with coefficient zero. If the terms ofAwere sorted to begin with, the result will be in canonical form. This function runs in linear time in the bit size ofA.
-
void
nmod_mpoly_reverse(nmod_mpoly_t A, const nmod_mpoly_t B, const nmod_mpoly_ctx_t ctx)¶ Set
Ato the reversal ofB.
Random generation¶
-
void
nmod_mpoly_randtest_bound(nmod_mpoly_t A, flint_rand_t state, slong length, ulong exp_bound, const nmod_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
nmod_mpoly_randtest_bounds(nmod_mpoly_t A, flint_rand_t state, slong length, ulong exp_bounds, const nmod_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
nmod_mpoly_randtest_bits(nmod_mpoly_t A, flint_rand_t state, slong length, mp_limb_t exp_bits, const nmod_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.
Addition/Subtraction¶
-
void
nmod_mpoly_add_ui(nmod_mpoly_t A, const nmod_mpoly_t B, ulong c, const nmod_mpoly_ctx_t ctx)¶ Set
AtoBplusc.
-
void
nmod_mpoly_sub_ui(nmod_mpoly_t A, const nmod_mpoly_t B, ulong c, const nmod_mpoly_ctx_t ctx)¶ Set
AtoBminusc.
-
void
nmod_mpoly_add(nmod_mpoly_t A, const nmod_mpoly_t B, const nmod_mpoly_t C, const nmod_mpoly_ctx_t ctx)¶ Set
AtoBplusC.
-
void
nmod_mpoly_sub(nmod_mpoly_t A, const nmod_mpoly_t B, const nmod_mpoly_t C, const nmod_mpoly_ctx_t ctx)¶ Set
AtoBminusC.
Scalar operations¶
-
void
nmod_mpoly_neg(nmod_mpoly_t A, const nmod_mpoly_t B, const nmod_mpoly_ctx_t ctx)¶ Set
Ato \(-\).
-
void
nmod_mpoly_scalar_mul_ui(nmod_mpoly_t A, const nmod_mpoly_t B, ulong c, const nmod_mpoly_ctx_t ctx)¶ Set
AtoBtimesc.
-
void
nmod_mpoly_make_monic(nmod_mpoly_t A, nmod_mpoly_t B, const nmod_mpoly_ctx_t ctx)¶ Set
AtoBdivided by the leading coefficient ofB. This throws ifBis zero or the leading coefficient is not invertible.
Differentiation¶
-
void
nmod_mpoly_derivative(nmod_mpoly_t A, const nmod_mpoly_t B, slong idx, const nmod_mpoly_ctx_t ctx)¶ Set
Ato the derivative ofBwith respect to the variable of indexidx.
Evaluation¶
These functions return \(0\) when the operation would imply unreasonable arithmetic.
-
ulong
nmod_mpoly_evaluate_all_ui(nmod_mpoly_t A, const ulong *vals, const nmod_mpoly_ctx_t ctx)¶ Return the evaluation of
Awhere the variables are replaced by the corresponding elements of the arrayvals.
-
void
nmod_mpoly_evaluate_one_ui(nmod_mpoly_t A, const nmod_mpoly_t B, ulong var, ulong val, const nmod_mpoly_ctx_t ctx)¶ Set
Ato the evaluation ofBwhere the variable of indexvaris replaced byval.
-
int
nmod_mpoly_compose_nmod_poly(nmod_poly_t A, const nmod_mpoly_t B, nmod_poly_struct *const *C, const nmod_mpoly_ctx_t ctx)¶ 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
nmod_mpoly_compose_nmod_mpoly_geobucket(nmod_mpoly_t A, const nmod_mpoly_t B, nmod_mpoly_struct *const *C, const nmod_mpoly_ctx_t ctxB, const nmod_mpoly_ctx_t ctxAC)¶ -
int
nmod_mpoly_compose_nmod_mpoly_horner(nmod_mpoly_t A, const nmod_mpoly_t B, nmod_mpoly_struct *const *C, const nmod_mpoly_ctx_t ctxB, const nmod_mpoly_ctx_t ctxAC)¶ -
int
nmod_mpoly_compose_nmod_mpoly(nmod_mpoly_t A, const nmod_mpoly_t B, nmod_mpoly_struct *const *C, const nmod_mpoly_ctx_t ctxB, const nmod_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. Neither ofAandBis allowed to alias any other polynomial. Return \(1\) for success and \(0\) for failure. The main method attemps to perform the calculation using matrices and chooses heuristically between thegeobucketandhornermethods if needed.
-
void
nmod_mpoly_compose_nmod_mpoly_gen(nmod_mpoly_t A, const nmod_mpoly_t B, const slong *c, const nmod_mpoly_ctx_t ctxB, const nmod_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
nmod_mpoly_mul(nmod_mpoly_t A, const nmod_mpoly_t B, const nmod_mpoly_t C, const nmod_mpoly_ctx_t ctx)¶ Set
AtoBtimesC.
-
void
nmod_mpoly_mul_johnson(nmod_mpoly_t A, const nmod_mpoly_t B, const nmod_mpoly_t C, const nmod_mpoly_ctx_t ctx)¶ -
void
nmod_mpoly_mul_heap_threaded(nmod_mpoly_t A, const nmod_mpoly_t B, const nmod_mpoly_t C, const nmod_mpoly_ctx_t ctx)¶ Set
AtoBtimesCusing Johnson’s heap-based method. The first version always uses one thread.
-
int
nmod_mpoly_mul_array(nmod_mpoly_t A, const nmod_mpoly_t B, const nmod_mpoly_t C, const nmod_mpoly_ctx_t ctx)¶ -
int
nmod_mpoly_mul_array_threaded(nmod_mpoly_t A, const nmod_mpoly_t B, const nmod_mpoly_t C, const nmod_mpoly_ctx_t ctx)¶ Try to set
AtoBtimesCusing arrays. If the return is0, the operation was unsuccessful. Otherwise, it was successful, and the return is1. The first version always uses one thread.
-
int
nmod_mpoly_mul_dense(nmod_mpoly_t A, const nmod_mpoly_t B, const nmod_mpoly_t C, const nmod_mpoly_ctx_t ctx)¶ Try to set
AtoBtimes \(C\) using univariate arithmetic. If the return is0, the operation was unsuccessful. Otherwise, it was successful and the return is1.
Powering¶
These functions return \(0\) when the operation would imply unreasonable arithmetic.
-
int
nmod_mpoly_pow_fmpz(nmod_mpoly_t A, const nmod_mpoly_t B, const fmpz_t k, const nmod_mpoly_ctx_t ctx)¶ Set \(A\) to \(B\) raised to the \(k\)-th power. Return \(1\) for success and \(0\) for failure.
-
int
nmod_mpoly_pow_ui(nmod_mpoly_t A, const nmod_mpoly_t B, ulong k, const nmod_mpoly_ctx_t ctx)¶ Set \(A\) to \(B\) raised to the \(k\)-th power. Return \(1\) for success and \(0\) for failure.
Division¶
The division functions assume that the modulus is prime.
-
int
nmod_mpoly_divides(nmod_mpoly_t Q, const nmod_mpoly_t A, const nmod_mpoly_t B, const nmod_mpoly_ctx_t ctx)¶ If
Ais divisible byB, setQto the exact quotient and return1. Otherwise, setQto zero and return0. Note that the functionnmod_mpoly_divbelow may be faster if the quotient is known to be exact.
-
void
nmod_mpoly_div(nmod_mpoly_t Q, const nmod_mpoly_t A, const nmod_mpoly_t B, const nmod_mpoly_ctx_t ctx)¶ Set
Qto the quotient ofAbyB, discarding the remainder.
-
void
nmod_mpoly_divrem(nmod_mpoly_t Q, nmod_mpoly_t R, const nmod_mpoly_t A, const nmod_mpoly_t B, const nmod_mpoly_ctx_t ctx)¶ Set
QandRto the quotient and remainder ofAdivided byB.
-
void
nmod_mpoly_divrem_ideal(nmod_mpoly_struct **Q, nmod_mpoly_t R, const nmod_mpoly_t A, nmod_mpoly_struct *const *B, slong len, const nmod_mpoly_ctx_t ctx)¶ This function is as per
nmod_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.
-
int
nmod_mpoly_divides_dense(nmod_mpoly_t Q, const nmod_mpoly_t A, const nmod_mpoly_t B, const nmod_mpoly_ctx_t ctx)¶ Try to do the operation of
nmod_mpoly_dividesusing univariate arithmetic. If the return is \(-1\), the operation was unsuccessful. Otherwise, it was successful and the return is \(0\) or \(1\).
-
int
nmod_mpoly_divides_monagan_pearce(nmod_mpoly_t Q, const nmod_mpoly_t A, const nmod_mpoly_t B, const nmod_mpoly_ctx_t ctx)¶ Do the operation of
nmod_mpoly_dividesusing the algorithm of Michael Monagan and Roman Pearce.
-
int
nmod_mpoly_divides_heap_threaded(nmod_mpoly_t Q, const nmod_mpoly_t A, const nmod_mpoly_t B, const nmod_mpoly_ctx_t ctx)¶ Do the operation of
nmod_mpoly_dividesusing a heap and multiple threads. This function should only be called onceglobal_thread_poolhas been initialized.
Greatest Common Divisor¶
The greatest common divisor functions assume that the modulus is prime.
-
void
nmod_mpoly_term_content(nmod_mpoly_t M, const nmod_mpoly_t A, const nmod_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
nmod_mpoly_gcd(nmod_mpoly_t G, const nmod_mpoly_t A, const nmod_mpoly_t B, const nmod_mpoly_ctx_t ctx)¶ 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
nmod_mpoly_gcd_cofactors(nmod_mpoly_t G, nmod_mpoly_t Abar, nmod_mpoly_t Bbar, const nmod_mpoly_t A, const nmod_mpoly_t B, const nmod_mpoly_ctx_t ctx)¶ Do the operation of
nmod_mpoly_gcd()and also computeAbar = A/GandBbar = B/Gif successful.
-
int
nmod_mpoly_gcd_brown(nmod_mpoly_t G, const nmod_mpoly_t A, const nmod_mpoly_t B, const nmod_mpoly_ctx_t ctx)¶ -
int
nmod_mpoly_gcd_brown_threaded(nmod_mpoly_t G, const nmod_mpoly_t A, const nmod_mpoly_t B, const nmod_mpoly_ctx_t ctx)¶ Try to set
Gto the GCD ofAandBusing Brown’s algorithm. The first version always uses one thread.
-
int
nmod_mpoly_gcd_zippel(nmod_mpoly_t G, const nmod_mpoly_t A, const nmod_mpoly_t B, const nmod_mpoly_ctx_t ctx)¶ Try to set
Gto the GCD ofAandBusing Zipple’s interpolation algorithm to interpolate coefficients from univariate images in the most significant variable.
Univariate Functions¶
An
nmod_mpoly_univar_tholds a univariate polynomial in some main variable withnmod_mpoly_tcoefficients in the remaining variables. These functions are useful when one wants to rewrite an element of \(\mathbb{Z}/n\mathbb{Z}[x_1, \dots, x_m]\) as an element of \((\mathbb{Z}/n\mathbb{Z}[x_1, \dots, x_{v-1}, x_{v+1}, \dots, x_m])[x_v]\) and vise versa.
-
void
nmod_mpoly_univar_init(nmod_mpoly_univar_t A, const nmod_mpoly_ctx_t ctx)¶ Initialize \(A\).
-
void
nmod_mpoly_univar_clear(nmod_mpoly_univar_t A, const nmod_mpoly_ctx_t ctx)¶ Clear \(A\).
-
void
nmod_mpoly_univar_swap(nmod_mpoly_univar_t A, nmod_mpoly_univar_t B, const nmod_mpoly_ctx_t ctx)¶ Swap \(A\) and \(B\).
-
void
nmod_mpoly_to_univar(nmod_mpoly_univar_t A, const nmod_mpoly_t B, slong var, const nmod_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
nmod_mpoly_from_univar(nmod_mpoly_t A, const nmod_mpoly_univar_t B, slong var, const nmod_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
nmod_mpoly_univar_degree_fits_si(const nmod_mpoly_univar_t A, const nmod_mpoly_ctx_t ctx)¶ Return \(1\) if the degree of
Awith respect to the main variable fits anslong. Otherwise, return \(0\).
-
slong
nmod_mpoly_univar_length(const nmod_mpoly_univar_t A, const nmod_mpoly_ctx_t ctx)¶ Return the number of terms in
Awith respect to the main variable.
-
slong
nmod_mpoly_univar_get_term_exp_si(nmod_mpoly_univar_t A, slong i, const nmod_mpoly_ctx_t ctx)¶ Return the exponent of the term of index
iofA.
-
void
nmod_mpoly_univar_get_term_coeff(nmod_mpoly_t c, const nmod_mpoly_univar_t A, slong i, const nmod_mpoly_ctx_t ctx)¶ -
void
nmod_mpoly_univar_swap_term_coeff(nmod_mpoly_t c, nmod_mpoly_univar_t A, slong i, const nmod_mpoly_ctx_t ctx)¶ Set (resp. swap)
cto (resp. with) the coefficient of the term of indexiofA.
Internal Functions¶
-
void
nmod_mpoly_pow_rmul(nmod_mpoly_t A, const nmod_mpoly_t B, ulong k, const nmod_mpoly_ctx_t ctx)¶ Set \(A\) to \(B\) raised to the \(k\)-th power using repeated multiplications.
-
void
nmod_mpoly_div_monagan_pearce(nmod_mpoly_t polyq, const nmod_mpoly_t poly2, const nmod_mpoly_t poly3, const nmod_mpoly_ctx_t ctx)¶ Set
polyqto the quotient ofpoly2bypoly3, discarding the remainder (with notional remainder coefficients reduced modulo the leading coefficient ofpoly3). Implements “Polynomial division using dynamic arrays, heaps and packed exponents” by Michael Monagan and Roman Pearce. This function is exceptionally efficient if the division is known to be exact.
-
void
nmod_mpoly_divrem_monagan_pearce(nmod_mpoly_t q, nmod_mpoly_t r, const nmod_mpoly_t poly2, const nmod_mpoly_t poly3, const nmod_mpoly_ctx_t ctx)¶ Set
polyqandpolyrto the quotient and remainder ofpoly2divided bypoly3, (with remainder coefficients reduced modulo the leading coefficient ofpoly3). Implements “Polynomial division using dynamic arrays, heaps and packed exponents” by Michael Monagan and Roman Pearce.
-
void
nmod_mpoly_divrem_ideal_monagan_pearce(nmod_mpoly_struct **q, nmod_mpoly_t r, const nmod_mpoly_t poly2, nmod_mpoly_struct *const *poly3, slong len, const nmod_mpoly_ctx_t ctx)¶ This function is as per
nmod_mpoly_divrem_monagan_pearceexcept that it takes an array of divisor polynomialspoly3, and it returns an array of quotient polynomialsq. The number of divisor (and hence quotient) polynomials, is given bylen. The function computes polynomials \(q_i = q[i]\) such thatpoly2is \(r + \sum_{i=0}^{\mbox{len - 1}} q_ib_i\), where \(b_i =\)poly3[i].