diff options
author | skachano <skachano@636b058d-ea47-450e-bf9e-a15bfbe3eedb> | 2017-01-19 17:29:29 +0000 |
---|---|---|
committer | skachano <skachano@636b058d-ea47-450e-bf9e-a15bfbe3eedb> | 2017-01-19 17:29:29 +0000 |
commit | 49d726423c3f270f542ca93d43387e0dbcdd0ca9 (patch) | |
tree | cffa8ed298a2a8c1dc86b1225f5077ebd2af060c /src/Witness_complex/example | |
parent | c783096ff58ac63f47d367e58ded30a83da40cd3 (diff) |
Added an example with nearest landmark table. It is buggy.
git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/relaxed-witness@1966 636b058d-ea47-450e-bf9e-a15bfbe3eedb
Former-commit-id: 63ec7e948686d1f8c43576bab5a892ad816ffed4
Diffstat (limited to 'src/Witness_complex/example')
-rw-r--r-- | src/Witness_complex/example/CMakeLists.txt | 3 | ||||
-rw-r--r-- | src/Witness_complex/example/example_nearest_landmark_table.cpp | 50 |
2 files changed, 53 insertions, 0 deletions
diff --git a/src/Witness_complex/example/CMakeLists.txt b/src/Witness_complex/example/CMakeLists.txt index 848239b5..2bae07d9 100644 --- a/src/Witness_complex/example/CMakeLists.txt +++ b/src/Witness_complex/example/CMakeLists.txt @@ -13,9 +13,12 @@ if(CGAL_FOUND) add_executable ( Witness_complex_example_strong_witness_persistence example_strong_witness_persistence.cpp ) target_link_libraries(Witness_complex_example_strong_witness_persistence ${Boost_PROGRAM_OPTIONS_LIBRARY}) + + add_executable ( Witness_complex_example_nearest_landmark_table example_nearest_landmark_table.cpp ) if (TBB_FOUND) target_link_libraries(Witness_complex_example_witness_persistence ${TBB_LIBRARIES}) target_link_libraries(Witness_complex_example_strong_witness_persistence ${TBB_LIBRARIES}) + target_link_libraries(Witness_complex_example_nearest_landmark_table ${TBB_LIBRARIES}) endif() add_test(Witness_complex_test_torus_persistence diff --git a/src/Witness_complex/example/example_nearest_landmark_table.cpp b/src/Witness_complex/example/example_nearest_landmark_table.cpp new file mode 100644 index 00000000..00ec17e0 --- /dev/null +++ b/src/Witness_complex/example/example_nearest_landmark_table.cpp @@ -0,0 +1,50 @@ +#define BOOST_PARAMETER_MAX_ARITY 12 + + +#include <sys/types.h> +#include <sys/stat.h> + +#include <gudhi/Simplex_tree.h> +#include <gudhi/Witness_complex.h> +#include <gudhi/reader_utils.h> +#include <gudhi/Persistent_cohomology.h> + +#include <CGAL/Epick_d.h> + +#include <iostream> +#include <fstream> +#include <ctime> +#include <utility> +#include <string> +#include <vector> + +int main(int argc, char * const argv[]) { + typedef std::vector<std::pair<std::size_t, double>> Nearest_landmark_range; + typedef std::vector<Nearest_landmark_range> Nearest_landmark_table; + typedef Gudhi::witness_complex::Witness_complex<Nearest_landmark_table> Witness_complex; + + Gudhi::Simplex_tree<> simplex_tree; + Nearest_landmark_table nlt; + + // Example contains 10 witnesses and 5 landmarks + Nearest_landmark_range w0 = {std::make_pair(0,0), std::make_pair(1,1), std::make_pair(2,2), std::make_pair(3,3), std::make_pair(4,4)}; nlt.push_back(w0); + Nearest_landmark_range w1 = {std::make_pair(1,0), std::make_pair(2,1), std::make_pair(3,2), std::make_pair(4,3), std::make_pair(0,4)}; nlt.push_back(w1); + Nearest_landmark_range w2 = {std::make_pair(2,0), std::make_pair(3,1), std::make_pair(4,2), std::make_pair(0,3), std::make_pair(1,4)}; nlt.push_back(w2); + Nearest_landmark_range w3 = {std::make_pair(3,0), std::make_pair(4,1), std::make_pair(0,2), std::make_pair(1,3), std::make_pair(2,4)}; nlt.push_back(w3); + Nearest_landmark_range w4 = {std::make_pair(4,0), std::make_pair(0,1), std::make_pair(1,2), std::make_pair(2,3), std::make_pair(3,4)}; nlt.push_back(w4); + Nearest_landmark_range x0 = {std::make_pair(0,0), std::make_pair(4,1), std::make_pair(3,2), std::make_pair(2,3), std::make_pair(1,4)}; nlt.push_back(x0); + Nearest_landmark_range x1 = {std::make_pair(1,0), std::make_pair(0,1), std::make_pair(4,2), std::make_pair(3,3), std::make_pair(2,4)}; nlt.push_back(x1); + Nearest_landmark_range x2 = {std::make_pair(2,0), std::make_pair(1,1), std::make_pair(0,2), std::make_pair(4,3), std::make_pair(3,4)}; nlt.push_back(x2); + Nearest_landmark_range x3 = {std::make_pair(3,0), std::make_pair(2,1), std::make_pair(1,2), std::make_pair(0,3), std::make_pair(4,4)}; nlt.push_back(x3); + Nearest_landmark_range x4 = {std::make_pair(4,0), std::make_pair(3,1), std::make_pair(2,2), std::make_pair(1,3), std::make_pair(0,4)}; nlt.push_back(x4); + + Witness_complex witness_complex(nlt); + witness_complex.create_complex(simplex_tree, 4.1); + + Gudhi::persistent_cohomology::Persistent_cohomology<Gudhi::Simplex_tree<>, Gudhi::persistent_cohomology::Field_Zp > pcoh(simplex_tree); + // initializes the coefficient field for homology + pcoh.init_coefficients(11); + + pcoh.compute_persistent_cohomology(-0.1); + pcoh.output_diagram(); +} |