summaryrefslogtreecommitdiff
path: root/src/Persistent_cohomology/example/plain_homology.cpp
diff options
context:
space:
mode:
authorvrouvrea <vrouvrea@636b058d-ea47-450e-bf9e-a15bfbe3eedb>2016-05-26 21:03:43 +0000
committervrouvrea <vrouvrea@636b058d-ea47-450e-bf9e-a15bfbe3eedb>2016-05-26 21:03:43 +0000
commit24fddda9ca1d057c57b1ec9a3d24443c3e1abbf9 (patch)
tree8763960d6b5f3a6c4951e5e979a4fcfce793bb12 /src/Persistent_cohomology/example/plain_homology.cpp
parent0741cec5900f05b57f1aacffcef248fab911d27d (diff)
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
Diffstat (limited to 'src/Persistent_cohomology/example/plain_homology.cpp')
-rw-r--r--src/Persistent_cohomology/example/plain_homology.cpp44
1 files changed, 1 insertions, 43 deletions
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<MyOptions> 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<typename Persistent_interval>
- 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<int> 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;
- }
-
-
}