#include <cpptest-suite.h>
#include <libstick-0.1/simplicialcomplex.h>
-#include <libstick-0.1/matrixreduction.h>
using namespace libstick;
-class SimplicialComplexTestSuite: public Test::Suite {
+class simplicial_complex_TestSuite: public Test::Suite {
private:
- typedef SimplicialComplex<2, uint32_t, double> scomplex;
- typedef scomplex::SimplexOrder::BoundaryMatrix bm;
+ typedef simplicial_complex<3, uint32_t, double> scomplex;
+ typedef scomplex::simplex_order::boundary_matrix bm;
bool setupcalled;
scomplex c1, c2, c3;
- scomplex::SimplexOrder o1, o2, o3, o3b;
+ scomplex::simplex_order o1, o2, o3, o3b;
public:
- SimplicialComplexTestSuite() :
+ simplicial_complex_TestSuite() :
setupcalled(false),
o1(c1),
o2(c2),
o3(c3),
o3b(c3)
{
- TEST_ADD(SimplicialComplexTestSuite::test_isComplex);
- TEST_ADD(SimplicialComplexTestSuite::test_isMonotoneComplex);
- TEST_ADD(SimplicialComplexTestSuite::test_isOrderFiltration);
- TEST_ADD(SimplicialComplexTestSuite::test_isOrderMonotone);
- TEST_ADD(SimplicialComplexTestSuite::test_boundaryMatrix);
- TEST_ADD(SimplicialComplexTestSuite::test_matrixreduction);
+ TEST_ADD(simplicial_complex_TestSuite::test_is_complex);
+ TEST_ADD(simplicial_complex_TestSuite::test_is_monotoneComplex);
+ TEST_ADD(simplicial_complex_TestSuite::test_is_order_filtration);
+ TEST_ADD(simplicial_complex_TestSuite::test_is_order_monotone);
+ TEST_ADD(simplicial_complex_TestSuite::test_boundary_matrix);
}
protected:
return;
setupcalled = true;
- const unsigned num = 11;
- scomplex::Simplex ss[num] = {
+ scomplex::simplex ss[] = {
// dimension, faces, value...
{0, {}, 1},
{0, {}, 2},
{2, {7, 8, 9}, 10},
{2, {5, 6, 9}, 11}
};
+ const size_t cntss = sizeof(ss)/sizeof(scomplex::simplex);
+ c1.add_simplices(ss, cntss);
// This is o1 This is o2 This is o3(b)
// (value = index) (values) (values)
// | \| | \| | \|
// 4 ----7---- 3 4 ----7---- 3 4 ----7---- 3
- // Build the complex
- for (unsigned i=0; i<num; ++i)
- c1.addSimplex(ss[i]);
-
c2 = c1;
c2.simplices[6].value = 12;
o2.reset();
o3.reset();
o3b.reset();
- o3b.makeMonotoneFiltration();
+ o3b.make_monotone_filtration();
}
virtual void tear_down() {
}
- void test_isComplex() {
- TEST_ASSERT(c1.isComplex());
- TEST_ASSERT(c2.isComplex());
- TEST_ASSERT(c3.isComplex());
+ void test_is_complex() {
+ TEST_ASSERT(c1.is_complex());
+ TEST_ASSERT(c2.is_complex());
+ TEST_ASSERT(c3.is_complex());
}
- void test_isMonotoneComplex() {
- TEST_ASSERT(c1.isMonotone());
- TEST_ASSERT(!c2.isMonotone());
- TEST_ASSERT(c3.isMonotone());
+ void test_is_monotoneComplex() {
+ TEST_ASSERT(c1.is_monotone());
+ TEST_ASSERT(!c2.is_monotone());
+ TEST_ASSERT(c3.is_monotone());
}
- void test_isOrderFiltration() {
- TEST_ASSERT(o1.isFiltration());
- TEST_ASSERT(o2.isFiltration());
- TEST_ASSERT(o3.isFiltration());
- TEST_ASSERT(o3b.isFiltration());
+ void test_is_order_filtration() {
+ TEST_ASSERT(o1.is_filtration());
+ TEST_ASSERT(o2.is_filtration());
+ TEST_ASSERT(o3.is_filtration());
+ TEST_ASSERT(o3b.is_filtration());
}
- void test_isOrderMonotone() {
- TEST_ASSERT(o1.isMonotone());
- TEST_ASSERT(!o2.isMonotone());
- TEST_ASSERT(!o3.isMonotone());
- TEST_ASSERT(o3b.isMonotone());
+ void test_is_order_monotone() {
+ TEST_ASSERT(o1.is_monotone());
+ TEST_ASSERT(!o2.is_monotone());
+ TEST_ASSERT(!o3.is_monotone());
+ TEST_ASSERT(o3b.is_monotone());
}
- void test_boundaryMatrix() {
- bm mat1 = o1.getBoundaryMatrix();
+ void test_boundary_matrix() {
+ bm mat1 = o1.get_boundary_matrix();
bm mat1e(c1.size());
- mat1e.set(0, 1, true);
- mat1e.set(0, 2, true);
- mat1e.set(0, 3, true);
- mat1e.set(0, 4, true);
- mat1e.set(1, 5, true);
- mat1e.set(2, 5, true);
- mat1e.set(2, 6, true);
- mat1e.set(3, 6, true);
- mat1e.set(3, 7, true);
- mat1e.set(4, 7, true);
- mat1e.set(4, 8, true);
- mat1e.set(1, 8, true);
- mat1e.set(1, 9, true);
- mat1e.set(3, 9, true);
- mat1e.set(7, 10, true);
- mat1e.set(8, 10, true);
- mat1e.set(9, 10, true);
- mat1e.set(5, 11, true);
- mat1e.set(6, 11, true);
- mat1e.set(9, 11, true);
+ uint32_t mat1e_coords[][2] = {
+ {0, 1}, {0, 2}, {0, 3}, {0, 4}, {1, 5}, {2, 5}, {2, 6}, {3, 6}, {3, 7}, {4, 7}, {1, 8}, {4, 8},
+ {1, 9}, {3, 9}, {7, 10}, {8, 10}, {9, 10}, {5, 11}, {6, 11}, {9, 11}
+ };
+ mat1e.set_all(mat1e_coords, sizeof(mat1e_coords)/(2*sizeof(uint32_t)), true);
TEST_ASSERT(mat1 == mat1e);
- bm mat3b = o3b.getBoundaryMatrix();
+
+ bm mat3b = o3b.get_boundary_matrix();
bm mat3be(c1.size());
- mat3be.set(0, 1, true);
- mat3be.set(0, 2, true);
- mat3be.set(0, 3, true);
- mat3be.set(0, 4, true);
- mat3be.set(1, 5, true);
- mat3be.set(2, 5, true);
- mat3be.set(3, 6, true);
- mat3be.set(4, 6, true);
- mat3be.set(4, 7, true);
- mat3be.set(1, 7, true);
- mat3be.set(1, 8, true);
- mat3be.set(3, 8, true);
- mat3be.set(6, 9, true);
- mat3be.set(7, 9, true);
- mat3be.set(8, 9, true);
- mat3be.set(2, 10, true);
- mat3be.set(3, 10, true);
- mat3be.set(5, 11, true);
- mat3be.set(8, 11, true);
- mat3be.set(10, 11, true);
+ uint32_t mat3be_coords[][2] = {
+ {0, 1}, {0, 2}, {0, 3}, {0, 4}, {1, 5}, {2, 5}, {3, 6}, {4, 6}, {1, 7}, {4, 7}, {1, 8}, {3, 8},
+ {6, 9}, {7, 9}, {8, 9}, {2, 10}, {3, 10}, {5, 11}, {8, 11}, {10, 11}
+ };
+ mat3be.set_all(mat3be_coords, sizeof(mat3be_coords)/(2*sizeof(uint32_t)), true);
TEST_ASSERT(mat3b == mat3be);
//std::cout << mat3b << std::endl << std::endl;
//std::cout << ((bm::colbase) mat3b) << std::endl << std::endl;
//std::cout << ((bm::rowbase) mat3b) << std::endl << std::endl;
}
-
- void test_matrixreduction() {
- bm b = o3b.getBoundaryMatrix();
- bm v = unitMatrix<bm>(b.size());
-
- bm b_orig = b;
- reduceBoundaryMatrix(b, v);
- TEST_ASSERT(b == b_orig*v);
-
- //std::cout << std::endl << "after reduce: " << std::endl;
- //std::cout << std::endl << b << std::endl;
- //std::cout << std::endl << v << std::endl;
- //std::cout << std::endl << (b_orig*v) << std::endl;
- }
};
#endif