From ce9d8f2bf7f8a9cb8e3b5414e228616fd8402b65 Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Fri, 3 Feb 2017 12:04:40 +0000 Subject: Add intervals in dimension function in cubical also git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/ST_cythonize@2056 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: c1fd5ee1283204c7bef96c5f6245e982657dc1cb --- src/cython/cython/cubical_complex.pyx | 22 +++++++++++++++++++++- src/cython/cython/periodic_cubical_complex.pyx | 22 +++++++++++++++++++++- 2 files changed, 42 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/cython/cython/cubical_complex.pyx b/src/cython/cython/cubical_complex.pyx index 321fc22a..d65d2060 100644 --- a/src/cython/cython/cubical_complex.pyx +++ b/src/cython/cython/cubical_complex.pyx @@ -44,7 +44,7 @@ cdef extern from "Persistent_cohomology_interface.h" namespace "Gudhi": vector[pair[int, pair[double, double]]] get_persistence(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) # CubicalComplex python interface cdef class CubicalComplex: @@ -175,3 +175,23 @@ cdef class CubicalComplex: if self.pcohptr != NULL: pbn_result = self.pcohptr.persistent_betti_numbers(from_value, to_value) return pbn_result + + def intervals_in_dim(self, dimension): + """This function returns the persistence intervals of the simplicial + complex in a specific dimension. + + :param dimension: The specific dimension. + :type from_value: int. + :returns: The persistence intervals. + :rtype: list of pair of float + + :note: betti_numbers function requires persistence function to be + launched first. + """ + cdef vector[pair[double,double]] intervals_result + if self.pcohptr != NULL: + intervals_result = self.pcohptr.intervals_in_dimension(dimension) + else: + print("intervals_in_dim function requires persistence function" + " to be launched first.") + return intervals_result diff --git a/src/cython/cython/periodic_cubical_complex.pyx b/src/cython/cython/periodic_cubical_complex.pyx index c1b25f31..9175ac47 100644 --- a/src/cython/cython/periodic_cubical_complex.pyx +++ b/src/cython/cython/periodic_cubical_complex.pyx @@ -44,7 +44,7 @@ cdef extern from "Persistent_cohomology_interface.h" namespace "Gudhi": vector[pair[int, pair[double, double]]] get_persistence(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) # PeriodicCubicalComplex python interface cdef class PeriodicCubicalComplex: @@ -175,3 +175,23 @@ cdef class PeriodicCubicalComplex: if self.pcohptr != NULL: pbn_result = self.pcohptr.persistent_betti_numbers(from_value, to_value) return pbn_result + + def intervals_in_dim(self, dimension): + """This function returns the persistence intervals of the simplicial + complex in a specific dimension. + + :param dimension: The specific dimension. + :type from_value: int. + :returns: The persistence intervals. + :rtype: list of pair of float + + :note: betti_numbers function requires persistence function to be + launched first. + """ + cdef vector[pair[double,double]] intervals_result + if self.pcohptr != NULL: + intervals_result = self.pcohptr.intervals_in_dimension(dimension) + else: + print("intervals_in_dim function requires persistence function" + " to be launched first.") + return intervals_result -- cgit v1.2.3