1 #ifndef simplicialcomplex_h_ooDeimaexieghaev
2 #define simplicialcomplex_h_ooDeimaexieghaev
5 #include <cpptest-suite.h>
7 #include <libstick/simplicialfunction.h>
9 using namespace libstick
;
12 class simplicial_complex_TestSuite
: public Test::Suite
{
15 typedef simplicial_function
<3, uint32_t, double> sfunction
;
16 typedef sfunction::scomplex scomplex
;
17 typedef scomplex::simplex_order::boundary_matrix bm
;
22 scomplex::simplex_order o1
, o3b
;
25 simplicial_complex_TestSuite() :
33 TEST_ADD(simplicial_complex_TestSuite::test_is_complex
);
34 TEST_ADD(simplicial_complex_TestSuite::test_is_function_monotone
);
35 TEST_ADD(simplicial_complex_TestSuite::test_is_order_filtration
);
36 TEST_ADD(simplicial_complex_TestSuite::test_is_order_monotone
);
37 TEST_ADD(simplicial_complex_TestSuite::test_boundary_matrix
);
41 virtual void setup() {
46 typedef sfunction::valuedsimplex vsimpl
;
48 sfunction::valuedsimplex ss
[] = {
49 // {dimension, faces}, value
62 const size_t cntss
= sizeof(ss
)/sizeof(sfunction::valuedsimplex
);
63 f1
.add_simplices(ss
, cntss
);
65 // This is f1 This is f2 This is f3
66 // (value = index) (values) (values)
68 // 1 ----5---- 2 1 ----5---- 2 1 ----5---- 2
70 // | \ 11 | | \ 11 | | \ 13 |
73 // 8 9 6 8 9 12 8 9 12
75 // | 10 \ | | 10 \ | | 10 \ |
78 // 4 ----7---- 3 4 ----7---- 3 4 ----7---- 3
80 // Copy and change the function values
81 f2
.set_values(f1
.get_values());
84 f3
.set_values(f2
.get_values());
87 // Get two orders, the one is a monotone filtration
90 f3
.make_order_monotonefiltration(o3b
);
93 virtual void tear_down() {
96 void test_is_complex() {
97 TEST_ASSERT(c
.is_complex());
100 void test_is_function_monotone() {
101 TEST_ASSERT(f1
.is_monotone());
102 TEST_ASSERT(!f2
.is_monotone());
103 TEST_ASSERT(f3
.is_monotone());
106 void test_is_order_filtration() {
107 TEST_ASSERT(o1
.is_filtration());
108 TEST_ASSERT(o3b
.is_filtration());
111 void test_is_order_monotone() {
112 TEST_ASSERT(f1
.is_order_monotonefiltration(o1
));
113 TEST_ASSERT(!f2
.is_order_monotonefiltration(o1
));
114 TEST_ASSERT(!f3
.is_order_monotonefiltration(o1
));
115 TEST_ASSERT(f3
.is_order_monotonefiltration(o3b
));
118 void test_boundary_matrix() {
119 bm mat1
= o1
.get_boundary_matrix();
121 uint32_t mat1e_coords
[][2] = {
122 {0, 1}, {0, 2}, {0, 3}, {0, 4}, {1, 5}, {2, 5}, {2, 6}, {3, 6}, {3, 7}, {4, 7}, {1, 8}, {4, 8},
123 {1, 9}, {3, 9}, {7, 10}, {8, 10}, {9, 10}, {5, 11}, {6, 11}, {9, 11}
125 mat1e
.set_all(mat1e_coords
, sizeof(mat1e_coords
)/(2*sizeof(uint32_t)), true);
126 TEST_ASSERT(mat1
== mat1e
);
129 bm mat3b
= o3b
.get_boundary_matrix();
131 uint32_t mat3be_coords
[][2] = {
132 {0, 1}, {0, 2}, {0, 3}, {0, 4}, {1, 5}, {2, 5}, {3, 6}, {4, 6}, {1, 7}, {4, 7}, {1, 8}, {3, 8},
133 {6, 9}, {7, 9}, {8, 9}, {2, 10}, {3, 10}, {5, 11}, {8, 11}, {10, 11}
135 mat3be
.set_all(mat3be_coords
, sizeof(mat3be_coords
)/(2*sizeof(uint32_t)), true);
136 TEST_ASSERT(mat3b
== mat3be
);
138 //std::cout << mat3b << std::endl << std::endl;
139 //std::cout << mat3be << std::endl << std::endl;
140 //std::cout << ((bm::colbase) mat3b) << std::endl << std::endl;
141 //std::cout << ((bm::rowbase) mat3b) << std::endl << std::endl;