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

◆ TEST() [16/19]

TEST ( WordTable ,
prefix_suffix  )

Definition at line 580 of file NCGroebnerTest.cpp.

581{
582 std::vector<int> monom1 {1, 0, 1, 2}; // babc
583 std::vector<int> monom2 {1, 0, 2, 2}; // bacc
584 std::vector<int> monom3 {1, 0, 1, 0}; // baba
585 std::vector<int> word {1, 0, 1, 0, 2, 2, 1, 0, 1, 2};
586 std::vector<int> word2 {1, 0, 1, 1, 2, 2, 1, 1, 1, 2};
587
588 WordTable W;
589
590 EXPECT_EQ(monom1.size(), 4);
591 EXPECT_EQ(monom2.size(), 4);
592 EXPECT_EQ(monom3.size(), 4);
593 EXPECT_EQ(word.size(), 10);
594
595 W.insert(Word(monom1));
596 W.insert(Word(monom2));
597 W.insert(Word(monom3));
598
599 int ind = -1; // index of prefix solution, if any.
600 int ind2 = -1; // index of suffix solution, if any.
601 bool isprefix = W.isPrefix(Word(word), ind);
602 bool issuffix = W.isSuffix(Word(word), ind2);
603
604 EXPECT_TRUE(isprefix);
605 EXPECT_TRUE(issuffix);
606 EXPECT_EQ(2, ind);
607 EXPECT_EQ(0, ind2);
608
609 ind = -1;
610 ind2 = -1;
611 isprefix = W.isPrefix(Word(monom1), ind);
612 issuffix = W.isSuffix(Word(monom2), ind2);
613 EXPECT_TRUE(isprefix);
614 EXPECT_EQ(0,ind);
615 EXPECT_TRUE(issuffix);
616 EXPECT_EQ(1,ind2);
617
618
619 ind = -1;
620 ind2 = -1;
621 isprefix = W.isPrefix(Word(word2), ind);
622 issuffix = W.isSuffix(Word(word2), ind2);
623
624 EXPECT_FALSE(isprefix);
625 EXPECT_FALSE(issuffix);
626}
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
bool isPrefix(Word word, int &output) const
bool isSuffix(Word word, 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(), WordTable::isPrefix(), WordTable::isSuffix(), monom1, monom2, monom3, and word.