summaryrefslogtreecommitdiff
path: root/src/python/gudhi/cubical_complex.pyx
diff options
context:
space:
mode:
authormathieu <mathieu.carriere3@gmail.com>2020-01-16 15:46:41 -0500
committermathieu <mathieu.carriere3@gmail.com>2020-01-16 15:46:41 -0500
commit436a7fbe36a9de6a969afd5978c3d496773a8690 (patch)
treea753b0c4c0648bac78b8e8b9cf11f1522866bd32 /src/python/gudhi/cubical_complex.pyx
parentcabc43b34723efa7640313348b844eabe9971e38 (diff)
added wrapper functions
Diffstat (limited to 'src/python/gudhi/cubical_complex.pyx')
-rw-r--r--src/python/gudhi/cubical_complex.pyx29
1 files changed, 28 insertions, 1 deletions
diff --git a/src/python/gudhi/cubical_complex.pyx b/src/python/gudhi/cubical_complex.pyx
index cbeda014..5562e8a7 100644
--- a/src/python/gudhi/cubical_complex.pyx
+++ b/src/python/gudhi/cubical_complex.pyx
@@ -31,6 +31,7 @@ cdef extern from "Persistent_cohomology_interface.h" namespace "Gudhi":
cdef cppclass Cubical_complex_persistence_interface "Gudhi::Persistent_cohomology_interface<Gudhi::Cubical_complex::Cubical_complex_interface<>>":
Cubical_complex_persistence_interface(Bitmap_cubical_complex_base_interface * st, bool persistence_dim_max)
vector[pair[int, pair[double, double]]] get_persistence(int homology_coeff_field, double min_persistence)
+ vector[pair[int, pair[pair[double, int], pair[double, int]]]] get_persistence_cubical_generators(int homology_coeff_field, double min_persistence)
vector[int] betti_numbers()
vector[int] persistent_betti_numbers(double from_value, double to_value)
vector[pair[double,double]] intervals_in_dimension(int dimension)
@@ -85,7 +86,7 @@ cdef class CubicalComplex:
elif ((dimensions is None) and (top_dimensional_cells is None)
and (perseus_file != '')):
if os.path.isfile(perseus_file):
- self.thisptr = new Bitmap_cubical_complex_base_interface(perseus_file.encode('utf-8'))
+ self.thisptr = new Bitmap_cubical_complex_base_interface(str.encode(perseus_file))
else:
print("file " + perseus_file + " not found.")
else:
@@ -145,6 +146,32 @@ cdef class CubicalComplex:
persistence_result = self.pcohptr.get_persistence(homology_coeff_field, min_persistence)
return persistence_result
+ def persistence_generators(self, homology_coeff_field=11, min_persistence=0, persistence_dim_max = False):
+ """This function returns the persistence of the simplicial complex.
+
+ :param homology_coeff_field: The homology coefficient field. Must be a
+ prime number. Default value is 11.
+ :type homology_coeff_field: int.
+ :param min_persistence: The minimum persistence value to take into
+ account (strictly greater than min_persistence). Default value is
+ 0.0.
+ Sets min_persistence to -1.0 to see all values.
+ :type min_persistence: float.
+ :param persistence_dim_max: If true, the persistent homology for the
+ maximal dimension in the complex is computed. If false, it is
+ ignored. Default is false.
+ :type persistence_dim_max: bool
+ :returns: The persistence of the simplicial complex, together with the corresponding generators, i.e., the positive and negative top-dimensional cells.
+ :rtype: list of pairs(dimension, pair(index of positive top-dimensional cell, index of negative top-dimensional cell))
+ """
+ if self.pcohptr != NULL:
+ del self.pcohptr
+ self.pcohptr = new Cubical_complex_persistence_interface(self.thisptr, True)
+ cdef vector[pair[int, pair[pair[double, int], pair[double, int]]]] persistence_result
+ if self.pcohptr != NULL:
+ persistence_result = self.pcohptr.get_persistence_cubical_generators(homology_coeff_field, min_persistence)
+ return persistence_result
+
def betti_numbers(self):
"""This function returns the Betti numbers of the complex.