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

◆ TEST() [18/19]

TEST ( WordTable ,
skylanin  )

Definition at line 682 of file NCGroebnerTest.cpp.

683{
684 // X,Y Z are the 3 variables
685#if 0
686 mons = {{Z, X}, {Z, Y}, {Z, Z}, {Y, Y, X}, {Y, Y, Z},
687 {Y, X, Y, Y}, {Y, Y, Y, Y}, {Y, X, Y, X, X},
688 {Y, X, Y, X, Y}, {Y, X, Y, X, Z},
689 {Y, X, X, Y, X, X}, {Y, X, X, Y, X, Z},
690 {Y, X, X, Y, Y, Y}}
691#endif
692
693 std::vector<int> m0 {2,0}; // ZX
694 std::vector<int> m1 {2,1}; // ZY
695 std::vector<int> m2 {2,2}; // ZZ
696 std::vector<int> m3 {1,1,0}; // YYX
697 std::vector<int> m4 {1,1,2}; // YYZ
698 std::vector<int> m5 {1,0,1,1}; // YXYY
699 std::vector<int> m6 {1,1,1,1}; // YYYY
700 std::vector<int> m7 {1,0,1,0,0}; // YXYXX
701 std::vector<int> m8 {1,0,1,0,1}; // YXYXY
702 std::vector<int> m9 {1,0,1,0,2}; // YXYXZ
703 std::vector<int> m10 {1,0,0,1,0,0}; // YXXYXX
704 std::vector<int> m11 {1,0,0,1,0,2}; // YXXYXZ
705 std::vector<int> m12 {1,0,0,1,1,1}; // YXXYYY
706
707 std::vector<Overlap> overlaps;
708 std::vector<std::pair<int,int>> matches;
709
710 WordTable W;
711 W.insert(Word(m0), overlaps);
712 EXPECT_EQ(0, overlaps.size());
713
714 W.insert(Word(m1), overlaps);
715 EXPECT_EQ(0, overlaps.size());
716
717 W.insert(Word(m2), overlaps);
718 std::vector<Overlap> ans {
719 std::make_tuple(2,1,0,true),
720 std::make_tuple(2,1,1,true),
721 std::make_tuple(2,1,2,true)
722 };
723 std::sort(ans.begin(),ans.end());
724 std::sort(overlaps.begin(),overlaps.end());
725
726 EXPECT_EQ(overlaps, ans);
727 overlaps.clear();
728 W.leftOverlaps(overlaps);
729 EXPECT_EQ(0, overlaps.size());
730
731 W.insert(Word(m3));
732 W.insert(Word(m4));
733 W.insert(Word(m5));
734 W.insert(Word(m6));
735 W.insert(Word(m7));
736 W.insert(Word(m8));
737 W.insert(Word(m9));
738 W.insert(Word(m10));
739 W.insert(Word(m11));
740 W.insert(Word(m12));
741
742 matches.clear();
743 W.superwords(Word(std::vector<int> {1, 1}), matches);
744 std::vector<std::pair<int,int>> ans2
745 {
746 std::make_pair(3,0),
747 std::make_pair(4,0),
748 std::make_pair(5,2),
749 std::make_pair(6,0),
750 std::make_pair(6,1),
751 std::make_pair(6,2),
752 std::make_pair(12,3),
753 std::make_pair(12,4)
754 };
755 std::sort(ans2.begin(),ans2.end());
756 std::sort(matches.begin(),matches.end());
757 EXPECT_EQ(ans2, matches);
758
759 matches.clear();
760 EXPECT_TRUE(W.isNontrivialSuperword(Word(std::vector<int> {1,2,1,1,2,1,1}), 6, 6));
761 EXPECT_TRUE(W.isNontrivialSuperword(Word(std::vector<int> {1,1,2,1,1,2,1,1,2}), 4, 4));
762
763 matches.clear();
764 W.subwords(Word(std::vector<int> {2,2,0,1,1,0,1,0,1,1}), matches); // ZZXYYXYXYY
765 std::vector<std::pair<int,int>> ans3
766 {
767 {0,1},
768 {2,0},
769 {3,3},
770 {5,6},
771 {8,4}
772 };
773 std::sort(ans3.begin(),ans3.end());
774 std::sort(matches.begin(),matches.end());
775 EXPECT_EQ(ans3, matches);
776
777}
Non-owning view of a non-commutative word: [begin, end) of int variable indices.
Definition Word.hpp:56
void superwords(Word word, std::vector< std::pair< int, int > > &output) const
void subwords(Word word, std::vector< std::pair< int, int > > &output) const
auto isNontrivialSuperword(Word word, int index1, int index2) const -> bool
void leftOverlaps(std::vector< Overlap > &newLeftOverlaps) 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::isNontrivialSuperword(), WordTable::leftOverlaps(), WordTable::subwords(), and WordTable::superwords().