10#ifndef BIBASIS_INVOLUTIVE_HPP
11#define BIBASIS_INVOLUTIVE_HPP
57 template <
typename MonomType>
61 std::list<Polynom<MonomType>*>
GBasis;
81 ,
bool toGroebner)
const;
84 ,
bool toGroebner)
const;
91 template <
typename MonomType>
96 ,
PRing(matrix->get_ring()->cast_to_PolynomialRing())
100 std::list<Polynom<MonomType>*> initialSet;
107 catch(std::string& errorString)
109 ERROR(errorString.c_str());
114 ERROR(
"BIBasis::BooleanInvolutiveBasis::BooleanInvolutiveBasis(): unknown error.");
119 template <
typename MonomType>
125 template <
typename MonomType>
128 typename std::list<Polynom<MonomType>*>::const_iterator it(
GBasis.begin());
129 for (
unsigned i =
Length()-1-num; i > 0; i--)
136 template <
typename MonomType>
142 template <
typename MonomType>
147 const ring_elem coefficientUnit =
PRing->getCoefficients()->one();
151 currentPolynom !=
GBasis.end();
154 if (!*currentPolynom)
161 for (
const MonomType* currentMonom = &(**currentPolynom).Lm();
163 currentMonom = currentMonom->Next)
166 typename std::set<typename MonomType::Integer> variablesSet = currentMonom->GetVariablesSet();
168 for (
typename std::set<typename MonomType::Integer>::const_iterator currentVariable = variablesSet.begin();
169 currentVariable != variablesSet.end();
172 currentExponent[*currentVariable] = 1;
178 ring_elem tmpRingPolynomial =
PRing->make_flat_term(coefficientUnit, tmpRingMonomial);
179 PRing->add_to(currentRingPolynomial, tmpRingPolynomial);
182 matrixConstructor.
append(
PRing->make_vec(0, currentRingPolynomial));
188 template <
typename MonomType>
192 typename MonomType::Integer independ = MonomType::GetDimIndepend();
195 for (
int column = 0; column < matrix->
n_cols(); ++column)
197 vec polynomVector = matrix->
elem(column);
205 for (
Nterm& currentTerm : polynomVector->coeff)
211 MonomType* currentMonom =
new MonomType();
215 throw std::string(
"BIBasis::BooleanInvolutiveBasis::FillInitialSet(): got NULL instead of new monom.");
218 for (
typename MonomType::Integer currentVariable = 0; currentVariable < independ; ++currentVariable)
220 if (monomVector[currentVariable])
222 *currentMonom *= currentVariable;
226 *currentPolynom += *currentMonom;
231 initialSet.push_back(currentPolynom);
235 template <
typename MonomType>
256 while (!originalForm->
IsZero())
259 while (involutiveDivisor)
262 if (!originalForm->
IsZero())
268 involutiveDivisor = 0;
272 if (!originalForm->
IsZero())
274 (*normalForm) += originalForm->
Lm();
283 template <
typename MonomType>
286 ,
bool toGroebner)
const
288 if (!polynom || polynom->
IsZero())
293 typename std::list<Polynom<MonomType>*>::const_iterator it(set.begin()), setEnd(set.end());
294 const MonomType& plm = polynom->
Lm();
298 if (toGroebner && plm.IsDivisibleBy((**it).Lm()))
302 else if (!toGroebner && plm.IsPommaretDivisibleBy((**it).Lm()))
312 template <
typename MonomType>
315 ,
bool toGroebner)
const
325 while (!polynom->
IsZero())
327 currentReducer =
FindDivisor(polynom, set, toGroebner);
328 while (currentReducer)
331 currentReducer =
FindDivisor(polynom, set, toGroebner);
335 (*result) += polynom->
Lm();
344 template <
typename MonomType>
347 std::list<Polynom<MonomType>*> tmpPolySet;
354 currentPolynom =
Reduce(currentPolynom, tmpPolySet, toGroebner);
356 if (currentPolynom && !currentPolynom->
IsZero())
358 const MonomType& hLm = currentPolynom->
Lm();
359 typename std::list<Polynom<MonomType>*>::iterator iteratorTmpPolySet = tmpPolySet.begin();
360 while (iteratorTmpPolySet != tmpPolySet.end())
362 if ((**iteratorTmpPolySet).Lm().IsDivisibleBy(hLm))
364 GBasis.push_back(*iteratorTmpPolySet);
365 iteratorTmpPolySet = tmpPolySet.erase(iteratorTmpPolySet);
369 ++iteratorTmpPolySet;
372 tmpPolySet.push_back(currentPolynom);
376 unsigned tmpPolySetSize =
static_cast<unsigned int>(tmpPolySet.size());
377 for (
unsigned i = 0; i < tmpPolySetSize; ++i)
380 tmpPolySet.pop_front();
381 currentPolynom =
Reduce(currentPolynom, tmpPolySet, toGroebner);
382 if (!currentPolynom || currentPolynom->
IsZero())
388 tmpPolySet.push_back(currentPolynom);
395 template <
typename MonomType>
403 template <
typename MonomType>
425 template <
typename MonomType>
440 std::set<typename MonomType::Integer> currentNmpSet;
444 currentNmpSet = currentTriple->
GetNmp();
446 if (currentAncestor == currentTriple)
451 delete currentTriple;
453 if (!newNormalForm->
IsZero())
455 std::list<Triple<MonomType>*> newProlongations;
460 if ((**tit).GetPolynomLm().IsTrueDivisibleBy(newNormalForm->
Lm()))
463 newProlongations.push_back(*tit);
473 if (!newNormalForm->
Degree())
483 delete newNormalForm;
exponents::Exponents exponents_t
BooleanInvolutiveBasis(const Matrix *matrix, bool toGroebner)
std::list< Polynom< MonomType > * > GBasis
TSet< MonomType > IntermediateBasis
const Matrix * ToMatrix() const
const PolynomialRing *const PRing
void ConstructInvolutiveBasis()
Polynom< MonomType > * Reduce(Polynom< MonomType > *polynom, const std::list< Polynom< MonomType > * > &set, bool toGroebner) const
Polynom< MonomType > * NormalForm(const Triple< MonomType > *triple) const
QSet< MonomType > ProlongationsSet
const Polynom< MonomType > * FindDivisor(const Polynom< MonomType > *polynom, const std::list< Polynom< MonomType > * > &set, bool toGroebner) const
void Construct(const std::list< Polynom< MonomType > * > &set, bool toGroebner)
void FillInitialSet(const Matrix *matrix, std::list< Polynom< MonomType > * > &initialSet) const
const Polynom< MonomType > & operator[](int number) const
~BooleanInvolutiveBasis()
void ReduceSet(bool toGroebner)
MonomType::Integer Degree() const
void Reduction(const Polynom &anotherPolynom)
const MonomType & Lm() const
void HeadReduction(const Polynom &anotherPolynom)
std::list< Triple< MonomType > * >::const_iterator ConstIterator
std::list< Triple< MonomType > * >::iterator Iterator
const Triple * GetWeakAncestor() const
const Polynom< MonomType > * GetPolynom() const
const std::set< typename MonomType::Integer > & GetNmp() const
MonomType::Integer GetVariable() const
const Triple * GetAncestor() const
const MonomType & GetPolynomLm() const
ring_elem elem(int i, int j) const
Mutable builder used to assemble an immutable Matrix one column (or one term) at a time.
void to_expvector(const_monomial m, exponents_t result_exp) const
monomial make_one() const
void from_expvector(const_exponents exp, monomial result) const
Engine-side commutative monomial monoid: variable names, ordering, multidegree machinery,...
Abstract base for the engine's polynomial-ring hierarchy.
VALGRIND_MAKE_MEM_DEFINED & result(result)
MatrixConstructor — the mutable builder that produces an immutable Matrix.
Matrix — the engine's immutable homomorphism F -> G between free modules.
#define newarray_atomic_clear(T, len)
#define newarray_atomic(T, len)
BIBasis::PointerLessComparator / PointerMoreComparator — pointer-deref comparators for STL containers...
BIBasis::QSet<MonomType> — prolongation work-queue sorted by leading monomial.
Singly linked-list node carrying one term of a polynomial-ring element.
BIBasis::TSet<MonomType> — the running intermediate involutive basis (T-set).