1 #ifndef _TRIANGULARSET_H_ 2 #define _TRIANGULARSET_H_ 6 #include "../Utils/TemplateHelpers.hpp" 7 #include "../Utils/SymbolHelpers.hpp" 8 #include "BPASTriangularSet.hpp" 16 extern long long unsigned int rcProfilingStart;
17 extern float primitivePartTime;
18 extern float squareFreePartTime;
19 extern float subresultantChainTime;
20 extern float zerodimensionalregularchainTime;
21 extern float pseudoDivideTime;
22 extern float normalFormTime;
24 extern float tsCopyTime;
33 typedef enum TriangularSetMode {
43 template <
class Field,
class RecursivePoly>
48 TriangularSetMode mode;
49 mpz_class characteristic;
50 std::vector<RecursivePoly>
set;
51 std::vector<Symbol> vars;
52 std::vector<Symbol> algVars;
53 std::vector<Symbol> trcVars;
56 bool stronglyNormalized;
64 void updateTriangularSetStates();
72 void updateTriangularSetStates(
const RecursivePoly& p);
79 int variableIndex(
const Symbol& s)
const;
177 TriangularSet<Field,RecursivePoly> (
const std::vector<Symbol>&& vs,
const std::vector<Symbol>&& avs,
const std::vector<Symbol>&& tvs,
const std::vector<RecursivePoly>&& ts, TriangularSetMode tsm,
const mpz_class& c);
285 return algVars.size();
294 return algVars.size();
303 return trcVars.size();
348 if (std::find(algVars.begin(),algVars.end(),s) != algVars.end())
361 return stronglyNormalized;
379 return (vars.size() - algVars.size());
388 if (!isAMemberOf(v,vars)) {
391 int vi(variableIndex(v)),varsSize(vi),algVarsSize;
392 varsSize = vars.size() - 1 - varsSize;
393 for (
int i=0; i<algVars.size(); ++i) {
394 if (variableIndex(algVars[i])>vi)
397 return (varsSize - algVarsSize);
406 return algVars.size();
496 RecursivePoly
pseudoDivide (
const RecursivePoly& p, std::vector<RecursivePoly>* quo=NULL, RecursivePoly* c=NULL)
const;
504 RecursivePoly
normalForm(
const RecursivePoly& p, std::vector<RecursivePoly>* Q=NULL)
const;
511 RecursivePoly
reduce(
const RecursivePoly& p)
const;
522 RecursivePoly
reduce(
const RecursivePoly& p, RecursivePoly& c,
bool takeMainPrimitivePart =
false,
bool onlyInDimZero =
false)
const;
548 RecursivePoly
randomTriangularSetPolynomial(std::vector<Symbol> variables,
int algVar, std::vector<Symbol> transcendentalVariables, std::vector<int> maxDegs,
unsigned long int coefBound,
double pSparsity,
bool includeNeg);
561 void randomTriangularSet(
int nVars,
int nAlgVars,
int nTrcVars,
int nTerms,
unsigned long int coefBound,
int pSparsity,
bool includeNeg);
589 inline friend std::ostream& operator<< (std::ostream& out, const TriangularSet<Field,RecursivePoly>& a) {
592 for (
int i = 0; i < a.set.size(); ++i) {
593 if (!a.set[i].isZero()) {
594 if (isNotFirst) { out <<
", "; }
614 std::vector<RecursivePoly> tsp;
615 for (
int i=0; i<
set.size(); ++i) {
616 if (!
set[i].isZero())
617 tsp.push_back(
set[i]);
A triangular set templated by a multivariate polynomial over a field.
Definition: triangularset.hpp:44
bool isEmpty() const
Copy an object derived from abstract BPASTriangularSet class to type of current object.
std::vector< Symbol > variables() const
Get the variable names in decreasing order.
Definition: triangularset.hpp:311
bool canComputeInDimensionZero(const RecursivePoly &p, bool excludeMainVariable=false) const
Test to determine whether the triangular set can be treated as zero dimensional, i.e., whether the triangular set becomes zero dimensional when all non-algebraic variables are removed and whether the polynomial p contains only algebraic variables.
std::vector< RecursivePoly > polynomials() const
Get the vector of polynoials in the triangular set.
Definition: triangularset.hpp:369
ExpressionTree convertToExpressionTree() const
Convert a triangular set to an expression tree (array of its polynomials).
Definition: triangularset.hpp:608
void display()
Display the triangular set.
TriangularSet< Field, RecursivePoly > & operator+=(const RecursivePoly &p)
Add assignment operator +=.
std::vector< Symbol > allVariables() const
Get the list of variables followed by the transcendental variables.
int codimension() const
Return the codimension of the triangular set (understood in terms of the space of (potentially algebr...
Definition: triangularset.hpp:405
int numberOfVariables() const
Get the number of variables.
Definition: triangularset.hpp:275
void upper(const Symbol &s, BPASTriangularSet< Field, RecursivePoly > &ts) const
Returns the triangular set consisting of polynomials with main variable strictly greater than s...
bool operator==(const TriangularSet< Field, RecursivePoly > &a) const
Identity operator ==.
int dimension() const
Return the dimension of the triangular set (understood in terms of the space of (potentially algebrai...
Definition: triangularset.hpp:378
An ExpressionTree encompasses various forms of data that can be expressed generically as a binary tre...
Definition: ExpressionTree.hpp:17
TriangularSet< Field, RecursivePoly > & operator=(const TriangularSet< Field, RecursivePoly > &a)
Assignment operator =.
int numberOfTranscendentalVariables() const
Get the number of transcendental variables.
Definition: triangularset.hpp:302
bool isStronglyNormalized() const
Return true if the triangular set is strongly normalized, i.e., the initals of all polynomials are in...
Definition: triangularset.hpp:360
TriangularSet< Field, RecursivePoly > operator+(const RecursivePoly &p)
Add operator +.
void makePrimitive()
Replace each polynomial of the triangular set with its primitive part.
RecursivePoly reduce(const RecursivePoly &p) const
Reduce the input polynomial modulo the triangular set.
RecursivePoly randomTriangularSetPolynomial(std::vector< Symbol > variables, int algVar, std::vector< Symbol > transcendentalVariables, int nTerms, unsigned long int coefBound, int pSparsity, bool includeNeg)
Generate a random triangular set polynomial based on its number of terms.
RecursivePoly select(const Symbol &s) const
Select a polynomial given the leading variable; if no such polynomial, 0 is returned.
int dimensionLower(Symbol v) const
Return the dimension of the triangular set lower(v) (understood in terms of the space of (potentially...
Definition: triangularset.hpp:387
bool isAlgebraic(const Symbol &s) const
Determine if the input variable s is algebraic, i.e., if the triangular set contains a polynomial wit...
Definition: triangularset.hpp:347
void lower(const Symbol &s, BPASTriangularSet< Field, RecursivePoly > &ts) const
Returns the triangular set consisting of polynomials with main variable strictly less than s...
bool isZeroDimensionalMathematically() const
Test to determine if only algebraic variables (aside from transcendentals) appear in the polynomials ...
RecursivePoly pseudoDivide(const RecursivePoly &p, std::vector< RecursivePoly > *quo=NULL, RecursivePoly *c=NULL) const
Pseudo division: return the pseudo-remainder, the pseudo-quotients and c such that c*p = ∑(q_i T_i) ...
void randomTriangularSet(int nVars, int nAlgVars, int nTrcVars, int nTerms, unsigned long int coefBound, int pSparsity, bool includeNeg)
Generate a random triangular set based on the number of terms of its polynomials. ...
void fromVector(const std::vector< ExpTreeConvert > &ringVec)
Fill this expression tree with the vector of BPASRing elements specified.
Definition: ExpressionTree.hpp:180
int numberOfAlgebraicVariables() const
Get the number of algebraic variables.
Definition: triangularset.hpp:293
An abstract class defining the interface of a triangular set.
Definition: BPASTriangularSet.hpp:14
void cutChain(const TriangularSet< Field, RecursivePoly > &T, const Symbol &v, TriangularSet< Field, RecursivePoly > &Tlv, RecursivePoly &Tv, TriangularSet< Field, RecursivePoly > &Tgv) const
Cut an input triangular set at the symbol v, returning the subchain below v, the polynomial with main...
An encapsulation of a mathematical symbol.
Definition: Symbol.hpp:23
void randomStronglyNormalizedTriangularSet(int nVars, int nAlgVars, int nTrcVars, int nTerms, unsigned long int coefBound, int pSparsity, bool includeNeg)
Generate a random strongly normalized triangular set based on the number of terms in its polynomials...
bool isConstantPolynomial(const RecursivePoly &p) const
Tests if the polynomial is constant relative to the TriangularSet, i.e., whether it is and element of...
RecursivePoly normalForm(const RecursivePoly &p, std::vector< RecursivePoly > *Q=NULL) const
Return the normalForm of the input polynomial modulo the triangular set in the sense of Groebner basi...
ExprTreeNode is a single node in the bianry tree of an ExpressionTree.
Definition: ExprTreeNode.hpp:76
std::vector< Symbol > transcendentalVariables() const
Get the transcendentalVariables variables.
Definition: triangularset.hpp:329
int size() const
Get the size of the triangular set.
Definition: triangularset.hpp:284
std::vector< Symbol > mainVariables() const
Get the algebraic variables.
Definition: triangularset.hpp:320
bool operator!=(const TriangularSet< Field, RecursivePoly > &a) const
Negated identity operator !=.