255{
256
257 size_t loop_count = 0;
258 size_t nterms = 0;
259
260
264
265
266
267 std::pair<int,int> subwordPos;
268 Word leftWord, rightWord;
269
272
274 nterms += reducee->numTerms();
275 mHeap->addPolynomial(*reducee);
276
278
279 while (not
mHeap->isZero())
280 {
281 loop_count++;
282
283
284 Word reduceeLeadWord;
285 std::pair<Monom, ring_elem>
LT {
mHeap->viewLeadTerm() };
286
288
289 if (W.
subword(reduceeLeadWord,subwordPos))
290 {
291
294
296 ring_elem d = reducers[subwordPos.first]->cbegin().coeff();
297
299
302 *reducers[subwordPos.first],
303 coeffNeeded,
304 leftWord,
305 rightWord);
306 nterms += tmp.numTerms();
307 mHeap->addPolynomial(tmp);
308 }
309 else
310 {
311
312
314 mHeap->removeLeadTerm();
315 }
316 }
318 {
319 std::cout << "reduction: " << "#steps: " << loop_count << " " << FreeMonoidLogger() << std::endl;
320 std::cout << " " << "#terms: " << nterms << std::endl;
321 std::cout << " " << AllocLogger() << std::endl;
322 }
324}
Polynomial< CoefficientRingType > Poly
gc_vector< Poly * > PolyList
const Ring * coefficientRing() const
void add_to_end(Poly &f, const Poly &g) const
void clear(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 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
std::unique_ptr< PolynomialHeap > mHeap
const PolyList & currentValue() const
const FreeAlgebra & freeAlgebra() const
virtual ring_elem divide(const ring_elem f, const ring_elem g) const =0
virtual ring_elem negate(const ring_elem f) const =0
bool subword(Word word, std::pair< int, int > &output) const
const mpreal remainder(const mpreal &x, const mpreal &y, mp_rnd_t rnd_mode=mpreal::get_default_rnd())