34 o <<
"[NCGB] reduction heap: "
42 for (
auto i = 0; i <
mInput.size(); ++i)
51 std::make_tuple(i,-1,-1,
true));
56 o <<
"[NCGB] input is " << (
mIsGraded ?
"homogeneous" :
"inhomogeneous") <<
newline;
75 auto toBeProcessed = degSet.second;
79 o <<
"[" << degSet.first <<
"](" << toBeProcessed->
size() <<
")";
82 while(!toBeProcessed->empty())
84 auto overlap = toBeProcessed->front();
89 toBeProcessed->pop_front();
92 std::cout <<
"Reduction avoided using 2nd criterion." << std::endl;
93 std::cout <<
"table after pop:";
116 std::cout <<
"Overlap " << overlap <<
" reduced to zero."
120 toBeProcessed->pop_front();
128 o <<
"[NCGB] number of spair reductions: " << n_spairs;
139 auto toBeProcessed = degSet.second;
143 o <<
"[" << degSet.first <<
"](" << toBeProcessed->
size() <<
")";
146 while(!toBeProcessed->empty())
148 auto overlap = toBeProcessed->front();
153 toBeProcessed->pop_front();
156 std::cout <<
"Reduction avoided using 2nd criterion." << std::endl;
157 std::cout <<
"table after pop:";
180 std::cout <<
"Overlap " << overlap <<
" reduced to zero."
184 toBeProcessed->pop_front();
192 o <<
"[NCGB] number of spair reductions: " << n_spairs;
208 Monom leadMon = lastPoly.cbegin().monom();
212 if (!
freeAlgebra().coefficientRing()->is_zero(foundCoeff))
223 for (
auto t = f.cbegin(); t != f.cend(); ++t)
233 std::vector<Overlap> newOverlaps;
257 size_t loop_count = 0;
267 std::pair<int,int> subwordPos;
268 Word leftWord, rightWord;
274 nterms += reducee->numTerms();
275 mHeap->addPolynomial(*reducee);
279 while (not
mHeap->isZero())
284 Word reduceeLeadWord;
285 std::pair<Monom, ring_elem>
LT {
mHeap->viewLeadTerm() };
289 if (W.
subword(reduceeLeadWord,subwordPos))
296 ring_elem d = reducers[subwordPos.first]->cbegin().coeff();
302 *reducers[subwordPos.first],
306 nterms += tmp.numTerms();
307 mHeap->addPolynomial(tmp);
314 mHeap->removeLeadTerm();
319 std::cout <<
"reduction: " <<
"#steps: " << loop_count <<
" " <<
FreeMonoidLogger() << std::endl;
320 std::cout <<
" " <<
"#terms: " << nterms << std::endl;
329 for (
auto i = reducees.cbegin(); i != reducees.cend(); ++i)
344 auto i = f->cbegin();
346 freeAlgebra().monoid().wordFromMonom(tmp,i.monom());
355 int polyIndex2) ->
Poly*
363 prefix = A.lead_word_prefix(*polyList[polyIndex1], overlapIndex);
364 suffix = A.lead_word_suffix(*polyList[polyIndex2], *(polyList[polyIndex1]->cbegin().monom().
begin()) - A.monoid().numWeights() - 1 - overlapIndex);
365 A.mult_by_term_right(tmp1, *polyList[polyIndex1], A.coefficientRing()->from_long(1),
suffix);
366 A.mult_by_term_left(tmp2, *polyList[polyIndex2], A.coefficientRing()->from_long(1),
prefix);
367 A.subtract(*
result, tmp1, tmp2);
373 if (std::get<1>(overlap) == -1)
383 std::get<0>(overlap),
384 std::get<1>(overlap),
385 std::get<2>(overlap));
393 A.lead_term_as_poly(tmp, *
mGroebner[std::get<2>(o)]);
394 A.mult_by_term_left(wordAsPoly, tmp, A.coefficientRing()->from_long(1),
prefix);
401 return std::get<1>(o) + tmp.
size();
412 int len_of_s = tmpL.
size() - std::get<1>(o);
422 o <<
"Left Poly : " << b1.
str() << std::endl;
423 o <<
"Overlap Pos : " << std::get<1>(overlap) << std::endl;
424 o <<
"Right Poly : " << b2.
str() << std::endl;
429 o <<
"Current GB:" << std::endl;
433 freeAlgebra().elem_text_out(b1,*f,
true,
true,
true);
434 o << b1.
str() << std::endl;
440 for (
auto newOverlap : newOverlaps)
456 std::cout <<
"Reduction avoided using 2nd criterion." << std::endl;
477 w = A.lead_word(tmp);
478 retval = !
mWordTable.isNontrivialSuperword(w, std::get<0>(o), std::get<2>(o));
Free associative algebra k<x_1,...,x_n> over an arbitrary coefficient ring.
FreeMonoid — monoid of length-prefixed non-commutative words with weight-vector prefix.
NCGroebner — Buchberger-style two-sided Gröbner basis driver over a FreeAlgebra.
std::unique_ptr< PolynomialHeap > makePolynomialHeap(HeapType type, const FreeAlgebra &F)
std::string getHeapName(HeapType type)
HeapType getHeapType(int strategy)
PolynomialHeap abstract interface — batched-subtraction heap for non-commutative reduction.
std::tuple< int, int, int, bool > Overlap
OverlapTable — degree-sorted queue of pending word overlaps for non-commutative GB drivers.
gc_vector< const Poly * > ConstPolyList
Polynomial< CoefficientRingType > Poly
gc_vector< Poly * > PolyList
Word prefix(const Word vec, int lengthOfPrefix)
Word suffix(const Word vec, int indexOfSuffix)
Word and WordWithData — non-owning views over the flat-int encoding of a non-commutative word.
WordTable / WordWithDataTable — leading-word indices for non-commutative Gröbner basis lookup.
Append-only GC-backed byte buffer used throughout the engine for text output.
Process-wide allocation counter used by StatsAllocator for debugging and benchmarking.
const Ring * coefficientRing() const
void add_to_end(Poly &f, const Poly &g) const
void makeMonicInPlace(Poly &f) const
std::pair< int, bool > heft_degree(const Poly &f) const
void subtractScalarMultipleOf(Poly &result, const Poly &f, const Poly &g, ring_elem coeff) const
void clear(Poly &f) const
Word lead_word(const Poly &f) const
const FreeMonoid & monoid() const
void mult_by_term_left_and_right(Poly &result, const Poly &f, const ring_elem c, const Monom leftM, const Monom rightM) const
void swap(Poly &f, Poly &g) const
Free associative algebra over a coefficient ring: the non-commutative analogue of PolynomialRing.
void wordFromMonom(Word &result, const Monom &m) const
void wordPrefixFromMonom(Word &result, const Monom &m, int endIndex) const
void wordSuffixFromMonom(Word &result, const Monom &m, int beginIndex) const
Static counter for non-commutative monomial comparisons.
auto overlapWordLength(Overlap o) const -> int
void computeInhomogeneous(int softDegreeLimit)
auto twoSidedReduction(const ConstPolyList &reducees) const -> ConstPolyList
std::unique_ptr< PolynomialHeap > mHeap
void updateOverlaps(const Poly *toAdd)
NCGroebner(const FreeAlgebra &A, const ConstPolyList &input, int hardDegreeLimit, int strategy)
std::vector< int > mGeneratorDegrees
void autoreduceByLastElement()
const FreeAlgebra & mFreeAlgebra
void compute(int softDegreeLimit)
auto insertNewOverlaps(std::vector< Overlap > &newOverlaps) -> void
auto isOverlapNecessary(Overlap o) const -> bool
auto overlapHeft(Overlap o) const -> int
void computeHomogeneous(int softDegreeLimit)
const PolyList & currentValue() const
auto createOverlapLeadWord(Poly &wordAsPoly, Overlap o) const -> void
OverlapTable mOverlapTable
static auto createOverlapPoly(const FreeAlgebra &A, const PolyList &polyList, int polyIndex1, int polyIndex2, int overlapIndex) -> Poly *
auto displayGroebnerBasis(std::ostream &o) const -> void
const FreeAlgebra & freeAlgebra() const
auto printOverlapData(std::ostream &o, Overlap overlap) const -> void
ring_elem getCoeffOfMonom(const Poly &f, const Monom &m)
const ConstPolyList mInput
auto initReductionOnly() -> void
void addToGroebnerBasis(Poly *toAdd)
virtual ring_elem divide(const ring_elem f, const ring_elem g) const =0
virtual ring_elem negate(const ring_elem f) const =0
Non-owning view of a non-commutative word: [begin, end) of int variable indices.
bool subword(Word word, std::pair< int, int > &output) const
Index of Words (non-commutative monomials) with subword, prefix/suffix, and overlap lookup used by th...
VALGRIND_MAKE_MEM_DEFINED & result(result)
Engine-to-interpreter type vocabulary across the C++ / .dd boundary.
AllocLogger / StatsAllocator — single-threaded debug/benchmark instrumentation.
Ring — the legacy abstract base class for every coefficient and polynomial ring.
TermIterator< Nterm > begin(Nterm *ptr)
ring_elem — the universal value type carried by every Ring* in the engine.
Non-owning view onto a [length, degree, v1, v2, ..., vn] packed monomial in some externally managed b...
void emit_line(const char *s)
Text-formatting helpers layered on buffer: bignum print, line wrapping, M2_gbTrace-gated emit.