1 #ifndef _SMZPALTARRAY_H_ 2 #define _SMZPALTARRAY_H_ 4 #include "../Ring/Integer.hpp" 5 #include "../polynomial.h" 6 #include "uzpolynomial.h" 7 #include "../RingPolynomial/upolynomial.h" 8 #include "../RationalNumberPolynomial/mrpolynomial.h" 9 #include "SMZP_CppSupport.hpp" 10 #include "SMZP_Support.h" 11 #include "SMZP_Support_Test.h" 12 #include "SMZP_Support_Recursive.h" 14 #include "../ExpressionTree/ExpressionTree.hpp" 15 #include "../DataStructures/Factors.hpp" 17 #if defined(WITH_BLAD) 18 #include "../BLADInterface/bladinterface.h" 53 if (type == 0 || type == 1 || type == 4) {
61 if (type == 0 || type == 1) {
74 mutable AltArrZ_t* poly;
102 void reorderVarsInPlace(
int varmap[]);
107 void expandVarsInPlace(
int vars,
Symbol* newvars,
int varmap[]);
124 std::vector<SLPZRepresentation> slp;
207 static mpz_class characteristic;
208 static RingProperties properties;
262 if (mpz_cmp_si(this->poly->elems->coef, 0l) < 0) {
396 void print(std::ostream& os)
const;
573 void setLeadingCoefficient(
const Integer& it);
755 std::vector<Symbol> vecSyms;
756 std::vector<Integer> vecRats;
759 for (
int i = 0; i < n; ++i) {
760 vecSyms.push_back(syms[i]);
761 vecRats.push_back(xs[i]);
839 return (*
this + mpz_class(r));
848 return (*
this + r.get_mpz());
862 return (*
this += mpz_class(r));
882 *
this += r.get_mpz();
890 return (*
this - mpz_class(r));
902 return (*
this - r.get_mpz());
916 return (*
this -= mpz_class(r));
936 *
this -= r.get_mpz();
944 return (*
this * mpz_class(r));
956 return (*
this * r.get_mpz());
970 return (*
this *= mpz_class(r));
989 *
this *= r.get_mpz();
997 return (*
this / mpz_class(r));
1009 return (*
this / r.get_mpz());
1021 return (*
this /= mpz_class(r));
1029 mpz_set(t, r.get_mpz_t());
1043 *
this /= r.get_mpz();
1114 void printSLP(std::ostream& out = std::cout)
const;
1124 void randomPolynomial(
int numvar,
int nterms,
unsigned long int coefBound, degree_t sparsity,
bool includeNeg);
1138 void randomPolynomial(std::vector<int> maxDegs,
unsigned long int coefBound,
float sparsity,
bool includeNeg);
1152 #endif //_SMQPLINKEDLIST_H_ bool isOne() const
Is this polynomial one.
std::vector< Symbol > variables() const
Get variable names of variables with non-zero degree;.
SparseUnivariatePolynomial< SparseMultivariateRationalPolynomial > convertToSUP(const Symbol &x) const
Convert to a SUP<SMQP> given the variable 'x'.
A multivariate polynomial with Integer coefficients using a sparse representation.
Definition: mzpolynomial.hpp:71
SparseMultivariateRationalPolynomial & operator-=(const SparseMultivariateRationalPolynomial &b)
Update *this by subtracting the specified polynomial from it.
SparseMultivariateRationalPolynomial evaluate(int n, const Symbol *syms, const RationalNumber *xs) const
Evaluate f(x)
Definition: mrpolynomial.h:733
A univariate polynomial over an arbitrary BPASRing represented sparsely.
Definition: BigPrimeField.hpp:21
void setRingVariables(const std::vector< Symbol > &)
Set variables' names.
static SparseMultivariateRationalPolynomial interpolate(const std::vector< std::vector< RationalNumber >> &points, const std::vector< RationalNumber > &vals)
Find the interpolating polynomial for the points and values specified by each vector, respectively.
SparseMultivariateRationalPolynomial & operator=(const SparseMultivariateRationalPolynomial &b)
Assign this polynomail to equal the specified.
SparseMultivariateRationalPolynomial operator[](int index) const
Get the polynomial term at index.
RationalNumber coefficient(int, const int *) const
Get a coefficient, given the exponent of each variable.
A multivariate polynomial with RationalNumber coefficients represented sparely.
Definition: mrpolynomial.h:70
Factors< SparseMultivariateRationalPolynomial > factor() const
Factors this polynomial into irreducible factors.
Integer numberOfTerms() const
Get the number of non-zero terms.
void fromString(const std::string &str)
Parse a polynomial from string str and place in *this.
int numberOfRingVariables() const
Get the number of variables in this polynomial ring.
Definition: mzpolynomial.hpp:546
ExpressionTree convertToExpressionTree() const
Convert *this to an ExpressionTree.
SparseMultivariateRationalPolynomial operator/(const SparseMultivariateRationalPolynomial &b) const
Divide *this by the specified polynomial.
SparseMultivariateRationalPolynomial pseudoDivide(const SparseMultivariateRationalPolynomial &b, SparseMultivariateRationalPolynomial *quo=NULL, SparseMultivariateRationalPolynomial *mult=NULL, bool lazy=0) const
Pseudo divide this by b.
Integer leadingVariableDegree() const
Get the degree of this polynomial w.r.t the leading variable.
Definition: mzpolynomial.hpp:29
friend std::istream & operator>>(std::istream &in, SparseMultivariateRationalPolynomial &p)
Parse polynomial from in stream.
Factors< SparseMultivariateRationalPolynomial > squareFree() const
Compute squarefree factorization of *this with respect to all of its variables.
int mainDegree() const
Get the degree of the main variable.
SparseMultivariateRationalPolynomial primitiveGCD(const SparseMultivariateRationalPolynomial &b) const
Get the GCD between *this and b as a primitive polynomial.
SparseMultivariateIntegerPolynomial evaluate(int n, const Symbol *syms, const Integer *xs) const
Evaluate f(x)
Definition: mzpolynomial.hpp:754
Integer degree() const
Total degree.
void negate()
Negate all the coefficients of *this.
SparseMultivariateRationalPolynomial operator*(const SparseMultivariateRationalPolynomial &b) const
Multiply *this by the specified polynomail.
An ExpressionTree encompasses various forms of data that can be expressed generically as a binary tre...
Definition: ExpressionTree.hpp:17
bool isEqual(const SparseMultivariateRationalPolynomial &b) const
Determine if *this is equal to b.
bool operator!=(const SparseMultivariateRationalPolynomial &b) const
Determine if *this is not equal to the specified polynomial.
SparseMultivariateRationalPolynomial gcd(const SparseMultivariateRationalPolynomial &b) const
Get GCD between *this and b.
int numberOfVariables() const
Get the number of variables in this polynomial.
void straightLineProgram()
SLP representation of the polynomial.
void negativeOne()
Sets this polynomial to -1.
Data Structure for interval [a, b].
Definition: interval.h:9
SparseMultivariateIntegerPolynomial unitCanonical(SparseMultivariateIntegerPolynomial *u, SparseMultivariateIntegerPolynomial *v) const
Obtain the unit normal (a.k.a canonical associate) of an element.
Definition: mzpolynomial.hpp:257
A univariate polynomial with Integer coefficients using a dense representation.
Definition: uzpolynomial.h:13
SparseMultivariateRationalPolynomial derivative(const Symbol &s, int k) const
Return k-th derivative.
Symbol mainVariable() const
Get the main variable.
Definition: mzpolynomial.hpp:500
SparseMultivariateRationalPolynomial deepCopy() const
Get a copy of this such that all underlying memory is NOT shared.
SparseMultivariateRationalPolynomial operator+(const SparseMultivariateRationalPolynomial &b) const
Add two SMQP polynomials together, *this and the specified.
SparseMultivariateIntegerPolynomial integral(const Symbol &s) const
Compute integral.
Definition: mzpolynomial.hpp:736
std::vector< Symbol > ringVariables() const
Get variable names of all variables available to this polynomial, even those that have zero degree...
SparseMultivariateRationalPolynomial primitivePart() const
Get the primitive part with respect to all variables.
RationalNumber trailingCoefficient() const
Get the trailing coefficient.
void print(std::ostream &os) const
Output the string representation of *this to the input ostream.
SparseMultivariateRationalPolynomial & operator*=(const SparseMultivariateRationalPolynomial &b)
Multiply the polynomials a and b, returning their product.
void differentiate(const Symbol &s, int k)
Convert current object to its k-th derivative.
Definition: mzpolynomial.hpp:656
A simple data structure for encapsulating a collection of Factor elements.
Definition: Factors.hpp:95
RationalNumber leadingCoefficient() const
Get the leading coefficient.
bool divide(const SparseMultivariateRationalPolynomial &b, SparseMultivariateRationalPolynomial &q, SparseMultivariateRationalPolynomial &r) const
Divide this by polynomial b, returning the quotient and remainder in q and r, respectively.
void zero()
Set this polynomial to zero.
SparseMultivariateRationalPolynomial initial() const
Get the leading coefficient of *this with respect to the main variable.
void setCoefficient(int, const int *, const RationalNumber &)
Set a coefficient, given the exponent of each variable.
An arbitrary-precision Integer.
Definition: Integer.hpp:22
SparseMultivariateRationalPolynomial integral(const Symbol &s, int k) const
Return k-th integral.
void integrate(const Symbol &s, int k)
Convert current object to its k-th integral.
Definition: mrpolynomial.h:695
SparseMultivariateRationalPolynomial leadingCoefficientInVariable(const Symbol &x, int *e=NULL) const
Get the leading coefficient w.r.t the input variable 'x'.
void printSLP(std::ostream &out=std::cout) const
Print SLP representation.
SparseMultivariateRationalPolynomial & operator/=(const SparseMultivariateRationalPolynomial &b)
Update *this by dividing by the specified polynomial.
SparseMultivariateRationalPolynomial operator%(const SparseMultivariateRationalPolynomial &b) const
Get the remainder of *this divided by b.
SparseMultivariateRationalPolynomial operator^(long long int e) const
Exponentiate *this by the input exponent integer.
RationalNumber content() const
Get the content with respect to all variables.
void one()
Sets this polynomial to one.
SparseMultivariateRationalPolynomial rank() const
Get the rank of this polynomial.
SparseMultivariateRationalPolynomial & operator%=(const SparseMultivariateRationalPolynomial &b)
Update *this by setting it to the remainder of *this divided by b.
bool operator==(const SparseMultivariateRationalPolynomial &b) const
Determine if *this is equal to the specified polynomial.
An encapsulation of a mathematical symbol.
Definition: Symbol.hpp:23
An arbitrary-precision rational number.
Definition: RationalNumber.hpp:24
bool isNegativeOne() const
Is this polynomial negative one.
An element of the SLP of an integer polynomial.
Definition: mzpolynomial.hpp:26
void one()
Sets this polynomial to one.
Symbol leadingVariable() const
Get the leading variable, that is, the highest-order variable with positive degree of this polynomial...
SparseMultivariateRationalPolynomial head() const
Get the head of this polynomial.
bool isZero() const
Is this polynomial zero.
void integrate(const Symbol &s)
Convert current object to its derivative.
Definition: mzpolynomial.hpp:701
bool isConstantTermZero() const
Is the contant term zero.
SparseMultivariateIntegerPolynomial derivative(const Symbol &s) const
Compute derivative.
Definition: mzpolynomial.hpp:682
void integrate(const Symbol &s, int k)
Convert current object to its k-th integral.
Definition: mzpolynomial.hpp:692
void randomPolynomial(int numvar, int nterms, unsigned long int coefBound, degree_t sparsity, bool includeNeg)
Change *this to be a random non-zero polynomial.
SparseMultivariateRationalPolynomial & operator+=(const SparseMultivariateRationalPolynomial &b)
Add the polynomails a and b and return the sum.
SparseMultivariateRationalPolynomial squareFreePart() const
Computes the square free part of this polynomail.
int isConstant() const
Determine if this polynomial encodes a constant.
SparseMultivariateRationalPolynomial & operator^=(long long int e)
Update *this by exponentiating this to the input integer.
SparseMultivariateRationalPolynomial operator-() const
Subtract the polynomial b from a and return the difference.
SparseMultivariateRationalPolynomial tail() const
Get the tail of this polynomial.
void differentiate(const Symbol &s)
Convert current object to its derivative.
Definition: mzpolynomial.hpp:665
void differentiate(const Symbol &s, int k)
Convert current object to its k-th derivative.
Definition: mrpolynomial.h:659
An abstract class defining the interface of a multivariate polynomial that can be viewed recursively...
Definition: polynomial.h:166