summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorvrouvrea <vrouvrea@636b058d-ea47-450e-bf9e-a15bfbe3eedb>2016-05-18 10:27:49 +0000
committervrouvrea <vrouvrea@636b058d-ea47-450e-bf9e-a15bfbe3eedb>2016-05-18 10:27:49 +0000
commitaf8482fa911750dca5f65b702489e63f3ceb86c7 (patch)
tree4f25e4e17246a767c369443d395ed4c3d8fd8433 /src
parent7eb4beac61db2ba22fa0293ac816da87d98ffeff (diff)
Persistence for Simplex tree
git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/ST_cythonize@1180 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: a27f6deac2f5fffe99a91417af7bb74872f692e0
Diffstat (limited to 'src')
-rwxr-xr-xsrc/cython/example/Simplex_tree_example.py2
-rw-r--r--src/cython/src/cpp/Persistent_cohomology_interface.h46
-rw-r--r--src/cython/src/cython/Simplex_tree.pyx12
3 files changed, 59 insertions, 1 deletions
diff --git a/src/cython/example/Simplex_tree_example.py b/src/cython/example/Simplex_tree_example.py
index 119fbc65..90a4a433 100755
--- a/src/cython/example/Simplex_tree_example.py
+++ b/src/cython/example/Simplex_tree_example.py
@@ -38,6 +38,8 @@ print("skeleton_tree[2]=", st.get_skeleton_tree(2))
print("skeleton_tree[1]=", st.get_skeleton_tree(1))
print("skeleton_tree[0]=", st.get_skeleton_tree(0))
+print("persistence(2)=", st.persistence(2))
+
print("#######################################################################")
print("MiniSimplexTree creation from insertion")
triangle012 = [0, 1, 2]
diff --git a/src/cython/src/cpp/Persistent_cohomology_interface.h b/src/cython/src/cpp/Persistent_cohomology_interface.h
new file mode 100644
index 00000000..79c6ce06
--- /dev/null
+++ b/src/cython/src/cpp/Persistent_cohomology_interface.h
@@ -0,0 +1,46 @@
+/* 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): Vincent Rouvreau
+ *
+ * Copyright (C) 2016 INRIA Saclay (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/>.
+ */
+
+#ifndef PERSISTENT_COHOMOLOGY_INTERFACE_H
+#define PERSISTENT_COHOMOLOGY_INTERFACE_H
+
+#include <gudhi/Persistent_cohomology.h>
+
+namespace Gudhi {
+
+template<typename SimplexTreeOptions = Simplex_tree_options_full_featured>
+class Persistent_cohomology_interface : public
+persistent_cohomology::Persistent_cohomology<Simplex_tree<SimplexTreeOptions>,persistent_cohomology::Field_Zp> {
+ public:
+ Persistent_cohomology_interface(Simplex_tree<SimplexTreeOptions>* stptr)
+ : persistent_cohomology::Persistent_cohomology<Simplex_tree<SimplexTreeOptions>,persistent_cohomology::Field_Zp>(*stptr) { }
+ void get_persistence(int homology_coeff_field, double min_persistence) {
+ persistent_cohomology::Persistent_cohomology<Simplex_tree<SimplexTreeOptions>,persistent_cohomology::Field_Zp>::init_coefficients(homology_coeff_field);
+ persistent_cohomology::Persistent_cohomology<Simplex_tree<SimplexTreeOptions>,persistent_cohomology::Field_Zp>::compute_persistent_cohomology(min_persistence);
+ persistent_cohomology::Persistent_cohomology<Simplex_tree<SimplexTreeOptions>,persistent_cohomology::Field_Zp>::output_diagram();
+ }
+};
+
+} // namespace Gudhi
+
+#endif // PERSISTENT_COHOMOLOGY_INTERFACE_H
+
diff --git a/src/cython/src/cython/Simplex_tree.pyx b/src/cython/src/cython/Simplex_tree.pyx
index 819ae5f0..b1689679 100644
--- a/src/cython/src/cython/Simplex_tree.pyx
+++ b/src/cython/src/cython/Simplex_tree.pyx
@@ -48,6 +48,11 @@ cdef extern from "Simplex_tree_interface.h" namespace "Gudhi":
vector[pair[vector[int], double]] get_coface_tree(vector[int] simplex, int dimension)
void remove_maximal_simplex(vector[int] simplex)
+cdef extern from "Persistent_cohomology_interface.h" namespace "Gudhi":
+ cdef cppclass Persistent_cohomology_interface_full_featured "Gudhi::Persistent_cohomology_interface<Gudhi::Simplex_tree_options_full_featured>":
+ Persistent_cohomology_interface_full_featured(Simplex_tree_interface_full_featured* st)
+ void get_persistence(int homology_coeff_field, double min_persistence)
+
# SimplexTree python interface
cdef class SimplexTree:
cdef Simplex_tree_interface_full_featured *thisptr
@@ -126,7 +131,12 @@ cdef class SimplexTree:
return ct
def remove_maximal_simplex(self, simplex):
self.thisptr.remove_maximal_simplex(simplex)
-
+ def persistence(self, homology_coeff_field, min_persistence = 0):
+ cdef Persistent_cohomology_interface_full_featured *pcohptr = new Persistent_cohomology_interface_full_featured(self.thisptr)
+ if pcohptr != NULL:
+ pcohptr.get_persistence(homology_coeff_field, min_persistence)
+ del pcohptr
+ return 5
cdef extern from "Simplex_tree_interface.h" namespace "Gudhi":
cdef cppclass Simplex_tree_options_mini: