diff --git a/src/Zigzag_persistence/include/gudhi/filtered_zigzag_persistence.h b/src/Zigzag_persistence/include/gudhi/filtered_zigzag_persistence.h index 21f1e1cb4..36bfe89e8 100644 --- a/src/Zigzag_persistence/include/gudhi/filtered_zigzag_persistence.h +++ b/src/Zigzag_persistence/include/gudhi/filtered_zigzag_persistence.h @@ -41,16 +41,9 @@ namespace zigzag_persistence { * * @brief Default options for @ref Filtered_zigzag_persistence_with_storage and @ref Filtered_zigzag_persistence. */ -struct Default_filtered_zigzag_options { - using Internal_key = int; /**< Cell ID used internally, must be signed. */ +struct Default_filtered_zigzag_options : Default_zigzag_options { using Cell_key = int; /**< Cell ID used in the given boundaries. */ using Filtration_value = double; /**< Filtration value type. */ - using Dimension = int; /**< Dimension value type. */ - /** - * @brief Column type use by the internal matrix. - */ - static const Gudhi::persistence_matrix::Column_types column_type = - Gudhi::persistence_matrix::Column_types::NAIVE_VECTOR; }; /** @@ -302,7 +295,7 @@ class Filtered_zigzag_persistence_with_storage private: std::unordered_map handleToKey_; /**< Map from input keys to internal keys. */ - Dimension dimMax_; /**< Maximal dimension of a bar to record. */ + Dimension dimMax_; /**< Maximal dimension of a bar to record. */ std::vector persistenceDiagram_; /**< Stores current closed persistence intervals. */ Internal_key numArrow_; /**< Current arrow number. */ Filtration_value previousFiltrationValue_; /**< Filtration value of the previous arrow. */ @@ -312,7 +305,7 @@ class Filtered_zigzag_persistence_with_storage * i is the smallest cell index whose cell has filtration value f. */ std::vector > filtrationValues_; - Zigzag_persistence pers_; /**< Class computing the pairs. */ + Zigzag_persistence pers_; /**< Class computing the pairs. */ /** * @brief Stores the filtration value if the value is new. Assumes that the given value is either greater (or equal) @@ -578,7 +571,7 @@ class Filtered_zigzag_persistence { Dictionary handleToKey_; /**< Map from input keys to internal keys. */ Internal_key numArrow_; /**< Current arrow number. */ Dictionary keyToFiltrationValue_; /**< Cell Key to filtration value map. */ - Zigzag_persistence pers_; /**< Class computing the pairs. */ + Zigzag_persistence pers_; /**< Class computing the pairs. */ }; // end class Filtered_zigzag_persistence } // namespace zigzag_persistence diff --git a/src/Zigzag_persistence/include/gudhi/zigzag_persistence.h b/src/Zigzag_persistence/include/gudhi/zigzag_persistence.h index 08639137f..e704587de 100644 --- a/src/Zigzag_persistence/include/gudhi/zigzag_persistence.h +++ b/src/Zigzag_persistence/include/gudhi/zigzag_persistence.h @@ -68,13 +68,11 @@ struct Default_zigzag_options { * @brief Column type use by the internal matrix. */ static const Gudhi::persistence_matrix::Column_types column_type = - Gudhi::persistence_matrix::Column_types::NAIVE_VECTOR; //TODO: redo benchmark with oscillating rips + Gudhi::persistence_matrix::Column_types::NAIVE_VECTOR; }; // TODO: add the possibility of something else than Z2. Which means that the possibility of vineyards without Z2 // also needs to be implemented. The theory needs to be done first. -// TODO: erase_birth_history will be moved to the options if it is proven to be useful. In the meantime -// it stays here undocumented to ease benchmarks. /** * @class Zigzag_persistence zigzag_persistence.h gudhi/zigzag_persistence.h * @brief Class computing the zigzag persistent homology of a zigzag sequence. Algorithm based on \cite zigzag. @@ -146,7 +144,7 @@ struct Default_zigzag_options { * * @tparam ZigzagOptions Structure following the @ref ZigzagOptions concept. Default value: @ref Default_zigzag_options. */ -template +template class Zigzag_persistence { public: @@ -324,19 +322,8 @@ class Zigzag_persistence template void get_current_infinite_intervals(F&& stream_infinite_interval) { for (auto& p : births_) { - if constexpr (erase_birth_history) { - auto& col = matrix_.get_column(p.first); - stream_infinite_interval(col.get_dimension(), p.second); - } else { - try { - auto& col = matrix_.get_column(p.first); - if (!col.is_paired()) { - stream_infinite_interval(col.get_dimension(), p.second); - } - } catch (const std::out_of_range&) { - continue; - } - } + auto& col = matrix_.get_column(p.first); + stream_infinite_interval(col.get_dimension(), p.second); } } @@ -438,10 +425,8 @@ class Zigzag_persistence } // birth not available anymore, do not } // modify *chain_f_it. - if constexpr (erase_birth_history) { - birthOrdering_.remove_birth(maxb); - births_.erase(chainFp); - } + birthOrdering_.remove_birth(maxb); + births_.erase(chainFp); // Update persistence diagram with left interval [fil(b_max) ; fil(m)) stream_interval_(dim - 1, maxb, numArrow_); @@ -477,10 +462,8 @@ class Zigzag_persistence if (!col.is_paired()) { // in F auto it = births_.find(currCol); stream_interval_(col.get_dimension(), it->second, numArrow_); - if constexpr (erase_birth_history) { - birthOrdering_.remove_birth(it->second); - births_.erase(it); - } + birthOrdering_.remove_birth(it->second); + births_.erase(it); } else { // in H -> paired with c_g, that now belongs to F now // maintain the <=b order birthOrdering_.add_birth_backward(numArrow_); diff --git a/src/Zigzag_persistence/test/test_zigzag_persistence.cpp b/src/Zigzag_persistence/test/test_zigzag_persistence.cpp index cb2ed8d6e..0f1edb9a2 100644 --- a/src/Zigzag_persistence/test/test_zigzag_persistence.cpp +++ b/src/Zigzag_persistence/test/test_zigzag_persistence.cpp @@ -17,7 +17,6 @@ #include using ZP = Gudhi::zigzag_persistence::Zigzag_persistence<>; -// using ZP = Gudhi::zigzag_persistence::Zigzag_persistence; struct Interval { Interval() {}