9 for (; j < wordTable.
mMonomials.size() - 1; ++j)
22 std::copy(w.
begin(),w.
end(),newW.first);
32 std::copy(w.
begin(),w.
end(),newW.first);
40 std::vector<int>& result_start_indices)
45 if (word2.
size() < word1.
size())
return;
46 for (
auto j = 0; j <= word2.
size() - word1.
size(); ++j)
49 for (
auto k = 0; k < word1.
size(); ++k)
55 if (match) result_start_indices.push_back(j);
61 int& result_start_index)
67 if (word2.
size() < word1.
size())
return false;
68 for (
auto j = 0; j <= word2.
size() - word1.
size(); ++j)
71 for (
auto k = 0; k < word1.
size(); ++k)
79 result_start_index = j;
89 if (word2.
size() < word1.
size())
return false;
91 for (
auto k = 0; k < word1.
size(); ++k)
103 auto word1size = word1.
size();
104 auto word2size = word2.
size();
105 if (word2size < word1size)
return false;
107 if (word2size == 0)
return false;
109 for (
auto k = 0; k < word1size; ++k)
110 if (word1.
begin()[word1size-1-k] != word2.
begin()[word2size-1-k])
119 std::vector<std::pair<int,int>>& output)
const
123 std::vector<int> start_indices;
126 start_indices.clear();
128 for (
auto j : start_indices)
129 output.push_back(std::make_pair(i,j));
162 std::pair<int,int>& output)
const
164 int start_index = -1;
169 output = std::make_pair(i, start_index);
177 std::vector<std::pair<int,int>>& output)
const
181 std::vector<int> start_indices;
184 start_indices.clear();
186 for (
auto j : start_indices)
187 output.push_back(std::make_pair(i,j));
195 std::vector<int> start_indices;
198 start_indices.clear();
200 for (
auto j : start_indices)
202 if (i != index1 && i != index2)
return true;
205 if (j == 0 && i != index1)
return true;
206 if (j ==
word.size() - mMonomials[index2].size() && i != index2)
return true;
215 std::vector<int>& result_overlaps)
217 if (word1.
size() <= 1)
return;
218 for (
int i = word1.
size() - 1; i > 0 and i + word2.
size() > word1.
size(); --i)
223 result_overlaps.push_back(i);
239 std::vector<int> overlap_indices;
240 for (
int i=0; i<word_index; ++i)
242 overlap_indices.clear();
244 for (
auto j : overlap_indices)
245 newLeftOverlaps.push_back(std::make_tuple(i, j, word_index,
true));
254 std::vector<int> overlap_indices;
255 for (
int i=0; i<=word_index; ++i)
257 overlap_indices.clear();
259 for (
auto j : overlap_indices)
260 newRightOverlaps.push_back(std::make_tuple(word_index, j, i,
true));
266 if (wordTable.
mMonomials.size() == 0)
return o;
269 for (; j < wordTable.
mMonomials.size() - 1; ++j)
296 std::vector<int>& result_start_indices)
301 if (word2.
size() < word1.
size())
return;
303 for (
auto j = 0; j <= word2.
size() - word1.
size(); ++j)
306 for (
auto k = 0; k < word1.
size(); ++k)
312 if (match) result_start_indices.push_back(j);
318 int& result_start_index)
324 if (word2.
size() < word1.
size())
return false;
326 for (
auto j = 0; j <= word2.
size() - word1.
size(); ++j)
329 for (
auto k = 0; k < word1.
size(); ++k)
337 result_start_index = j;
347 if (word2.
size() < word1.
size())
return false;
349 for (
auto k = 0; k < word1.
size(); ++k)
361 auto word1size = word1.
size();
362 auto word2size = word2.
size();
363 if (word2size < word1size)
return false;
365 if (word2size == 0)
return false;
367 for (
auto k = 0; k < word1size; ++k)
368 if (word1.
begin()[word1size-1-k] != word2.
begin()[word2size-1-k])
377 std::vector<std::pair<int,int>>& output)
const
381 std::vector<int> start_indices;
385 start_indices.clear();
387 for (
auto j : start_indices)
388 output.push_back(std::make_pair(i,j));
423 std::pair<int,int>& output)
const
425 int start_index = -1;
431 output = std::make_pair(i, start_index);
439 std::vector<std::pair<int,int>>& output)
const
443 std::vector<int> start_indices;
447 start_indices.clear();
449 for (
auto j : start_indices)
450 output.push_back(std::make_pair(i,j));
458 std::vector<int> start_indices;
462 start_indices.clear();
464 for (
auto j : start_indices)
466 if (i != index1 && i != index2)
return true;
469 if (j == 0 && i != index1)
return true;
470 if (j ==
word.size() -
mMonomials[index2].size() && i != index2)
return true;
479 std::vector<int>& result_overlaps)
481 if (word1.
size() <= 1)
return;
482 for (
int i = word1.
size() - 1; i > 0 and i + word2.
size() > word1.
size(); --i)
488 result_overlaps.push_back(i);
504 std::vector<int> overlap_indices;
505 for (
int i=0; i<word_index; ++i)
508 overlap_indices.clear();
510 for (
auto j : overlap_indices)
511 newLeftOverlaps.push_back(std::make_tuple(i, j, word_index,
true));
520 std::vector<int> overlap_indices;
521 for (
int i=0; i<=word_index; ++i)
524 overlap_indices.clear();
526 for (
auto j : overlap_indices)
527 newRightOverlaps.push_back(std::make_tuple(word_index, j, i,
true));
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.
std::ostream & operator<<(std::ostream &o, const WordTable &wordTable)
WordTable / WordWithDataTable — leading-word indices for non-commutative Gröbner basis lookup.
const int * begin() const
Non-owning view of a non-commutative word: [begin, end) of int variable indices.
void superwords(Word word, std::vector< std::pair< int, int > > &output) const
void rightOverlaps(std::vector< Overlap > &newRightOverlaps) const
static void subwordPositions(Word word1, Word word2, std::vector< int > &result_start_indices)
bool isPrefix(Word word, int &output) const
bool isSuffix(Word word, int &output) const
void subwords(Word word, std::vector< std::pair< int, int > > &output) const
std::vector< Word > mMonomials
static void overlaps(Word word1, Word word2, std::vector< int > &result_overlaps)
auto isNontrivialSuperword(Word word, int index1, int index2) const -> bool
void leftOverlaps(std::vector< Overlap > &newLeftOverlaps) const
static bool isPrefixOf(Word word1, Word word2)
static bool subwordPosition(Word word1, Word word2, int &result_start_index)
bool subword(Word word, std::pair< int, int > &output) const
MemoryBlock mMonomialSpace
static bool isSuffixOf(Word word1, Word word2)
const int * begin() const
Word plus its ecart degree and heft degree — the value type WordWithDataTable stores.
static void overlaps(WordWithData word1, WordWithData word2, std::vector< int > &result_overlaps)
bool subword(WordWithData word, std::pair< int, int > &output) const
static void subwordPositions(WordWithData word1, WordWithData word2, std::vector< int > &result_start_indices)
bool isSuffix(WordWithData word, int &output) const
std::vector< int > mIndices
void superwords(WordWithData word, std::vector< std::pair< int, int > > &output) const
static bool subwordPosition(WordWithData word1, WordWithData word2, int &result_start_index)
bool isPrefix(WordWithData word, int &output) const
auto isNontrivialSuperword(WordWithData word, int index1, int index2) const -> bool
size_t insert(WordWithData w)
static bool isPrefixOf(WordWithData word1, WordWithData word2)
void leftOverlaps(std::vector< Overlap > &newLeftOverlaps) const
static bool isSuffixOf(WordWithData word1, WordWithData word2)
void subwords(WordWithData word, std::vector< std::pair< int, int > > &output) const
void rightOverlaps(std::vector< Overlap > &newRightOverlaps) const
std::vector< WordWithData > mMonomials