summaryrefslogtreecommitdiff
path: root/src/python/gudhi/cubical_complex.pyx
diff options
context:
space:
mode:
Diffstat (limited to 'src/python/gudhi/cubical_complex.pyx')
-rw-r--r--src/python/gudhi/cubical_complex.pyx30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/python/gudhi/cubical_complex.pyx b/src/python/gudhi/cubical_complex.pyx
index 007abcb6..69d0f0b6 100644
--- a/src/python/gudhi/cubical_complex.pyx
+++ b/src/python/gudhi/cubical_complex.pyx
@@ -37,6 +37,7 @@ cdef extern from "Persistent_cohomology_interface.h" namespace "Gudhi":
Cubical_complex_persistence_interface(Bitmap_cubical_complex_base_interface * st, bool persistence_dim_max)
void compute_persistence(int homology_coeff_field, double min_persistence)
vector[pair[int, pair[double, double]]] get_persistence()
+ vector[vector[int]] cofaces_of_cubical_persistence_pairs()
vector[int] betti_numbers()
vector[int] persistent_betti_numbers(double from_value, double to_value)
vector[pair[double,double]] intervals_in_dimension(int dimension)
@@ -170,6 +171,35 @@ cdef class CubicalComplex:
self.compute_persistence(homology_coeff_field, min_persistence)
return self.pcohptr.get_persistence()
+ def cofaces_of_persistence_pairs(self):
+ """A persistence interval is described by a pair of cells, one that creates the
+ feature and one that kills it. The filtration values of those 2 cells give coordinates
+ for a point in a persistence diagram, or a bar in a barcode. Structurally, in the
+ cubical complexes provided here, the filtration value of any cell is the minimum of the
+ filtration values of the maximal cells that contain it. Connecting persistence diagram
+ coordinates to the corresponding value in the input (i.e. the filtration values of
+ the top-dimensional cells) is useful for differentiation purposes.
+
+ This function returns a list of pairs of top-dimensional cells corresponding to
+ the persistence birth and death cells of the filtration. The cells are represented by
+ their indices in the input list of top-dimensional cells (and not their indices in the
+ internal datastructure that includes non-maximal cells). Note that when two adjacent
+ top-dimensional cells have the same filtration value, we arbitrarily return one of the two
+ when calling the function on one of their common faces.
+
+ :returns: The top-dimensional cells/cofaces of the positive and negative cells, together with the corresponding homological dimension.
+ :rtype: numpy array of integers of shape [number_of_persistence_points, 3], the integers of eah row being: (homological dimension,
+ index of positive top-dimensional cell, index of negative top-dimensional cell). If the homological feature is essential, i.e., if
+ the death time is +infinity, then the index of the corresponding negative top-dimensional cell is -1.
+ """
+ cdef vector[vector[int]] persistence_result
+ if self.pcohptr != NULL:
+ persistence_result = self.pcohptr.cofaces_of_cubical_persistence_pairs()
+ else:
+ print("cofaces_of_persistence_pairs function requires persistence function"
+ " to be launched first.")
+ return np.array(persistence_result)
+
def betti_numbers(self):
"""This function returns the Betti numbers of the complex.