summaryrefslogtreecommitdiff
path: root/src/Witness_complex/test/test_simple_witness_complex.cpp
diff options
context:
space:
mode:
authorskachano <skachano@636b058d-ea47-450e-bf9e-a15bfbe3eedb>2016-10-05 17:06:15 +0000
committerskachano <skachano@636b058d-ea47-450e-bf9e-a15bfbe3eedb>2016-10-05 17:06:15 +0000
commitd439da1345822fe25f58adb631f7d0cd9749ecfc (patch)
treea269adbedb7e719ce75855ef0e9064b9d5c782e7 /src/Witness_complex/test/test_simple_witness_complex.cpp
parent93654d5708654a6071c1775580f625da625a08a8 (diff)
Modified existing tests and examples
git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/relaxed-witness@1647 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: cd187fe5bc9174403aa5dc96c74871c697b3a5e6
Diffstat (limited to 'src/Witness_complex/test/test_simple_witness_complex.cpp')
-rw-r--r--src/Witness_complex/test/test_simple_witness_complex.cpp103
1 files changed, 103 insertions, 0 deletions
diff --git a/src/Witness_complex/test/test_simple_witness_complex.cpp b/src/Witness_complex/test/test_simple_witness_complex.cpp
new file mode 100644
index 00000000..abd0a0dd
--- /dev/null
+++ b/src/Witness_complex/test/test_simple_witness_complex.cpp
@@ -0,0 +1,103 @@
+/* This file is part of the Gudhi Library. The Gudhi library
+ * (Geometric Understanding in Higher Dimensions) is a generic C++
+ * library for computational topology.
+ *
+ * Author(s): Siargey Kachanovich
+ *
+ * Copyright (C) 2016 INRIA Sophia Antipolis-Méditerranée (France)
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#define BOOST_TEST_DYN_LINK
+#define BOOST_TEST_MODULE "simple_witness_complex"
+#include <boost/test/unit_test.hpp>
+#include <boost/mpl/list.hpp>
+
+#include <CGAL/Epick_d.h>
+
+#include <gudhi/Simplex_tree.h>
+#include <gudhi/Witness_complex.h>
+#include <gudhi/Strong_witness_complex.h>
+
+#include <iostream>
+#include <ctime>
+#include <vector>
+
+typedef Gudhi::Simplex_tree<> Simplex_tree;
+typedef std::vector< Vertex_handle > typeVectorVertex;
+typedef CGAL::Epick_d<CGAL::Dynamic_dimension_tag> Kernel;
+typedef typename Kernel::FT FT;
+typedef typename Kernel::Point_d Point_d;
+typedef Gudhi::witness_complex::Witness_complex<Kernel> WitnessComplex;
+typedef Gudhi::witness_complex::Strong_witness_complex<Kernel> StrongWitnessComplex;
+
+/* All landmarks and witnesses are taken on the grid in the following manner.
+ LWLWL
+ WW.WW
+ L...L
+ WW.WW
+ LWLWL
+
+ Witness complex consists of 8 vertices, 12 edges and 4 triangles
+ */
+
+BOOST_AUTO_TEST_CASE(simple_witness_complex) {
+ Simplex_tree complex, relaxed_complex, strong_relaxed_complex;
+
+ std::vector<Point_d> witnesses, landmarks;
+
+ landmarks.push_back(Point_d(std::vector<FT>{-2,-2}));
+ landmarks.push_back(Point_d(std::vector<FT>{-2, 0}));
+ landmarks.push_back(Point_d(std::vector<FT>{-2, 2}));
+ landmarks.push_back(Point_d(std::vector<FT>{ 0,-2}));
+ landmarks.push_back(Point_d(std::vector<FT>{ 0, 2}));
+ landmarks.push_back(Point_d(std::vector<FT>{ 2,-2}));
+ landmarks.push_back(Point_d(std::vector<FT>{ 2, 0}));
+ landmarks.push_back(Point_d(std::vector<FT>{ 2, 2}));
+ witnesses.push_back(Point_d(std::vector<FT>{-2,-1}));
+ witnesses.push_back(Point_d(std::vector<FT>{-2, 1}));
+ witnesses.push_back(Point_d(std::vector<FT>{-1,-2}));
+ witnesses.push_back(Point_d(std::vector<FT>{-1,-1}));
+ witnesses.push_back(Point_d(std::vector<FT>{-1, 1}));
+ witnesses.push_back(Point_d(std::vector<FT>{-1, 2}));
+ witnesses.push_back(Point_d(std::vector<FT>{ 1,-2}));
+ witnesses.push_back(Point_d(std::vector<FT>{ 1,-1}));
+ witnesses.push_back(Point_d(std::vector<FT>{ 1, 1}));
+ witnesses.push_back(Point_d(std::vector<FT>{ 1, 2}));
+ witnesses.push_back(Point_d(std::vector<FT>{ 2,-1}));
+ witnesses.push_back(Point_d(std::vector<FT>{ 2, 1}));
+
+ WitnessComplex witness_complex(landmarks.begin(),
+ landmarks.end(),
+ witnesses.begin(),
+ witnesses.end());
+ witness_complex.create_complex(complex, 0);
+
+ BOOST_CHECK(complex.num_simplices() == 24);
+
+ witness_complex.create_complex(relaxed_complex, 8.01);
+
+ BOOST_CHECK(relaxed_complex.num_simplices() == 239);
+
+ StrongWitnessComplex strong_witness_complex(landmarks.begin(),
+ landmarks.end(),
+ witnesses.begin(),
+ witnesses.end());
+
+ strong_witness_complex.create_complex(strong_relaxed_complex, 9.1);
+
+ BOOST_CHECK(strong_relaxed_complex.num_simplices() == 239);
+
+}