1 #ifndef simplicialcomplex_h_ooDeimaexieghaev
2 #define simplicialcomplex_h_ooDeimaexieghaev
5 #include <cpptest-suite.h>
7 #include <libstick-0.1/simplicialcomplex.h>
9 using namespace libstick
;
12 class simplicial_complex_TestSuite
: public Test::Suite
{
15 typedef simplicial_complex
<3, uint32_t, double> scomplex
;
16 typedef scomplex::simplex_order::boundary_matrix bm
;
20 scomplex::simplex_order o1
, o2
, o3
, o3b
;
23 simplicial_complex_TestSuite() :
30 TEST_ADD(simplicial_complex_TestSuite::test_is_complex
);
31 TEST_ADD(simplicial_complex_TestSuite::test_is_monotoneComplex
);
32 TEST_ADD(simplicial_complex_TestSuite::test_is_order_filtration
);
33 TEST_ADD(simplicial_complex_TestSuite::test_is_order_monotone
);
34 TEST_ADD(simplicial_complex_TestSuite::test_boundary_matrix
);
38 virtual void setup() {
43 scomplex::simplex ss
[] = {
44 // dimension, faces, value...
57 const size_t cntss
= sizeof(ss
)/sizeof(scomplex::simplex
);
58 c1
.add_simplices(ss
, cntss
);
60 // This is o1 This is o2 This is o3(b)
61 // (value = index) (values) (values)
63 // 1 ----5---- 2 1 ----5---- 2 1 ----5---- 2
65 // | \ 11 | | \ 11 | | \ 13 |
68 // 8 9 6 8 9 12 8 9 12
70 // | 10 \ | | 10 \ | | 10 \ |
73 // 4 ----7---- 3 4 ----7---- 3 4 ----7---- 3
76 c2
.simplices
[6].value
= 12;
79 c3
.simplices
[11].value
= 13;
85 o3b
.make_monotone_filtration();
88 virtual void tear_down() {
91 void test_is_complex() {
92 TEST_ASSERT(c1
.is_complex());
93 TEST_ASSERT(c2
.is_complex());
94 TEST_ASSERT(c3
.is_complex());
97 void test_is_monotoneComplex() {
98 TEST_ASSERT(c1
.is_monotone());
99 TEST_ASSERT(!c2
.is_monotone());
100 TEST_ASSERT(c3
.is_monotone());
103 void test_is_order_filtration() {
104 TEST_ASSERT(o1
.is_filtration());
105 TEST_ASSERT(o2
.is_filtration());
106 TEST_ASSERT(o3
.is_filtration());
107 TEST_ASSERT(o3b
.is_filtration());
110 void test_is_order_monotone() {
111 TEST_ASSERT(o1
.is_monotone());
112 TEST_ASSERT(!o2
.is_monotone());
113 TEST_ASSERT(!o3
.is_monotone());
114 TEST_ASSERT(o3b
.is_monotone());
117 void test_boundary_matrix() {
118 bm mat1
= o1
.get_boundary_matrix();
120 uint32_t mat1e_coords
[][2] = {
121 {0, 1}, {0, 2}, {0, 3}, {0, 4}, {1, 5}, {2, 5}, {2, 6}, {3, 6}, {3, 7}, {4, 7}, {1, 8}, {4, 8},
122 {1, 9}, {3, 9}, {7, 10}, {8, 10}, {9, 10}, {5, 11}, {6, 11}, {9, 11}
124 mat1e
.set_all(mat1e_coords
, sizeof(mat1e_coords
)/(2*sizeof(uint32_t)), true);
125 TEST_ASSERT(mat1
== mat1e
);
128 bm mat3b
= o3b
.get_boundary_matrix();
129 bm
mat3be(c1
.size());
130 uint32_t mat3be_coords
[][2] = {
131 {0, 1}, {0, 2}, {0, 3}, {0, 4}, {1, 5}, {2, 5}, {3, 6}, {4, 6}, {1, 7}, {4, 7}, {1, 8}, {3, 8},
132 {6, 9}, {7, 9}, {8, 9}, {2, 10}, {3, 10}, {5, 11}, {8, 11}, {10, 11}
134 mat3be
.set_all(mat3be_coords
, sizeof(mat3be_coords
)/(2*sizeof(uint32_t)), true);
135 TEST_ASSERT(mat3b
== mat3be
);
137 //std::cout << mat3b << std::endl << std::endl;
138 //std::cout << mat3be << std::endl << std::endl;
139 //std::cout << ((bm::colbase) mat3b) << std::endl << std::endl;
140 //std::cout << ((bm::rowbase) mat3b) << std::endl << std::endl;