1 #ifndef _REGULARCHAIN_H_ 2 #define _REGULARCHAIN_H_ 4 #include "regularchain_macros.hpp" 6 #include "../TriangularSet/triangularset.hpp" 7 #include "../SubResultantChain/subresultantchain.hpp" 8 #include "chainstructures.hpp" 10 #include "BPASRegularChain.hpp" 14 extern int intersectDepth;
15 extern int regularGCDDepth;
16 extern int intersectFreeDepth;
17 extern int intersectAlgebraicDepth;
18 extern int regularizeDepth;
19 extern int regularizeSingleDepth;
20 extern int extendDepth;
21 extern int cleanChainDepth;
24 extern float primitivePartTime;
25 extern float squareFreePartTime;
26 extern float subresultantChainTime;
27 extern float zerodimensionalregularchainTime;
28 extern float pseudoDivideTime;
29 extern float normalFormTime;
30 extern float removeRedundantChainsTime;
31 extern float factorTime;
33 extern float intersectTime;
34 extern float regularGCDTime;
35 extern float intersectFreeTime;
36 extern float intersectAlgebraicTime;
37 extern float regularizeTime;
38 extern float extendTime;
39 extern float cleanChainTime;
40 extern float constructChainTime;
41 extern float constructChainsTime;
42 extern float GCDFreeFactorizationTime;
43 extern float ZDIntersectTime;
44 extern float ZDRegularizeTime;
45 extern float isRegularTime;
46 extern float isInSaturatedIdealTime;
47 extern float cleanSetTime;
49 extern float tsCopyTime;
50 extern float rcCopyTime;
51 extern float zdrcCopyTime;
56 template <
class Field,
class RecursivePoly>
59 template <
class Value>
64 template <
class Field,
class RecursivePoly>
69 template<
class Field,
class RecursivePoly>
72 template<
class Field,
class RecursivePoly>
79 enum RegularChainOption {
80 ASSUME_REGULAR = 0x001,
81 ASSUME_REDUCED = 0x002,
82 ASSUME_PRIMITIVE = 0x004,
83 ASSUME_SQUAREFREE = 0x008,
84 ASSUME_ZERODIMENSIONAL = 0x010,
85 ASSUME_MAKESCHAIN = 0x020,
86 MAINTAIN_SQUAREFREE = 0x040,
87 MAINTAIN_NORMALIZED = 0x080,
88 MAINTAIN_PRIME = 0x100,
89 CONSTRUCT_FACTORIZE = 0x200,
96 template <
class Field,
class RecursivePoly>
113 int regularChainOptions = CONSTRUCT_FACTORIZE;
118 int saturatedIdealPrimeLevel;
126 void updateRegularChainStates();
134 void updateRegularChainStates(
const RecursivePoly& p);
148 RecursivePoly makeCanonical(
const RecursivePoly& p_in)
const;
157 RecursivePoly reduceMinimal(
const RecursivePoly& p)
const;
164 RecursivePoly reduceMinimalPrimitivePart(
const RecursivePoly& p)
const;
171 RecursivePoly reduceMinimalPrimitiveSquareFreePart(
const RecursivePoly& p_in)
const;
178 RecursivePoly removeZero(
const RecursivePoly& p)
const;
245 #if defined(RC_WITH_GENERATORS) && RC_WITH_GENERATORS 246 void regularizeListStream(
const RecursivePoly& p,
const std::vector<RecursivePoly>& knownRegular,
const std::vector<RecursivePoly>& unknownIfRegular,
bool lazardDecompose,
int heightBound, AsyncGenerator<PolyChainPair<RecursivePoly,
RegularChain<Field,RecursivePoly>>>& results)
const;
248 std::vector<PolyChainPair<RecursivePoly,RegularChain<Field,RecursivePoly>>> regularizeListStream(
const RecursivePoly& p,
const std::vector<RecursivePoly>& knownRegular,
const std::vector<RecursivePoly>& unknownIfRegular,
bool lazardDecompose,
int heightBound)
const;
257 void constructChain(
const RecursivePoly& p,
int options=ASSUME_REGULAR);
276 #if defined(RC_WITH_GENERATORS) && RC_WITH_GENERATORS 279 std::vector<RegularChain<Field,RecursivePoly>> constructChainsFromPoly(
const RecursivePoly& p,
bool lazardDecompose,
int heightBound,
int options=ASSUME_REGULAR)
const;
299 #if defined(RC_WITH_GENERATORS) && RC_WITH_GENERATORS 302 std::vector<RegularChain<Field,RecursivePoly>> intersectFree(
const RecursivePoly& p,
const Symbol& v,
bool lazardDecompose,
int heightBound)
const;
314 #if defined(RC_WITH_GENERATORS) && RC_WITH_GENERATORS 317 std::vector<RegularChain<Field,RecursivePoly>> intersectAlgebraic(
const RecursivePoly& p,
const RegularChain<Field,RecursivePoly>& T,
const Symbol& v,
const SubResultantChain<RecursivePoly,RecursivePoly>& src,
bool lazardDecompose,
int heightBound)
const;
330 #if defined(RC_WITH_GENERATORS) && RC_WITH_GENERATORS 341 #if defined(RC_WITH_GENERATORS) && RC_WITH_GENERATORS 342 void regularizeSingle(
const RecursivePoly& p,
bool lazardDecompose,
int heightBound, AsyncGenerator<PolyChainPair<RecursivePoly,
RegularChain<Field,RecursivePoly>>>& results)
const;
344 std::vector<PolyChainPair<RecursivePoly,RegularChain<Field,RecursivePoly>>> regularizeSingle(
const RecursivePoly& p,
bool lazardDecompose,
int heightBound)
const;
354 std::vector<RecursivePoly> GCDFreeFactorization(
const RecursivePoly& p,
int type = 2)
const;
362 std::vector<RegularChain<Field,RecursivePoly>> extend(
const RecursivePoly& p,
const Symbol& v,
bool lazardDecompose,
int heightBound)
const;
370 std::vector<RegularChain<Field,RecursivePoly>> extend(
const std::vector<RecursivePoly>& T,
const Symbol& v,
bool lazardDecompose,
int heightBound)
const;
389 #if defined(RC_WITH_GENERATORS) && RC_WITH_GENERATORS 390 void _squareFreePartInner(
const RecursivePoly& p,
const Symbol& v,
const SubResultantChain<RecursivePoly,RecursivePoly>& src,
bool lazardDecompose,
int heightBound,
int options, AsyncGenerator<
RegularChain<Field,RecursivePoly>>& results)
const;
392 std::vector<RegularChain<Field,RecursivePoly>> _squareFreePartInner(
const RecursivePoly& p,
const Symbol& v,
const SubResultantChain<RecursivePoly,RecursivePoly>& src,
bool lazardDecompose,
int heightBound,
int options)
const;
402 #if defined(RC_WITH_GENERATORS) && RC_WITH_GENERATORS 405 std::vector<RegularChain<Field,RecursivePoly>> _squareFreePart(
const RecursivePoly& p,
const Symbol& v,
bool lazardDecompose,
int heightBound,
int options)
const;
417 #if defined(RC_WITH_GENERATORS) && RC_WITH_GENERATORS 418 void _squareFreePartPolynomialInner(
const RecursivePoly& p,
const Symbol& v,
const SubResultantChain<RecursivePoly,RecursivePoly>& src,
bool lazardDecompose,
int heightBound,
int options, AsyncGenerator<PolyChainPair<RecursivePoly,
RegularChain<Field,RecursivePoly>>>& results)
const;
420 std::vector<PolyChainPair<RecursivePoly,RegularChain<Field,RecursivePoly>>> _squareFreePartPolynomialInner(
const RecursivePoly& p,
const Symbol& v,
const SubResultantChain<RecursivePoly,RecursivePoly>& src,
bool lazardDecompose,
int heightBound,
int options)
const;
431 #if defined(RC_WITH_GENERATORS) && RC_WITH_GENERATORS 434 std::vector<PolyChainPair<RecursivePoly,RegularChain<Field,RecursivePoly>>> _squareFreePartPolynomial(
const RecursivePoly& p,
const Symbol& v,
bool lazardDecompose,
int heightBound,
int options)
const;
479 #if defined(RC_WITH_GENERATORS) && RC_WITH_GENERATORS 480 void _regularGCD(
const RecursivePoly& p,
const RecursivePoly& q,
const Symbol& v,
const SubResultantChain<RecursivePoly,RecursivePoly>& S,
bool lazardDecompose,
int inputHeightBound, AsyncGenerator<PolyChainPair<RecursivePoly,
RegularChain<Field,RecursivePoly>>>& results)
const;
482 std::vector<PolyChainPair<RecursivePoly,RegularChain<Field,RecursivePoly>>> _regularGCD(
const RecursivePoly& p,
const RecursivePoly& q,
const Symbol& v,
const SubResultantChain<RecursivePoly,RecursivePoly>& src,
bool lazardDecompose =
false,
int heightBound = 0)
const;
492 #if defined(RC_WITH_GENERATORS) && RC_WITH_GENERATORS 493 void _regularize(
const RecursivePoly& p,
bool lazardDecompose,
int heightBound, AsyncGenerator<PolyChainPair<RecursivePoly,
RegularChain<Field,RecursivePoly>>>& results)
const;
495 std::vector<PolyChainPair<RecursivePoly,RegularChain<Field,RecursivePoly>>> _regularize(
const RecursivePoly& p,
bool lazardDecompose,
int heightBound)
const;
505 #if defined(RC_WITH_GENERATORS) && RC_WITH_GENERATORS 508 std::vector<RegularChain<Field,RecursivePoly>> _intersect(
const RecursivePoly& p,
bool lazardDecompose,
int inputHeightBound)
const;
518 #if defined(RC_WITH_GENERATORS) && RC_WITH_GENERATORS 521 std::vector<RegularChain<Field,RecursivePoly>> _triangularize(
const std::vector<RecursivePoly>& polys, std::vector<
RegularChain<Field,RecursivePoly>>& chains,
bool lazardDecompose,
int heightBound)
const;
524 std::vector<RegularChain<Field,RecursivePoly>> _triangularizeByTasks(std::vector<RecursivePoly>& polys,
bool lazardDecompose,
int heightBound)
const;
526 friend void triangularizeTask<Field,RecursivePoly>(
const RegularChain<Field, RecursivePoly>& rc, std::vector<RecursivePoly>& polys,
bool lazardDecompose,
int heightBound, TaskScheduler* tasks, std::shared_ptr<SynchronizedWriteVector<RegularChain<Field,RecursivePoly>>> results);
530 std::vector<RegularChain<Field,RecursivePoly>> intersectTrivial(
const RecursivePoly& p)
const;
532 bool isIntersectionTrivial(
const RecursivePoly& p, RecursivePoly& pReduced)
const;
534 std::vector<PolyChainPair<RecursivePoly,RegularChain<Field,RecursivePoly>>> regularizeTrivial(
const RecursivePoly& p,
const RecursivePoly& pReduced)
const;
536 bool isRegularizationTrivial(
const RecursivePoly& p, RecursivePoly& pReduced)
const;
538 RecursivePoly moduloPolysWithConstantInitial(
const RecursivePoly& p_in)
const;
540 std::vector<RecursivePoly> factorPolynomial(
const RecursivePoly& p)
const;
649 RegularChain<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);
800 return squareFreeLevel >= algVars.size();
803 bool isSaturatedIdealPrime()
const {
804 return saturatedIdealPrimeLevel >= algVars.size();
814 bool isInSaturatedIdealMinimal_inner(
const RecursivePoly& p)
const;
844 bool isRegular(
const RecursivePoly& p)
const;
932 std::vector<RegularChain<Field,RecursivePoly>>
triangularize(
const std::vector<RecursivePoly>& F,
bool lazardDecompose =
false,
int type = 0);
941 std::vector<RegularChain<Field,RecursivePoly>>
intersect(
const RecursivePoly& p,
bool lazardDecompose =
false,
int heightBound = 0)
const;
951 std::vector<PolyChainPair<RecursivePoly,RegularChain<Field,RecursivePoly>>>
regularize(
const RecursivePoly& p,
bool lazardDecompose =
false,
int heightBound = 0)
const;
963 std::vector<PolyChainPair<RecursivePoly,RegularChain<Field,RecursivePoly>>>
regularGCD(
const RecursivePoly& p,
const RecursivePoly& q,
const Symbol& v,
const SubResultantChain<RecursivePoly,RecursivePoly>& src,
bool lazardDecompose =
false,
int heightBound = 0)
const;
972 std::vector<RegularChain<Field,RecursivePoly>>
squareFreePart(
const RecursivePoly& p,
const Symbol& v,
bool lazardDecompose =
false,
int heightBound = 0,
int options=ASSUME_REGULAR)
const;
987 void randomRegularChain(
int nVars,
int nAlgVars,
int nTrcVars,
int nTerms,
unsigned long int coefBound,
int pSparsity,
bool includeNeg);
1001 void randomRegularChain(
int nVars,
int nAlgVars,
int nTrcVars, std::vector<int> maxDegs,
unsigned long int coefBound,
double pSparsity,
bool includeNeg);
1008 bool cleanSet(std::vector<RecursivePoly>& polys)
const;
void randomRegularChain(int nVars, int nAlgVars, int nTrcVars, int nTerms, unsigned long int coefBound, int pSparsity, bool includeNeg)
Generate a random regular chain based on the number of terms of the polynomials in the chain...
A triangular set templated by a multivariate polynomial over a field.
Definition: triangularset.hpp:44
std::vector< Symbol > variables() const
Get the variable names in decreasing order.
Definition: triangularset.hpp:311
Definition: regularchain.hpp:60
void lowerSlice(const Symbol &s)
Destructively converts the current object into lower(s) by changing the set of (potentially algebraic...
int numberOfVariables() const
Get the number of variables.
Definition: triangularset.hpp:275
bool isSquareFree() const
Find out if the regular chain is known to be squarefree.
Definition: regularchain.hpp:799
A class for handling regular chains in dimension zero.
Definition: regularchain.hpp:57
static void removeRedundantChains(const std::vector< RegularChain< Field, RecursivePoly >> &lrc, std::vector< RegularChain< Field, RecursivePoly >> &results)
Remove redundancy from the input list of regular chains.
RecursivePoly select(const Symbol &s) const
Select a polynomial given the leading variable; if no such polynomial, 0 is returned.
RecursivePoly select(const Symbol &s) const
Select the polynomial in the current object with main variable s, if it exists.
Definition: regularchain.hpp:895
bool isInSaturatedIdeal(const RecursivePoly &p) const
Find out if the input polynomial is in the saturated ideal of the current regular chain...
static bool compareHeuristicNoSplit(const RegularChain< Field, RecursivePoly > &rc1, const RegularChain< Field, RecursivePoly > &rc2)
Determine whether or not the quasicomponent of the first regular chain is contained in the quasicompo...
bool isInSaturatedIdealMinimal(const RecursivePoly &p) const
Efficiently find out if the input polynomial is in the saturated ideal of the current regular chain...
void setOptions(int opts)
Set the encoded options of the regular chain.
bool cleanSet(std::vector< RecursivePoly > &polys) const
Reduce the polynomials of the input vector modulo the saturated ideal of the current object and detec...
std::vector< PolyChainPair< RecursivePoly, RegularChain< Field, RecursivePoly > > > regularGCD(const RecursivePoly &p, const RecursivePoly &q, const Symbol &v, const SubResultantChain< RecursivePoly, RecursivePoly > &src, bool lazardDecompose=false, int heightBound=0) const
Compute the gcd of two input polynomials p and q modulo the saturated ideal of the current object...
static bool compareCertifiedNoSplit(const RegularChain< Field, RecursivePoly > &rc1, const RegularChain< Field, RecursivePoly > &rc2)
Determine whether or not the quasicomponent of the first regular chain is contained in the quasicompo...
RegularChain< Field, RecursivePoly > & operator+=(const RecursivePoly &p)
Add assignment operator +=: Adds a polynomial to a regular chain, assuming that the main variable of ...
std::vector< Symbol > variables() const
Get the (potentially algebriac) variable names in decreasing order.
Definition: regularchain.hpp:886
bool isIteratedResultantZeroModular(const RecursivePoly &p) const
Using a modular method determine if the iterated resultant of p and this regular chain is zero or not...
static std::vector< RegularChain< Field, RecursivePoly > > constructChains(const TriangularSet< Field, RecursivePoly > &T)
Construct a set of regular chains from an input triangular set by triangularizing the elements of the...
bool operator!=(const RegularChain< Field, RecursivePoly > &a) const
Negated identity operator !=.
int options() const
Get the encoded options of the regular chain, a bitwise or of RegularChainOption values.
std::vector< RegularChain< Field, RecursivePoly > > squareFreePart(const RecursivePoly &p, const Symbol &v, bool lazardDecompose=false, int heightBound=0, int options=ASSUME_REGULAR) const
A routine that decomposes the regular chain formed from the current object and an input polynomial in...
RegularChain< Field, RecursivePoly > operator+(const RecursivePoly &p) const
Add operator +: Adds a polynomial to a regular chain and returns a new regular chain, assuming that the main variable of p is above any in the current object and that init(p) is regular modulo the saturated ideal of the current object.
std::vector< RegularChain< Field, RecursivePoly > > triangularize(const std::vector< RecursivePoly > &F, bool lazardDecompose=false, int type=0)
Compute a triangular decomposition of the list of input polynomials.
bool operator==(const RegularChain< Field, RecursivePoly > &a) const
Identity operator ==.
std::vector< RegularChain< Field, RecursivePoly > > intersect(const RecursivePoly &p, bool lazardDecompose=false, int heightBound=0) const
Compute the common solutions of the input polynomial and the current regular chain.
A class for handling regular chains of arbitrary dimension.
Definition: regularchain.hpp:65
int numberOfVariables() const
Get the number of (potentially algebraic) variables in the current object.
Definition: regularchain.hpp:775
An encapsulation of a mathematical symbol.
Definition: Symbol.hpp:23
RegularChain< Field, RecursivePoly > & operator=(const ZeroDimensionalRegularChain< Field, RecursivePoly > &a)
Assignment operator = for a zero-dimensional regular chain.
std::vector< PolyChainPair< RecursivePoly, RegularChain< Field, RecursivePoly > > > regularize(const RecursivePoly &p, bool lazardDecompose=false, int heightBound=0) const
Compute a decomposition of the current object such that on each component the input polynomial is eit...
An abstract class defining the interface of a regular chain.
Definition: BPASRegularChain.hpp:11
bool isInRadicalSaturatedIdeal(const RecursivePoly &p) const
Find out if the input polynomial is in the radical saturated ideal of the current regular chain...
bool isRegular(const RecursivePoly &p) const
Find out if the input polynomial is regular modulo the saturated ideal of the current regular chain...