Basic Polynomial Algebra Subprograms (BPAS)
v. 1.791
|
A multivariate polynomial with Integer coefficients using a sparse representation. More...
#include <mzpolynomial.hpp>
Public Member Functions | |
SparseMultivariateIntegerPolynomial | subresultantGCD (const SparseMultivariateIntegerPolynomial &q) const |
std::vector< SparseMultivariateIntegerPolynomial > | subresultantChain (const SparseMultivariateIntegerPolynomial &q, int filled=0) const |
SparseMultivariateIntegerPolynomial | resultant (const SparseMultivariateIntegerPolynomial &q) const |
SparseMultivariateIntegerPolynomial () | |
Construct a multivariate polynomial. More... | |
SparseMultivariateIntegerPolynomial (int v) | |
Construct a multivariate polynomial with specific number of variables. More... | |
SparseMultivariateIntegerPolynomial (const Symbol &x) | |
htop More... | |
SparseMultivariateIntegerPolynomial (const std::string &str) | |
Construct a polynomial by parsing the string str. | |
SparseMultivariateIntegerPolynomial (const SparseMultivariateIntegerPolynomial &b) | |
Copy Constructor. More... | |
SparseMultivariateIntegerPolynomial (SparseMultivariateIntegerPolynomial &&b) | |
Move Constructor. More... | |
SparseMultivariateIntegerPolynomial (const SparseMultivariateRationalPolynomial &b) | |
Create a SMZP from an SMQP. | |
SparseMultivariateIntegerPolynomial (const Integer &r, int nvar=0) | |
Create a SMZP from an Integer. | |
SparseMultivariateIntegerPolynomial (const RationalNumber &r, int nvar=0) | |
Create a SMZP from a RationalNumber. | |
SparseMultivariateIntegerPolynomial (const DenseUnivariateIntegerPolynomial &p) | |
Create a SMZP from a univariate rational polynomial. More... | |
SparseMultivariateIntegerPolynomial (const SparseUnivariatePolynomial< SparseMultivariateIntegerPolynomial > &s) | |
Construct from a SUP<SMZP> polynomial such that the resulting SMZP has main variable equal to the variable of s. More... | |
~SparseMultivariateIntegerPolynomial () | |
Destroy the polynomial and underlying node memory. | |
bool | isZero () const |
Is this polynomial zero. More... | |
void | zero () |
Set this polynomial to zero. More... | |
bool | isOne () const |
Is this polynomial one. More... | |
void | one () |
Sets this polynomial to one. More... | |
bool | isNegativeOne () const |
Is this polynomial negative one. More... | |
void | negativeOne () |
Sets this polynomial to -1. More... | |
int | isConstant () const |
Determine if this polynomial encodes a constant. More... | |
SparseMultivariateIntegerPolynomial | unitCanonical (SparseMultivariateIntegerPolynomial *u, SparseMultivariateIntegerPolynomial *v) const |
Obtain the unit normal (a.k.a canonical associate) of an element. More... | |
SparseMultivariateIntegerPolynomial & | operator= (const SparseMultivariateIntegerPolynomial &b) |
Assign this polynomail to equal the specified. | |
SparseMultivariateIntegerPolynomial & | operator= (SparseMultivariateIntegerPolynomial &&b) |
Movement assignment: move b to be this polynomail. | |
SparseMultivariateIntegerPolynomial & | operator= (const Integer &r) |
Assign this polynomial to be equal to the constant ring element. | |
SparseMultivariateIntegerPolynomial | operator+ (const SparseMultivariateIntegerPolynomial &b) const |
Add two SMQP polynomials together, *this and the specified. | |
SparseMultivariateIntegerPolynomial | operator+ (SparseMultivariateIntegerPolynomial &&b) const |
SparseMultivariateIntegerPolynomial & | operator+= (const SparseMultivariateIntegerPolynomial &b) |
Add the polynomails a and b and return the sum. More... | |
SparseMultivariateIntegerPolynomial | operator- (const SparseMultivariateIntegerPolynomial &b) const |
Subtract the specified polynomail from *this. | |
SparseMultivariateIntegerPolynomial | operator- (SparseMultivariateIntegerPolynomial &&b) const |
SparseMultivariateIntegerPolynomial | operator- () const |
Subtract the polynomial b from a and return the difference. More... | |
SparseMultivariateIntegerPolynomial & | operator-= (const SparseMultivariateIntegerPolynomial &b) |
Update *this by subtracting the specified polynomial from it. | |
SparseMultivariateIntegerPolynomial | operator* (const SparseMultivariateIntegerPolynomial &b) const |
Multiply *this by the specified polynomail. | |
SparseMultivariateIntegerPolynomial | operator* (SparseMultivariateIntegerPolynomial &&b) const |
SparseMultivariateIntegerPolynomial & | operator*= (const SparseMultivariateIntegerPolynomial &b) |
Multiply the polynomials a and b, returning their product. More... | |
SparseMultivariateIntegerPolynomial | operator/ (const SparseMultivariateIntegerPolynomial &b) const |
Divide *this by the specified polynomial. | |
SparseMultivariateIntegerPolynomial | operator/ (SparseMultivariateIntegerPolynomial &&b) const |
SparseMultivariateIntegerPolynomial & | operator/= (const SparseMultivariateIntegerPolynomial &b) |
Update *this by dividing by the specified polynomial. | |
SparseMultivariateIntegerPolynomial | operator^ (long long int e) const |
Exponentiate *this by the input exponent integer. More... | |
SparseMultivariateIntegerPolynomial & | operator^= (long long int e) |
Update *this by exponentiating this to the input integer. More... | |
bool | operator== (const SparseMultivariateIntegerPolynomial &b) const |
Determine if *this is equal to the specified polynomial. More... | |
bool | operator!= (const SparseMultivariateIntegerPolynomial &b) const |
Determine if *this is not equal to the specified polynomial. More... | |
void | print (std::ostream &os) const |
Output the string representation of *this to the input ostream. | |
void | fromString (const std::string &str) |
Parse a polynomial from the string str and place it in *this. | |
SparseMultivariateIntegerPolynomial | gcd (const SparseMultivariateIntegerPolynomial &b) const |
Get GCD between *this and b. | |
SparseMultivariateIntegerPolynomial | primitiveGCD (const SparseMultivariateIntegerPolynomial &b) const |
Get the GCD between *this and b as a primitive polynomial. | |
Factors< SparseMultivariateIntegerPolynomial > | squareFree () const |
Compute squarefree factorization of *this with respect to all of its variables. | |
Factors< SparseMultivariateIntegerPolynomial > | squareFree (const std::vector< Symbol > &vars) const |
Compute squarefree factorization of *this with respect to the list of variables, vars. | |
SparseMultivariateIntegerPolynomial | squareFreePart () const |
Computes the square free part of this polynomail. More... | |
SparseMultivariateIntegerPolynomial | squareFreePart (std::vector< Symbol > &vars) const |
Computes the square free part of this polynomail. More... | |
Integer | content () const |
Get the content with respect to all variables. More... | |
SparseMultivariateIntegerPolynomial | content (const std::vector< Symbol > &v) const |
Get the content of this polynomial with respect to the variables in the input vector v. More... | |
SparseMultivariateIntegerPolynomial | primitivePart () const |
Get the primitive part with respect to all variables. More... | |
SparseMultivariateIntegerPolynomial | primitivePart (Integer &content) const |
Get the primitive part with respect to all variables. More... | |
SparseMultivariateIntegerPolynomial | primitivePart (const std::vector< Symbol > &v) const |
Get the primitive part with respect to the variables in the vector v. More... | |
SparseMultivariateIntegerPolynomial | primitivePart (const std::vector< Symbol > &v, SparseMultivariateIntegerPolynomial &content) const |
Get the primitive part with respect to the variables in the vector v. More... | |
SparseMultivariateIntegerPolynomial | initial () const |
Get the leading coefficient of *this with respect to the main variable. More... | |
Symbol | mainVariable () const |
Get the main variable. More... | |
int | mainDegree () const |
Get the degree of the main variable. More... | |
SparseMultivariateIntegerPolynomial | rank () const |
Get the rank of this polynomial. More... | |
SparseMultivariateIntegerPolynomial | head () const |
Get the head of this polynomial. More... | |
SparseMultivariateIntegerPolynomial | tail () const |
Get the tail of this polynomial. More... | |
SparseMultivariateIntegerPolynomial | separant () const |
Get the separant of this polynomial, that is, its derivative with respect to the main variable. More... | |
int | numberOfVariables () const |
Get the number of variables in this polynomial. | |
int | numberOfRingVariables () const |
Get the number of variables in this polynomial ring. | |
Integer | numberOfTerms () const |
Get the number of non-zero terms. | |
Integer | degree () const |
Total degree. | |
Integer | degree (const Symbol &) const |
Get the degree of a variable. | |
Integer | leadingCoefficient () const |
Get the leading coefficient. | |
void | setLeadingCoefficient (const Integer &it) |
Set the leading coefficient. | |
Integer | trailingCoefficient () const |
Get the trailing coefficient. | |
Integer | coefficient (int, const int *) const |
Get a coefficient, given the exponent of each variable. | |
Integer | coefficient (const std::vector< int > &v) const |
Get the coefficient of this polynomial with respect to the monomial defined by exponent vector exps. More... | |
void | setCoefficient (int, const int *, const Integer &) |
Set a coefficient, given the exponent of each variable. | |
void | setCoefficient (const std::vector< int > &v, const Integer &r) |
Set the coefficient of this polynomial for the monomial defined by exponent vector exps to r. More... | |
void | setRingVariables (const std::vector< Symbol > &) |
Set variables' names. More... | |
std::vector< Symbol > | ringVariables () const |
Get variable names of all variables available to this polynomial, even those that have zero degree. | |
std::vector< Symbol > | variables () const |
Get variable names of variables with non-zero degree;. | |
bool | isEqual (const SparseMultivariateIntegerPolynomial &b) const |
Determine if *this is equal to b. More... | |
void | differentiate (const Symbol &s, int k) |
Convert current object to its k-th derivative. More... | |
void | differentiate (const Symbol &s) |
Convert current object to its derivative. More... | |
SparseMultivariateIntegerPolynomial | derivative (const Symbol &s, int k) const |
Return k-th derivative. More... | |
SparseMultivariateIntegerPolynomial | derivative (const Symbol &s) const |
Compute derivative. More... | |
void | integrate (const Symbol &s, int k) |
Convert current object to its k-th integral. More... | |
void | integrate (const Symbol &s) |
Convert current object to its derivative. More... | |
SparseMultivariateIntegerPolynomial | integral (const Symbol &s, int k) const |
Return k-th integral. More... | |
SparseMultivariateRationalPolynomial | rationalIntegral (const Symbol &s, int k) const |
Return k-th integral. More... | |
SparseMultivariateIntegerPolynomial | integral (const Symbol &s) const |
Compute integral. More... | |
SparseMultivariateRationalPolynomial | rationalIntegral (const Symbol &s) const |
Return the integral of this, with respect to Symbol s, as a rational number polynomial. More... | |
SparseMultivariateIntegerPolynomial | evaluate (int n, const Symbol *syms, const Integer *xs) const |
Evaluate f(x) More... | |
SparseMultivariateIntegerPolynomial | evaluate (const std::vector< Symbol > &vars, const std::vector< Integer > &values) const |
Evaluate *this polynomial given the variables and their values in vars, and values. More... | |
bool | divide (const SparseMultivariateIntegerPolynomial &b, SparseMultivariateIntegerPolynomial &q, SparseMultivariateIntegerPolynomial &r) const |
Divide this by polynomial b, returning the quotient and remainder in q and r, respectively. More... | |
bool | rationalDivide (const SparseMultivariateIntegerPolynomial &b, SparseMultivariateRationalPolynomial &q, SparseMultivariateRationalPolynomial &r) const |
Divide this by polynomial b, return the quotient and remainder in q and r as rational number polynomials. More... | |
SparseMultivariateIntegerPolynomial | operator% (const SparseMultivariateIntegerPolynomial &b) const |
Get the remainder of *this divided by b. | |
SparseMultivariateIntegerPolynomial & | operator%= (const SparseMultivariateIntegerPolynomial &b) |
Update *this by setting it to the remainder of *this divided by b. | |
SparseMultivariateIntegerPolynomial | pseudoDivide (const SparseMultivariateIntegerPolynomial &b, SparseMultivariateIntegerPolynomial *quo=NULL, SparseMultivariateIntegerPolynomial *mult=NULL, bool lazy=0) const |
Pseudo divide this by b. More... | |
SparseMultivariateIntegerPolynomial | operator+ (const mpz_t r) const |
Add *this and a mpz_t. | |
SparseMultivariateIntegerPolynomial | operator+ (const mpz_class &r) const |
Add *this and the mpz_class r. | |
SparseMultivariateIntegerPolynomial | operator+ (const Integer &r) const |
SparseMultivariateIntegerPolynomial & | operator+= (const mpz_t r) |
Update *this by adding r. | |
SparseMultivariateIntegerPolynomial & | operator+= (const mpz_class &r) |
Update *this by adding the mpz_class r to it. | |
SparseMultivariateIntegerPolynomial & | operator+= (const Integer &r) |
Update *this by adding the Integer r to it. | |
SparseMultivariateIntegerPolynomial | operator- (const mpz_t r) const |
Subtract the mpz_t r from *this. | |
SparseMultivariateIntegerPolynomial | operator- (const mpz_class &r) const |
Subtract the mpz_class r from *this. | |
SparseMultivariateIntegerPolynomial | operator- (const Integer &r) const |
Subtract the Integer r from *this. | |
SparseMultivariateIntegerPolynomial & | operator-= (const mpz_t r) |
Update *this by subtracting mpz_t r. | |
SparseMultivariateIntegerPolynomial & | operator-= (const mpz_class &r) |
Update *this by subtracting mpz_class r. | |
SparseMultivariateIntegerPolynomial & | operator-= (const Integer &r) |
Update *this by subtracting Integer r. | |
SparseMultivariateIntegerPolynomial | operator* (const mpz_t r) const |
Multiply *this by mpz_t r. | |
SparseMultivariateIntegerPolynomial | operator* (const mpz_class &r) const |
Multiply *this by mpz_class r. | |
SparseMultivariateIntegerPolynomial | operator* (const Integer &r) const |
Multiply *this by Integer r. | |
SparseMultivariateIntegerPolynomial & | operator*= (const mpz_t r) |
Update *this by multiplying by mpz_t r. | |
SparseMultivariateIntegerPolynomial & | operator*= (const mpz_class &r) |
Update *this by multiplying by mpz_class r. | |
SparseMultivariateIntegerPolynomial & | operator*= (const Integer &r) |
Update *this by multiplying by Integer r. | |
SparseMultivariateIntegerPolynomial | operator/ (const mpz_t r) const |
Divide *this by mpz_t r. | |
SparseMultivariateIntegerPolynomial | operator/ (const mpz_class &r) const |
Divide *this by mpz_class r. | |
SparseMultivariateIntegerPolynomial | operator/ (const Integer &r) const |
Divide *this by Integer r. | |
SparseMultivariateIntegerPolynomial & | operator/= (const mpz_t r) |
Update *this by dividing by mpz_t r. | |
SparseMultivariateIntegerPolynomial & | operator/= (const mpz_class &r) |
Update *this by dividing by mpz_class r. | |
SparseMultivariateIntegerPolynomial & | operator/= (const Integer &r) |
Update *this by dividing by Integer r. | |
SparseMultivariateIntegerPolynomial | operator[] (int index) const |
Get the polynomial term at index. More... | |
Symbol | leadingVariable () const |
Get the leading variable, that is, the highest-order variable with positive degree of this polynomial. More... | |
Integer | leadingVariableDegree () const |
Get the degree of this polynomial w.r.t the leading variable. | |
bool | isConstantTermZero () const |
Is the contant term zero. | |
SparseMultivariateIntegerPolynomial | leadingCoefficientInVariable (const Symbol &x, int *e=NULL) const |
Get the leading coefficient w.r.t the input variable 'x'. More... | |
SparseUnivariatePolynomial< SparseMultivariateIntegerPolynomial > | convertToSUP (const Symbol &x) const |
Convert to a SUP<SMQP> given the variable 'x'. More... | |
void | negate () |
Negate all the coefficients of *this. More... | |
SparseMultivariateIntegerPolynomial | deepCopy () const |
Get a copy of this such that all underlying memory is NOT shared. More... | |
Factors< SparseMultivariateIntegerPolynomial > | factor () const |
Factors this polynomial into irreducible factors. More... | |
void | straightLineProgram () |
SLP representation of the polynomial. | |
void | printSLP (std::ostream &out=std::cout) const |
Print SLP representation. | |
void | randomPolynomial (int numvar, int nterms, unsigned long int coefBound, degree_t sparsity, bool includeNeg) |
Change *this to be a random non-zero polynomial. More... | |
void | randomPolynomial (std::vector< int > maxDegs, unsigned long int coefBound, float sparsity, bool includeNeg) |
Change *this to be a random non-zero polynomial. More... | |
ExpressionTree | convertToExpressionTree () const |
Convert *this to an ExpressionTree. More... | |
Static Public Member Functions | |
static SparseMultivariateIntegerPolynomial | interpolate (const std::vector< std::vector< Integer >> &points, const std::vector< Integer > &vals) |
Find the interpolating polynomial for the integer points and values specified by each vector, respectively. More... | |
static SparseMultivariateIntegerPolynomial | interpolate (const std::vector< std::vector< RationalNumber >> &points, const std::vector< RationalNumber > &vals) |
Find the interpolating polynomial for the rational number points and values specified by each vector, respectively. More... | |
Public Attributes | |
std::vector< SLPZRepresentation > | slp |
A multivariate polynomial with Integer coefficients using a sparse representation.
Only non-zero coefficients are encoded.
SparseMultivariateIntegerPolynomial::SparseMultivariateIntegerPolynomial | ( | ) |
Construct a multivariate polynomial.
SparseMultivariateIntegerPolynomial::SparseMultivariateIntegerPolynomial | ( | int | v | ) |
Construct a multivariate polynomial with specific number of variables.
v | Number of variables |
SparseMultivariateIntegerPolynomial::SparseMultivariateIntegerPolynomial | ( | const Symbol & | x | ) |
htop
Construct with a variable name such that f(x) = x;
x | The variable name |
SparseMultivariateIntegerPolynomial::SparseMultivariateIntegerPolynomial | ( | const SparseMultivariateIntegerPolynomial & | b | ) |
Copy Constructor.
Does not reuse underlying memory allocated by b.
b | A sparse multivariate polynomial |
SparseMultivariateIntegerPolynomial::SparseMultivariateIntegerPolynomial | ( | SparseMultivariateIntegerPolynomial && | b | ) |
Move Constructor.
b: The r-value reference polynomial.
SparseMultivariateIntegerPolynomial::SparseMultivariateIntegerPolynomial | ( | const DenseUnivariateIntegerPolynomial & | p | ) |
Create a SMZP from a univariate rational polynomial.
p | A SUZP polynomial. |
SparseMultivariateIntegerPolynomial::SparseMultivariateIntegerPolynomial | ( | const SparseUnivariatePolynomial< SparseMultivariateIntegerPolynomial > & | s | ) |
Construct from a SUP<SMZP> polynomial such that the resulting SMZP has main variable equal to the variable of s.
s | The SUP<SMZP> polynomial |
|
inlinevirtual |
Get the coefficient of this polynomial with respect to the monomial defined by exponent vector exps.
The exponent vector should be defined over all variables in the polynomial ring.
exps | the exponent vector |
Implements BPASMultivariatePolynomial< Integer, SparseMultivariateIntegerPolynomial >.
Integer SparseMultivariateIntegerPolynomial::content | ( | ) | const |
Get the content with respect to all variables.
That is, a single integer which is the GCD of all coefficients. The content here is one such that this/content is an integer polynomial with content of 1.
Moreover, the content is one such that the leading coefficient of the corresponding primitive part is positive.
SparseMultivariateIntegerPolynomial SparseMultivariateIntegerPolynomial::content | ( | const std::vector< Symbol > & | v | ) | const |
Get the content of this polynomial with respect to the variables in the input vector v.
That is, viewing the polynomial recursively such that the variables in v are the polynomial variables and all other variables belong to the coefficient ring.
In this case, the content does not necessarily make the leading coefficient of the corresponding primitive part positive.
ExpressionTree SparseMultivariateIntegerPolynomial::convertToExpressionTree | ( | ) | const |
Convert *this to an ExpressionTree.
returns the new ExpressionTree.
SparseUnivariatePolynomial<SparseMultivariateIntegerPolynomial> SparseMultivariateIntegerPolynomial::convertToSUP | ( | const Symbol & | x | ) | const |
Convert to a SUP<SMQP> given the variable 'x'.
returns the SUP<SMQP>.
SparseMultivariateIntegerPolynomial SparseMultivariateIntegerPolynomial::deepCopy | ( | ) | const |
Get a copy of this such that all underlying memory is NOT shared.
Note, any following arithmetic operations on the returned result will result in possibly making the underlying memory shared again.
|
virtual |
Return k-th derivative.
s | Symbol to differentiate with respect to |
k | Order of the k-th derivative, k > 0 |
Implements BPASMultivariatePolynomial< Integer, SparseMultivariateIntegerPolynomial >.
|
inlinevirtual |
Compute derivative.
s | Symbol to differentiate with respect to |
Implements BPASMultivariatePolynomial< Integer, SparseMultivariateIntegerPolynomial >.
|
inlinevirtual |
Convert current object to its k-th derivative.
s | Symbol to differentiate with respect to |
k | Order of the derivative, k > 0 |
Implements BPASMultivariatePolynomial< Integer, SparseMultivariateIntegerPolynomial >.
|
inlinevirtual |
Convert current object to its derivative.
s | Symbol to differentiate with respect to |
Implements BPASMultivariatePolynomial< Integer, SparseMultivariateIntegerPolynomial >.
bool SparseMultivariateIntegerPolynomial::divide | ( | const SparseMultivariateIntegerPolynomial & | b, |
SparseMultivariateIntegerPolynomial & | q, | ||
SparseMultivariateIntegerPolynomial & | r | ||
) | const |
Divide this by polynomial b, returning the quotient and remainder in q and r, respectively.
returns a boolean indicating if the division was exact.
|
inlinevirtual |
Evaluate f(x)
syms | Array of Symbols to evaluate at corresponding xs |
xs | Evaluation points |
Implements BPASMultivariatePolynomial< Integer, SparseMultivariateIntegerPolynomial >.
|
virtual |
Evaluate *this polynomial given the variables and their values in vars, and values.
vars must be a list of variables which are a (not necessarily proper) subset. vars and values should have matching indices. i.e. the values of vars[i] is values[i].
returns a new SMQP where all variables in vars have been evaluated using the values given.
Implements BPASMultivariatePolynomial< Integer, SparseMultivariateIntegerPolynomial >.
Factors<SparseMultivariateIntegerPolynomial> SparseMultivariateIntegerPolynomial::factor | ( | ) | const |
|
virtual |
Get the head of this polynomial.
That is, the initial multiplied by the rank.
returns the head.
Implements BPASRecursivelyViewedPolynomial< Integer, SparseMultivariateIntegerPolynomial >.
|
virtual |
Get the leading coefficient of *this with respect to the main variable.
returns the initial.
Implements BPASRecursivelyViewedPolynomial< Integer, SparseMultivariateIntegerPolynomial >.
SparseMultivariateIntegerPolynomial SparseMultivariateIntegerPolynomial::integral | ( | const Symbol & | s, |
int | k | ||
) | const |
Return k-th integral.
If Symbol s is not a symbol contained in this polynomial then it becomes the main variable of the result and integration proceeds as expected.
If the integral of this polynomial cannot be represented as an integer polynomial then an error occurs. See rationalIntegral().
s | Symbol to differentiate with respect to |
k | Order of the k-th derivative, k > 0 |
|
inline |
Compute integral.
s | Symbol to differentiate with respect to |
|
inline |
Convert current object to its k-th integral.
s | Symbol to differentiate with respect to |
k | Order of the derivative, k > 0 |
|
inline |
Convert current object to its derivative.
s | Symbol to differentiate with respect to |
|
static |
Find the interpolating polynomial for the integer points and values specified by each vector, respectively.
The points vector is a vector of vectors, where each element of the outer vector represents a multi-dimensional point. Each multi-dimensional point should have the same number of dimensions and in the same order.
An error will occur if the resulting interpolating polynomial cannot be represented as an integer polynomial.
returns the interpolating polynomial.
|
static |
Find the interpolating polynomial for the rational number points and values specified by each vector, respectively.
The points vector is a vector of vectors, where each element of the outer vector represents a multi-dimensional point. Each multi-dimensional point should have the same number of dimensions and in the same order.
An error will occur if the resulting interpolating polynomial cannot be represented as an integer polynomial.
returns the interpolating polynomial.
int SparseMultivariateIntegerPolynomial::isConstant | ( | ) | const |
Determine if this polynomial encodes a constant.
returns 0 if not a constant, 1 if a constant >= 0, -1 if a negative contstant.
bool SparseMultivariateIntegerPolynomial::isEqual | ( | const SparseMultivariateIntegerPolynomial & | b | ) | const |
Determine if *this is equal to b.
This takes into account the variable ordering on both poylnomials in such a way that the same polynomial under different variable orderings are NOT equal.
bool SparseMultivariateIntegerPolynomial::isNegativeOne | ( | ) | const |
Is this polynomial negative one.
returns true iff this polynomial encodes -1.
bool SparseMultivariateIntegerPolynomial::isOne | ( | ) | const |
Is this polynomial one.
return true iff this polynomial encodes 1.
bool SparseMultivariateIntegerPolynomial::isZero | ( | ) | const |
Is this polynomial zero.
returns true iff this polynomial encodes 0.
SparseMultivariateIntegerPolynomial SparseMultivariateIntegerPolynomial::leadingCoefficientInVariable | ( | const Symbol & | x, |
int * | e = NULL |
||
) | const |
Get the leading coefficient w.r.t the input variable 'x'.
Returns the leading exponent as e.
returns the coefficient as a new SMQP.
Symbol SparseMultivariateIntegerPolynomial::leadingVariable | ( | ) | const |
Get the leading variable, that is, the highest-order variable with positive degree of this polynomial.
returns the leading variable or the empty string if this polynomial has zero variables.
|
virtual |
Get the degree of the main variable.
returns the degree.
Implements BPASRecursivelyViewedPolynomial< Integer, SparseMultivariateIntegerPolynomial >.
|
inlinevirtual |
Get the main variable.
That is, the highest-ordered variable with positive degree.
returns the main variable.
Implements BPASRecursivelyViewedPolynomial< Integer, SparseMultivariateIntegerPolynomial >.
void SparseMultivariateIntegerPolynomial::negate | ( | ) |
Negate all the coefficients of *this.
Note, that due to the sharing nature of underling nodes, this may alter the Nodes of other SMQP.
void SparseMultivariateIntegerPolynomial::negativeOne | ( | ) |
Sets this polynomial to -1.
Maintains existing variable ordering.
void SparseMultivariateIntegerPolynomial::one | ( | ) |
Sets this polynomial to one.
Maintains existing variable ordering.
bool SparseMultivariateIntegerPolynomial::operator!= | ( | const SparseMultivariateIntegerPolynomial & | b | ) | const |
Determine if *this is not equal to the specified polynomial.
This takes into account the variable ordering on both poylnomials in such a way that the same polynomial under different variable orderings are NOT equal.
SparseMultivariateIntegerPolynomial& SparseMultivariateIntegerPolynomial::operator*= | ( | const SparseMultivariateIntegerPolynomial & | b | ) |
Multiply the polynomials a and b, returning their product.
Update this by multiplying by the specified polynomail.
SparseMultivariateIntegerPolynomial& SparseMultivariateIntegerPolynomial::operator+= | ( | const SparseMultivariateIntegerPolynomial & | b | ) |
Add the polynomails a and b and return the sum.
Update *this by adding the specified polynomail to it.
SparseMultivariateIntegerPolynomial SparseMultivariateIntegerPolynomial::operator- | ( | ) | const |
Subtract the polynomial b from a and return the difference.
Unary operation, return *this * -1.
bool SparseMultivariateIntegerPolynomial::operator== | ( | const SparseMultivariateIntegerPolynomial & | b | ) | const |
Determine if *this is equal to the specified polynomial.
This takes into account the variable ordering on both poylnomials in such a way that the same polynomial under different variable orderings are NOT equal.
SparseMultivariateIntegerPolynomial SparseMultivariateIntegerPolynomial::operator[] | ( | int | index | ) | const |
Get the polynomial term at index.
Returns 0 if index is beyond the number of terms in this polynomial.
SparseMultivariateIntegerPolynomial SparseMultivariateIntegerPolynomial::operator^ | ( | long long int | e | ) | const |
Exponentiate *this by the input exponent integer.
Treats negative exponents as positive.
SparseMultivariateIntegerPolynomial& SparseMultivariateIntegerPolynomial::operator^= | ( | long long int | e | ) |
Update *this by exponentiating this to the input integer.
Treats negative exponents as positive.
SparseMultivariateIntegerPolynomial SparseMultivariateIntegerPolynomial::primitivePart | ( | ) | const |
Get the primitive part with respect to all variables.
This is equivalent to this / content().
SparseMultivariateIntegerPolynomial SparseMultivariateIntegerPolynomial::primitivePart | ( | Integer & | content | ) | const |
Get the primitive part with respect to all variables.
This is equivalent to this / content().
Simultaneously returns the rational number content in the parameter content.
SparseMultivariateIntegerPolynomial SparseMultivariateIntegerPolynomial::primitivePart | ( | const std::vector< Symbol > & | v | ) | const |
Get the primitive part with respect to the variables in the vector v.
returns the primitive part.
SparseMultivariateIntegerPolynomial SparseMultivariateIntegerPolynomial::primitivePart | ( | const std::vector< Symbol > & | v, |
SparseMultivariateIntegerPolynomial & | content | ||
) | const |
Get the primitive part with respect to the variables in the vector v.
Returns the corresponding content in the content reference. returns the primitive part.
SparseMultivariateIntegerPolynomial SparseMultivariateIntegerPolynomial::pseudoDivide | ( | const SparseMultivariateIntegerPolynomial & | b, |
SparseMultivariateIntegerPolynomial * | quo = NULL , |
||
SparseMultivariateIntegerPolynomial * | mult = NULL , |
||
bool | lazy = 0 |
||
) | const |
Pseudo divide this by b.
The remainder is returned. if parameter quo is not null then the quotient is returned in quo. if parameter mult is not null then the multiplier is set to the initial of b raised to the power of degree(c, mvar(c)) - degree(b, mvar(c)) + 1.
returns the pseudo remainder.
void SparseMultivariateIntegerPolynomial::randomPolynomial | ( | int | numvar, |
int | nterms, | ||
unsigned long int | coefBound, | ||
degree_t | sparsity, | ||
bool | includeNeg | ||
) |
Change *this to be a random non-zero polynomial.
numvar: number of variables nterms: number of terms coefBound: limit on the number of bits encoding the coefficients. sparsity: succesive terms are at most sparsity away from each other includeNeg: a bool to say if coefs can be randomly negative or all positive
void SparseMultivariateIntegerPolynomial::randomPolynomial | ( | std::vector< int > | maxDegs, |
unsigned long int | coefBound, | ||
float | sparsity, | ||
bool | includeNeg | ||
) |
Change *this to be a random non-zero polynomial.
The number of variables will be equal to the size of the maxDegs vector. The term whose monomial has exponents equal to those in maxDegs is guaranteed to exist in the resulting polynomial. A sparsity of 0 produces a dense polynomial. A sparsity of 1 produces only one term; one whose monomial has exponents equal to maxDegs.
coefBound: limit on the number of bits encoding the coefficients. sparsity: a percentage of zero-terms between term with maxDegs and the constant term. includeNeg: a bool to say if coefs can be randomly negative or all positive
|
virtual |
Get the rank of this polynomial.
That is, the main variable raised to the main degree.
returns the rank.
Implements BPASRecursivelyViewedPolynomial< Integer, SparseMultivariateIntegerPolynomial >.
bool SparseMultivariateIntegerPolynomial::rationalDivide | ( | const SparseMultivariateIntegerPolynomial & | b, |
SparseMultivariateRationalPolynomial & | q, | ||
SparseMultivariateRationalPolynomial & | r | ||
) | const |
Divide this by polynomial b, return the quotient and remainder in q and r as rational number polynomials.
This differs from the normal divide function where divisibility of coefficients does not matter as the result belongs to the polynomial ring over the rational numbers.
returns a boolean indicating if the division was exact.
SparseMultivariateRationalPolynomial SparseMultivariateIntegerPolynomial::rationalIntegral | ( | const Symbol & | s, |
int | k | ||
) | const |
Return k-th integral.
If Symbol s is not a symbol contained in this polynomial then it becomes the main variable of the result and integration proceeds as expected.
This method returns a rational number polynomial and therefore works regardless of the coefficients of this polynomial.
s | Symbol to differentiate with respect to |
k | Order of the k-th derivative, k > 0 |
SparseMultivariateRationalPolynomial SparseMultivariateIntegerPolynomial::rationalIntegral | ( | const Symbol & | s | ) | const |
Return the integral of this, with respect to Symbol s, as a rational number polynomial.
s | the symbol to integrate with respect to returns the integral |
|
virtual |
Get the separant of this polynomial, that is, its derivative with respect to the main variable.
Implements BPASRecursivelyViewedPolynomial< Integer, SparseMultivariateIntegerPolynomial >.
|
inlinevirtual |
Set the coefficient of this polynomial for the monomial defined by exponent vector exps to r.
The exponent vector should be defined over all variables in the polynomial ring.
exps | the exponent vector |
r | the ring element to set as coefficient. |
Implements BPASMultivariatePolynomial< Integer, SparseMultivariateIntegerPolynomial >.
|
virtual |
Set variables' names.
This method can be used to shrink, expand, re-order, and re-name the variables of the polynomial ring in which this polynomial belongs.
Any symbol in the input vector that matches the current variables is considered a re-order. Non-matching symbols are considered a re-name and this renames is done in the order they appear by increasing index. For example: Q[x,y,z] -> Q[y,s,t] will have y reordered to be the first variable, x renamed to s, and z renamed to t.
If the size of the input vector is greater than the current number of variables then the polynomial ring is being expanded. Matching variables from this polynomial are re-ordered as they appear in the input vector. Current variables that have no match in the input vector are re-named in order of increasing index of unused variables from the input vector. For example: Q[x,y,z] -> Q[s,t,z,x] will have y named to s, t a new variable, and z and x re-ordered accordingly.
If the size of the input vector is less than the current number of variables then the polynomial ring is shrink to remove variables. Variables in the input vector that are also found to be in the current polynomial ring are matched and re-ordered as necessary.
It is invalid to remove a variable which is non-zero in this polynomial.
Implements BPASMultivariatePolynomial< Integer, SparseMultivariateIntegerPolynomial >.
SparseMultivariateIntegerPolynomial SparseMultivariateIntegerPolynomial::squareFreePart | ( | ) | const |
Computes the square free part of this polynomail.
That is, the polynomial of this divided by all square factors. This is with respect to all variables.
SparseMultivariateIntegerPolynomial SparseMultivariateIntegerPolynomial::squareFreePart | ( | std::vector< Symbol > & | vars | ) | const |
Computes the square free part of this polynomail.
That is, the polynomial of this divided by all square factors. This is with respect to all variables.
|
virtual |
Get the tail of this polynomial.
That is, This - this.head().
returns the tail.
Implements BPASRecursivelyViewedPolynomial< Integer, SparseMultivariateIntegerPolynomial >.
|
inline |
Obtain the unit normal (a.k.a canonical associate) of an element.
If either parameters u, v, are non-NULL then the units are returned such that b = ua, v = u^-1. Where b is the unit normal of a, and is the returned value.
void SparseMultivariateIntegerPolynomial::zero | ( | ) |
Set this polynomial to zero.
Maintains existing variable ordering.
|
friend |
Parse a polynomial from the in stream.
Exactly one line is parsed.