From 24fddda9ca1d057c57b1ec9a3d24443c3e1abbf9 Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Thu, 26 May 2016 21:03:43 +0000 Subject: Add doc, examples and unitary tests git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/get_persistence@1213 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: dc7980ef3f1baef17f2e42770da146d6c961e672 --- .../example/plain_homology.cpp | 44 +--------------------- 1 file changed, 1 insertion(+), 43 deletions(-) (limited to 'src/Persistent_cohomology/example/plain_homology.cpp') diff --git a/src/Persistent_cohomology/example/plain_homology.cpp b/src/Persistent_cohomology/example/plain_homology.cpp index 9e5adb5d..5afce9e2 100644 --- a/src/Persistent_cohomology/example/plain_homology.cpp +++ b/src/Persistent_cohomology/example/plain_homology.cpp @@ -42,24 +42,6 @@ struct MyOptions : Simplex_tree_options_full_featured { }; typedef Simplex_tree ST; - /* - * Compare two intervals by dimension, then by length. - */ - struct cmp_intervals_by_dim_then_length { - explicit cmp_intervals_by_dim_then_length(ST * sc) - : sc_(sc) { - } - template - bool operator()(const Persistent_interval & p1, const Persistent_interval & p2) { - if (sc_->dimension(get < 0 > (p1)) == sc_->dimension(get < 0 > (p2))) - return (sc_->filtration(get < 1 > (p1)) - sc_->filtration(get < 0 > (p1)) - > sc_->filtration(get < 1 > (p2)) - sc_->filtration(get < 0 > (p2))); - else - return (sc_->dimension(get < 0 > (p1)) > sc_->dimension(get < 0 > (p2))); - } - ST* sc_; - }; - int main() { ST st; @@ -102,34 +84,10 @@ int main() { pcoh.output_diagram(); - // ******************************************************** - // get_persistence - // ******************************************************** - std::cout << std::endl; + // Print the Betti numbers are b0=2 and b1=1. std::cout << std::endl; - - // First version - std::vector betti_numbers = pcoh.betti_numbers(); - std::cout << "The Betti numbers are : "; - for (std::size_t i = 0; i < betti_numbers.size(); i++) - std::cout << "b" << i << " = " << betti_numbers[i] << " ; "; - std::cout << std::endl; - - // Second version std::cout << "The Betti numbers are : "; for (int i = 0; i < st.dimension(); i++) std::cout << "b" << i << " = " << pcoh.betti_number(i) << " ; "; std::cout << std::endl; - - // Get persistence - cmp_intervals_by_dim_then_length cmp(&st); - auto persistent_pairs = pcoh.get_persistent_pairs(); - std::sort(std::begin(persistent_pairs), std::end(persistent_pairs), cmp); - for (auto pair : persistent_pairs) { - std::cout << st.dimension(get<0>(pair)) << " " - << st.filtration(get<0>(pair)) << " " - << st.filtration(get<1>(pair)) << std::endl; - } - - } -- cgit v1.2.3