Skip to content

Commit

Permalink
minor fix for prone_above_filtration + Filtration_value concept
Browse files Browse the repository at this point in the history
  • Loading branch information
hschreiber committed Aug 23, 2024
1 parent 290de10 commit 4d80e13
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 16 deletions.
9 changes: 2 additions & 7 deletions src/Simplex_tree/concept/FiltrationValue.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,13 @@ struct FiltrationValue {
/**
* @brief Has to construct the default value of FiltrationValue. E.g., 0 for a numerical value or {} for a vector.
*/
FiltrationValue(0);
FiltrationValue();

// only for default ordering of filtration_vect_ in initialize_filtration
// only for default ordering of filtration_vect_ in initialize_filtration and for prune_above_filtration
/**
* @brief Strictly smaller operator. If the filtration values are totally ordered, should be a StrictWeakOrdering.
*/
friend bool operator<(const FiltrationValue& f1, const FiltrationValue& f2);
// only for prune_above_filtration
/**
* @brief Smaller or equal operator.
*/
friend bool operator<=(const FiltrationValue& f1, const FiltrationValue& f2);
/**
* @brief Equality operator
*/
Expand Down
21 changes: 12 additions & 9 deletions src/Simplex_tree/include/gudhi/Simplex_tree.h
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ class Simplex_tree {

void assign_filtration(const Filtration_value_rep GUDHI_CHECK_code(f))
{
GUDHI_CHECK(f == Filtration_value(0), "filtration value specified for a complex that does not store them");
GUDHI_CHECK(f == Filtration_value(), "filtration value specified for a complex that does not store them");
}
Filtration_value filtration() const { return 0; }
};
Expand Down Expand Up @@ -950,7 +950,7 @@ class Simplex_tree {
* .end() return input iterators, with 'value_type' Vertex_handle. */
template<class InputVertexRange = std::initializer_list<Vertex_handle>>
std::pair<Simplex_handle, bool> insert_simplex(const InputVertexRange & simplex,
const Filtration_value_rep filtration = Filtration_value(0)) {
const Filtration_value_rep filtration = Filtration_value()) {
auto first = std::begin(simplex);
auto last = std::end(simplex);

Expand Down Expand Up @@ -980,7 +980,7 @@ class Simplex_tree {
template <class InputVertexRange = std::initializer_list<Vertex_handle>>
std::pair<Simplex_handle, bool> insert_simplex_and_subfaces(
const InputVertexRange& Nsimplex,
const Filtration_value_rep filtration = Filtration_value(0))
const Filtration_value_rep filtration = Filtration_value())
{
auto first = std::begin(Nsimplex);
auto last = std::end(Nsimplex);
Expand Down Expand Up @@ -1422,7 +1422,7 @@ class Simplex_tree {
* The complex does not need to be empty before calling this function. However, if a vertex is
* already present, its filtration value is not modified, unlike with other insertion functions. */
template <class VertexRange>
void insert_batch_vertices(VertexRange const& vertices, const Filtration_value_rep filt = Filtration_value(0)) {
void insert_batch_vertices(VertexRange const& vertices, const Filtration_value_rep filt = Filtration_value()) {
auto verts = vertices | boost::adaptors::transformed([&](auto v){
return Dit_value_t(v, Node(&root_, filt)); });
root_.members_.insert(boost::begin(verts), boost::end(verts));
Expand Down Expand Up @@ -2041,11 +2041,14 @@ class Simplex_tree {
Simplex_handle last;

auto to_remove = [this, filt](Dit_value_t& simplex) {
if (simplex.second.filtration() <= filt) return false;
if (has_children(&simplex)) rec_delete(simplex.second.children());
// dimension may need to be lowered
dimension_to_be_lowered_ = true;
return true;
//if filt and simplex.second.filtration() are non comparable, should return false.
if (filt < simplex.second.filtration()) {
if (has_children(&simplex)) rec_delete(simplex.second.children());
// dimension may need to be lowered
dimension_to_be_lowered_ = true;
return true;
}
return false;
};

//TODO: `if constexpr` replaceable by `std::erase_if` in C++20? Has a risk of additional runtime,
Expand Down

0 comments on commit 4d80e13

Please sign in to comment.