X-Git-Url: https://git.sthu.org/?p=libstick.git;a=blobdiff_plain;f=tests%2Fsimplicialcomplex.h;h=1c8f9496f41a83e4b76e8c9ea0a0f51c53a38781;hp=da0dfb5bd59d5e19b13a6b896615db8a4976400f;hb=7186ae9cc97393496d7f0e0cb281524276f1e47c;hpb=d6673c66ae1cb2b421b6e0c4b6a2f6ea6f0fad98 diff --git a/tests/simplicialcomplex.h b/tests/simplicialcomplex.h index da0dfb5..1c8f949 100644 --- a/tests/simplicialcomplex.h +++ b/tests/simplicialcomplex.h @@ -12,23 +12,26 @@ using namespace libstick; class simplicial_complex_TestSuite: public Test::Suite { private: - typedef simplicial_complex<3, uint32_t, double> scomplex; + typedef simplicial_function<3, uint32_t, double> sfunction; + typedef sfunction::simplcompltype scomplex; typedef scomplex::simplex_order::boundary_matrix bm; bool setupcalled; - scomplex c1, c2, c3; - scomplex::simplex_order o1, o2, o3, o3b; + scomplex c; + sfunction f1, f2, f3; + scomplex::simplex_order o1, o3b; public: simplicial_complex_TestSuite() : setupcalled(false), - o1(c1), - o2(c2), - o3(c3), - o3b(c3) + f1(c), + f2(c), + f3(c), + o1(c), + o3b(c) { TEST_ADD(simplicial_complex_TestSuite::test_is_complex); - TEST_ADD(simplicial_complex_TestSuite::test_is_monotoneComplex); + TEST_ADD(simplicial_complex_TestSuite::test_is_function_monotone); 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); @@ -40,24 +43,26 @@ class simplicial_complex_TestSuite: public Test::Suite { return; setupcalled = true; - scomplex::simplex ss[] = { - // dimension, faces, value... - {0, {}, 1}, - {0, {}, 2}, - {0, {}, 3}, - {0, {}, 4}, - {1, {1, 2}, 5}, - {1, {2, 3}, 6}, - {1, {3, 4}, 7}, - {1, {4, 1}, 8}, - {1, {1, 3}, 9}, - {2, {7, 8, 9}, 10}, - {2, {5, 6, 9}, 11} + typedef sfunction::valuedsimplex vsimpl; + + sfunction::valuedsimplex ss[] = { + // {dimension, faces}, value + {{0, {}}, 1}, + {{0, {}}, 2}, + {{0, {}}, 3}, + {{0, {}}, 4}, + {{1, {1, 2}}, 5}, + {{1, {2, 3}}, 6}, + {{1, {3, 4}}, 7}, + {{1, {4, 1}}, 8}, + {{1, {1, 3}}, 9}, + {{2, {7, 8, 9}}, 10}, + {{2, {5, 6, 9}}, 11} }; - const size_t cntss = sizeof(ss)/sizeof(scomplex::simplex); - c1.add_simplices(ss, cntss); + const size_t cntss = sizeof(ss)/sizeof(sfunction::valuedsimplex); + f1.add_simplices(ss, cntss); - // This is o1 This is o2 This is o3(b) + // This is f1 This is f2 This is f3 // (value = index) (values) (values) // // 1 ----5---- 2 1 ----5---- 2 1 ----5---- 2 @@ -72,51 +77,47 @@ class simplicial_complex_TestSuite: public Test::Suite { // | \| | \| | \| // 4 ----7---- 3 4 ----7---- 3 4 ----7---- 3 - c2 = c1; - c2.simplices[6].value = 12; + // Copy and change the function values + f2.set_values(f1.get_values()); + f2.set_value(6, 12); - c3 = c2; - c3.simplices[11].value = 13; + f3.set_values(f2.get_values()); + f3.set_value(11, 13); + // Get two orders, the one is a monotone filtration o1.reset(); - o2.reset(); - o3.reset(); o3b.reset(); - o3b.make_monotone_filtration(); + f3.make_order_monotonefiltration(o3b); } virtual void tear_down() { } void test_is_complex() { - TEST_ASSERT(c1.is_complex()); - TEST_ASSERT(c2.is_complex()); - TEST_ASSERT(c3.is_complex()); + TEST_ASSERT(c.is_complex()); } - void test_is_monotoneComplex() { - TEST_ASSERT(c1.is_monotone()); - TEST_ASSERT(!c2.is_monotone()); - TEST_ASSERT(c3.is_monotone()); + void test_is_function_monotone() { + TEST_ASSERT(f1.is_monotone()); + TEST_ASSERT(!f2.is_monotone()); + TEST_ASSERT(f3.is_monotone()); } 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_is_order_monotone() { - TEST_ASSERT(o1.is_monotone()); - TEST_ASSERT(!o2.is_monotone()); - TEST_ASSERT(!o3.is_monotone()); - TEST_ASSERT(o3b.is_monotone()); + TEST_ASSERT(f1.is_order_monotonefiltration(o1)); + TEST_ASSERT(!f2.is_order_monotonefiltration(o1)); + TEST_ASSERT(!f3.is_order_monotonefiltration(o1)); + TEST_ASSERT(f3.is_order_monotonefiltration(o3b)); } void test_boundary_matrix() { bm mat1 = o1.get_boundary_matrix(); - bm mat1e(c1.size()); + bm mat1e(c.size()); 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} @@ -126,7 +127,7 @@ class simplicial_complex_TestSuite: public Test::Suite { bm mat3b = o3b.get_boundary_matrix(); - bm mat3be(c1.size()); + bm mat3be(c.size()); 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}