summaryrefslogtreecommitdiff
path: root/src/python
diff options
context:
space:
mode:
authorMathieuCarriere <mathieu.carriere3@gmail.com>2020-03-19 17:02:55 -0400
committerMathieuCarriere <mathieu.carriere3@gmail.com>2020-03-19 17:02:55 -0400
commit361abfcfa9ec18c76837f847f8e2e3a060cf7db7 (patch)
tree159948d60884caa4993a9b4bd5924d87a29170b2 /src/python
parent61691b0081cb868645335c0b1433ddcc0bcbf9e3 (diff)
added decoding function
Diffstat (limited to 'src/python')
-rw-r--r--src/python/gudhi/simplex_tree.pyx10
-rw-r--r--src/python/include/Simplex_tree_interface.h27
2 files changed, 29 insertions, 8 deletions
diff --git a/src/python/gudhi/simplex_tree.pyx b/src/python/gudhi/simplex_tree.pyx
index 3502000a..2cd81c14 100644
--- a/src/python/gudhi/simplex_tree.pyx
+++ b/src/python/gudhi/simplex_tree.pyx
@@ -415,9 +415,9 @@ cdef class SimplexTree:
"""
return self.get_ptr().compute_extended_filtration()
- def extended_persistence(self, homology_coeff_field=11, min_persistence=0, persistence_dim_max = False):
+ def extended_persistence(self, homology_coeff_field=11, min_persistence=0):
"""This function retrieves good values for extended persistence, and separate the diagrams
- into the ordinary, relative, extended+ and extended- subdiagrams.
+ into the Ordinary, Relative, Extended+ and Extended- subdiagrams.
:param homology_coeff_field: The homology coefficient field. Must be a
prime number. Default value is 11.
@@ -427,10 +427,6 @@ cdef class SimplexTree:
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: A vector of four persistence diagrams. The first one is Ordinary, the second one is Relative, the third one is Extended+ and the fourth one is Extended-. See section 2.2 in https://link.springer.com/article/10.1007/s10208-017-9370-z for a description of these subtypes.
.. note::
@@ -447,7 +443,7 @@ cdef class SimplexTree:
"""
cdef vector[pair[int, pair[double, double]]] persistence_result
if self.pcohptr == NULL:
- self.pcohptr = new Simplex_tree_persistence_interface(self.get_ptr(), persistence_dim_max)
+ self.pcohptr = new Simplex_tree_persistence_interface(self.get_ptr(), True)
if self.pcohptr != NULL:
self.pcohptr.get_persistence(homology_coeff_field, min_persistence)
if self.pcohptr != NULL:
diff --git a/src/python/include/Simplex_tree_interface.h b/src/python/include/Simplex_tree_interface.h
index 50ed58d0..a6b1a06e 100644
--- a/src/python/include/Simplex_tree_interface.h
+++ b/src/python/include/Simplex_tree_interface.h
@@ -38,6 +38,7 @@ class Simplex_tree_interface : public Simplex_tree<SimplexTreeOptions> {
using Skeleton_simplex_iterator = typename Base::Skeleton_simplex_iterator;
using Complex_simplex_iterator = typename Base::Complex_simplex_iterator;
using Extended_filtration_data = typename Base::Extended_filtration_data;
+ using Extended_simplex_type = typename Base::Extended_simplex_type;
public:
@@ -127,7 +128,31 @@ class Simplex_tree_interface : public Simplex_tree<SimplexTreeOptions> {
}
std::vector<std::vector<std::pair<int, std::pair<Filtration_value, Filtration_value>>>> compute_extended_persistence_subdiagrams(const std::vector<std::pair<int, std::pair<Filtration_value, Filtration_value>>>& dgm){
- return this->extended_persistence_subdiagrams(dgm, this->efd);
+ std::vector<std::vector<std::pair<int, std::pair<Filtration_value, Filtration_value>>>> new_dgm(4);
+ for (unsigned int i = 0; i < dgm.size(); i++){
+ std::pair<Filtration_value, Extended_simplex_type> px = this->decode_extended_filtration(dgm[i].second.first, this->efd);
+ std::pair<Filtration_value, Extended_simplex_type> py = this->decode_extended_filtration(dgm[i].second.second, this->efd);
+ std::pair<int, std::pair<Filtration_value, Filtration_value>> pd_point = std::make_pair(dgm[i].first, std::make_pair(px.first, py.first));
+ //Ordinary
+ if (px.second == Base::UP && py.second == Base::UP){
+ new_dgm[0].push_back(pd_point);
+ }
+ // Relative
+ else if (px.second == Base::DOWN && py.second == Base::DOWN){
+ new_dgm[1].push_back(pd_point);
+ }
+ else{
+ // Extended+
+ if (px.first < py.first){
+ new_dgm[2].push_back(pd_point);
+ }
+ //Extended-
+ else{
+ new_dgm[3].push_back(pd_point);
+ }
+ }
+ }
+ return new_dgm;
}
void create_persistence(Gudhi::Persistent_cohomology_interface<Base>* pcoh) {