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

◆ processPreRow() [2/2]

void NCF4::processPreRow ( PreRow r,
RowsVector & rowsVector,
MemoryBlock & memoryBlock,
PreRowFeeder * feeder )
private

Definition at line 583 of file NCF4.cpp.

587{
588 // note: left and right should be the empty word if gbIndex < 0 indicating
589 // an input polynomial.
590 Word left = r.left;
591 int gbIndex = r.preRowIndex;
592 Word right = r.right;
593 PreRowType preRowType = r.preRowType;
594
595 if (M2_gbTrace >= 100)
596 std::cout << "Processing PreRow: ("
597 << left << "," << gbIndex << "," << right << ")"
598 << std::endl;
599
600 // construct the elem corresponding to this prerow
601 // it will either be:
602 // a multiple of a previously reduced row (if prevReducer)
603 // an element of the input (if gbIndex < 0 and not prevReducer)
604 // a multiple of a gb element (if gbIndex >= 0 and not prevReducer)
605 const Poly* elem;
606 Poly* tempelem;
607 if (preRowType == PreviousReducerPreRow)
608 {
609 // in this case, we construct the poly locally for processing in this
610 // function. We will destroy it at the end, as the new monomials for reduction
611 // are created and inserted into mMonomialSpace
612 tempelem = new Poly;
614 elem = tempelem;
615 }
616 else
617 {
618 if (gbIndex < 0)
619 elem = mInput[-gbIndex-1];
620 else
621 elem = mGroebner[gbIndex];
622 }
623
624 // loop through all monomials of the product
625 // for each monomial:
626 // (the below steps are now in processMonomInPreRow)
627 // is its prefix or suffix the lead term of a row from the previous degree?
628 // if so: insert the information from this row in the appropriate places
629 // if not: is the monomial in the hash table?
630 // if so: return the column index into the component for the new row.
631 // if not: insert it, and return the new column index into same place
632 // and place this monomial into mColumns.
633 // and search for divisor for it.
634 //
635 int numTerms = elem->numTerms();
636
637 auto wordRange = memoryBlock.allocateArray<Word>(numTerms);
638 auto columnRange = memoryBlock.allocateArray<int>(numTerms);
639 // int* componentAlloc = (int*)mMemoryPool.malloc(numTerms*sizeof(int));
640 // Range<int> componentRange(componentAlloc,componentAlloc + numTerms);
641 // for (auto& i : componentRange) i = 0;
642
643 Word* nextColWord = wordRange.first;
644
645 for (auto i = elem->cbegin(); i != elem->cend(); ++i)
646 {
647 Word mid;
648 freeAlgebra().monoid().wordFromMonom(mid,i.monom());
649 Word w = freeAlgebra().monoid().wordProductAsWord(left,mid,right,memoryBlock);
650 processWordInPreRow(w,feeder);
651 *nextColWord = w;
652 ++nextColWord;
653 }
654
655 // this memory is stored in rowsVector and cleaned up later.
656 ElementArray coeffs = mVectorArithmetic->elementArrayFromContainer(elem->getElementArray());
657
658 // delete the Poly created for prevReducer case, if necessary.
659 if (preRowType == PreviousReducerPreRow)
660 {
661 mFreeAlgebra.clear(*tempelem);
662 delete tempelem;
663 }
664
665 // add the processed row to the appropriate list
666 rowsVector.emplace_back(Row {coeffs, columnRange, wordRange});
667}
Polynomial< CoefficientRingType > Poly
const FreeMonoid & monoid() const
Word wordProductAsWord(const Word &left, const Word &right, MemoryBlock &memBlock) const
void wordFromMonom(Word &result, const Monom &m) const
std::pair< T *, T * > allocateArray(size_t nelems)
PolyList mGroebner
Definition NCF4.hpp:222
ColumnsVector mPreviousColumns
Definition NCF4.hpp:241
const ConstPolyList mInput
Definition NCF4.hpp:217
RowsVector mPreviousRows
Definition NCF4.hpp:244
PreRowType
Definition NCF4.hpp:121
@ PreviousReducerPreRow
Definition NCF4.hpp:121
void reducedRowToPoly(Poly *result, const RowsVector &rows, const ColumnsVector &cols, int i) const
Definition NCF4.cpp:328
const FreeAlgebra & mFreeAlgebra
Definition NCF4.hpp:216
void processWordInPreRow(Word &w, PreRowFeeder *feeder)
Definition NCF4.cpp:678
const VectorArithmetic * mVectorArithmetic
Definition NCF4.hpp:250
const FreeAlgebra & freeAlgebra() const
Definition NCF4.hpp:282
int M2_gbTrace
Definition m2-types.cpp:52
A materialised row of the Macaulay matrix: parallel coefficient and monomial arrays.
Definition NCF4.hpp:158

References MemoryBlock::allocateArray(), freeAlgebra(), NCF4::PreRow::left, M2_gbTrace, mFreeAlgebra, mGroebner, mInput, FreeAlgebra::monoid(), mPreviousColumns, mPreviousRows, mVectorArithmetic, NCF4::PreRow::preRowIndex, NCF4::PreRow::preRowType, PreviousReducerPreRow, processWordInPreRow(), reducedRowToPoly(), NCF4::PreRow::right, FreeMonoid::wordFromMonom(), and FreeMonoid::wordProductAsWord().

Referenced by buildF4Matrix(), parallelBuildF4Matrix(), and processPreRow().