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

◆ findDivisor()

std::pair< bool, NCF4::PreRow > NCF4::findDivisor ( Word w)
private

Definition at line 710 of file NCF4.cpp.

711{
712 Word newword;
713
714 // look in previous F4 matrix for Monom before checking mWordTable
715
716 auto usePreviousSuffix = findPreviousReducerSuffix(word);
717 if (usePreviousSuffix.first)
718 {
719 // here, we use a multiple of a previously reduced row
720 Word tmpWord;
721 if (word.size() != 0)
722 tmpWord.init(word.begin(), word.begin() + 1);
723 return std::make_pair(true, PreRow {tmpWord,
724 usePreviousSuffix.second,
725 Word(),
727 }
728 auto usePreviousPrefix = findPreviousReducerPrefix(word);
729 if (usePreviousPrefix.first)
730 {
731 // here, we use a multiple of a previously reduced row
732 Word tmpWord;
733 if (word.size() != 0)
734 tmpWord.init(word.end()-1, word.end());
735 return std::make_pair(true, PreRow {Word(),
736 usePreviousPrefix.second,
737 tmpWord,
739 }
740
741 // if we are here, then the Monom does not have a prefix/suffix
742 // that was processed previously.
743
744 // look in mWordTable for Monom
745 std::pair<int,int> divisorInfo;
746
747 // TODO: for certain inputs (e.g. Monoms that we *know* are of
748 // the form xm or mx for m a standard monomial and x a
749 // variable, one needs only to check prefixes or
750 // suffixes, not all subwords. Not sure how to utilize that
751 // just yet.
752
753 bool found = mWordTable.subword(word, divisorInfo);
754
755 // if newword = x^a x^b x^c, with x^b in the word table, then:
756 // divisorInfo.first = index of the GB element with x^b as lead monomial.
757 // divisorInfo.second = position of the start of x^b in newword
758 // (that is, the length of x^a).
759 if (not found)
760 return std::make_pair(false, PreRow {Word(), 0, Word(), ReducerPreRow});
761 // if found, then return this information to caller
762 Word prefix = Word(word.begin(), word.begin() + divisorInfo.second);
763 Word divisorWord = mWordTable[divisorInfo.first];
764 Word suffix = Word(word.begin() + divisorInfo.second + divisorWord.size(),
765 word.end());
766 return std::make_pair(true, PreRow {prefix, divisorInfo.first, suffix, ReducerPreRow});
767}
std::vector< int > word
Word prefix(const Word vec, int lengthOfPrefix)
Word suffix(const Word vec, int indexOfSuffix)
@ ReducerPreRow
Definition NCF4.hpp:121
@ PreviousReducerPreRow
Definition NCF4.hpp:121
std::pair< bool, int > findPreviousReducerSuffix(const Word &w)
Definition NCF4.cpp:808
WordTable mWordTable
Definition NCF4.hpp:219
std::pair< bool, int > findPreviousReducerPrefix(const Word &w)
Definition NCF4.cpp:769
void init(const int *begin, const int *end)
Definition Word.hpp:68
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 findPreviousReducerPrefix(), findPreviousReducerSuffix(), Word::init(), mWordTable, prefix(), PreviousReducerPreRow, ReducerPreRow, Word::size(), suffix(), and word.

Referenced by processWordInPreRow().