Macaulay2 Engine
Loading...
Searching...
No Matches

◆ preRowsFromOverlap()

void NCF4::preRowsFromOverlap ( const Overlap & o)
private

Definition at line 393 of file NCF4.cpp.

394{
395 // o = (gbLeftIndex, overLapPos, gbRightIndex).
396 // BUT: if overlapPos < 0, then gbRightIndex is also < 0 (and is ignored), and gbLeftIndex
397 // refers to a generator, and we add to mOverlapsTodo in only (1,gbLeftIndex,1).
398 // where 1 = empty word.
399
400 int gbLeftIndex = std::get<0>(o);
401 int overlapPos = std::get<1>(o);
402 int gbRightIndex = std::get<2>(o);
403
404 if (overlapPos < 0)
405 {
406 // Sneaky trick: a PreRow with index a < 0 refers to generator with index -a-1
407 mOverlapsTodo.emplace_back(PreRow {Word(),
408 - gbLeftIndex - 1,
409 Word(),
411 return;
412 }
413
414 // LM(gbLeft) = x^a x^b
415 // LM(gbRight) = x^b x^c
416 // overlapPos = starting position of x^b in gbLeft.
417 // one prerow will be: (1, gbLeftIndex, x^c)
418 // another prerow will be: (x^a, gbRightIndex, 1)
419
420 Word leadWordLeft = mWordTable[gbLeftIndex];
421 Word leadWordRight = mWordTable[gbRightIndex];
422 int overlapLen = leadWordLeft.size() - overlapPos;
423
424 Word suffix2 {}; // trivial word
425 Word prefix2(leadWordLeft.begin(), leadWordLeft.begin() + overlapPos);
426
427 Word suffix1(leadWordRight.begin() + overlapLen, leadWordRight.end());
428 Word prefix1 {}; // trivial word
429
430 // need to add in the lead monomial to the mColumnMonomials list now
431 // so they know which row reduces them
432 Word newWord = freeAlgebra().monoid().wordProductAsWord(leadWordLeft, suffix1, mMonomialSpace);
433
434 // This overlap may already have lead term in table.
435 // Only have to add it in if it is not yet present.
436 auto it = mColumnMonomials.find(newWord);
437 if (it == mColumnMonomials.cend())
438 mColumnMonomials.emplace(newWord, std::make_pair(-1,-1));
439
440 // it *matters* which one is a reducer and which one is an overlap.
441 // this is due to how the word table lookup works -- it searches them
442 // in the order that they were entered into the word table, which may
443 // not be sorted in term order.
444 if (gbLeftIndex > gbRightIndex)
445 {
446 mReducersTodo.emplace_back(PreRow {prefix2,
447 gbRightIndex,
448 suffix2,
450 mOverlapsTodo.emplace_back(PreRow {prefix1,
451 gbLeftIndex,
452 suffix1,
454 }
455 else
456 {
457 mReducersTodo.emplace_back(PreRow {prefix1,
458 gbLeftIndex,
459 suffix1,
461 mOverlapsTodo.emplace_back(PreRow {prefix2,
462 gbRightIndex,
463 suffix2,
465 }
466}
const FreeMonoid & monoid() const
Word wordProductAsWord(const Word &left, const Word &right, MemoryBlock &memBlock) const
@ OverlapPreRow
Definition NCF4.hpp:121
@ ReducerPreRow
Definition NCF4.hpp:121
std::vector< PreRow > mOverlapsTodo
Definition NCF4.hpp:239
MonomialHash mColumnMonomials
Definition NCF4.hpp:235
WordTable mWordTable
Definition NCF4.hpp:219
MemoryBlock mMonomialSpace
Definition NCF4.hpp:228
std::vector< PreRow > mReducersTodo
Definition NCF4.hpp:238
const FreeAlgebra & freeAlgebra() const
Definition NCF4.hpp:282
const int * begin() const
Definition Word.hpp:72
const int * end() const
Definition Word.hpp:73
int size() const
Definition Word.hpp:74
Symbolic description of one row before it is materialised in the matrix: a left * (something) * right...
Definition NCF4.hpp:138

References Word::begin(), Word::end(), freeAlgebra(), mColumnMonomials, mMonomialSpace, FreeAlgebra::monoid(), mOverlapsTodo, mReducersTodo, mWordTable, OverlapPreRow, ReducerPreRow, Word::size(), and FreeMonoid::wordProductAsWord().

Referenced by buildF4Matrix(), and parallelBuildF4Matrix().