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

◆ TEST() [19/19]

TEST ( WordTable ,
subwords  )

Definition at line 547 of file NCGroebnerTest.cpp.

548{
549 std::vector<int> monom1 {1, 0, 1, 2}; // babc
550 std::vector<int> monom2 {1, 0, 2, 2}; // bacc
551 std::vector<int> monom3 {1, 0, 1, 0}; // baba
552 std::vector<int> monom4 {1, 0}; // ba
553 std::vector<int> word {1, 0, 1, 0, 2, 2, 1, 0, 1, 2};
554
555 WordTable W;
556
557 EXPECT_EQ(monom1.size(), 4);
558 EXPECT_EQ(monom2.size(), 4);
559 EXPECT_EQ(monom3.size(), 4);
560 EXPECT_EQ(monom4.size(), 2);
561 EXPECT_EQ(word.size(), 10);
562
563 W.insert(Word(monom1));
564 W.insert(Word(monom2));
565 W.insert(Word(monom3));
566 W.insert(Word(monom4));
567
568 std::vector<std::pair<int,int>> matches;
569 W.subwords(Word(word), matches);
570
571 EXPECT_EQ(matches.size(), 6);
572 EXPECT_EQ(matches[0], std::make_pair(0, 6));
573 EXPECT_EQ(matches[1], std::make_pair(1, 2));
574 EXPECT_EQ(matches[2], std::make_pair(2, 0));
575 EXPECT_EQ(matches[3], std::make_pair(3, 0));
576 EXPECT_EQ(matches[4], std::make_pair(3, 2));
577 EXPECT_EQ(matches[5], std::make_pair(3, 6));
578}
std::vector< int > monom1
std::vector< int > monom2
std::vector< int > word
std::vector< int > monom3
Non-owning view of a non-commutative word: [begin, end) of int variable indices.
Definition Word.hpp:56
void subwords(Word word, std::vector< std::pair< int, int > > &output) const
size_t insert(Word w)
Definition WordTable.cpp:17
Index of Words (non-commutative monomials) with subword, prefix/suffix, and overlap lookup used by th...
Definition WordTable.hpp:89

References WordTable::insert(), monom1, monom2, monom3, WordTable::subwords(), and word.