Skip to content

Commit

Permalink
Merge pull request #22 from hschreiber/update_from_gudhi
Browse files Browse the repository at this point in the history
assert fix and forgoten case
  • Loading branch information
DavidLapous authored Sep 24, 2024
2 parents f915d61 + 4c0ff39 commit 38cce40
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 19 deletions.
36 changes: 25 additions & 11 deletions multipers/gudhi/gudhi/Multi_critical_filtration.h
Original file line number Diff line number Diff line change
Expand Up @@ -858,23 +858,37 @@ class Multi_critical_filtration {
bool _generator_can_be_added(const Generator &x, std::size_t curr, std::size_t &end) {
if (x.empty() || x.is_nan()) return false;

if constexpr (co){
if (x.is_minus_inf() && end - curr != 0) return false;

// assumes that everything between curr and end is simplified
// so, only multi_filtration_[curr] can be at inf or -inf.
if constexpr (co) {
if (multi_filtration_[curr].is_plus_inf() || (x.is_minus_inf() && end - curr != 0)) {
return false;
}
if (multi_filtration_[curr].is_minus_inf()) {
if (x.is_minus_inf()) {
return false;
}
end = curr;
return true;
}
if (x.is_plus_inf()) {
if (end - curr == 1 && multi_filtration_[curr].is_plus_inf()) return false;
// assumes that everything between curr and end is already simplified
// so, if end - curr != 1, there can be no minus_inf anymore.
if (multi_filtration_[curr].is_plus_inf()) return false;
end = curr;
return true;
}
} else {
if (x.is_plus_inf() && end - curr != 0) return false;

if (multi_filtration_[curr].is_minus_inf() || (x.is_plus_inf() && end - curr != 0)) {
return false;
}
if (multi_filtration_[curr].is_plus_inf()) {
if (x.is_plus_inf()) {
return false;
}
end = curr;
return true;
}
if (x.is_minus_inf()) {
if (end - curr == 1 && multi_filtration_[curr].is_minus_inf()) return false;
// assumes that everything between curr and end is already simplified
// so, if end - curr != 1, there can be no minus_inf anymore.
if (multi_filtration_[curr].is_minus_inf()) return false;
end = curr;
return true;
}
Expand Down
11 changes: 3 additions & 8 deletions multipers/multiparameter_module_approximation/approximation.h
Original file line number Diff line number Diff line change
Expand Up @@ -599,6 +599,7 @@ Module<value_type> multiparameter_module_approximation(
*/
/* threshold, box); */
}

out.add_barcode(current_line, barcode, threshold);

if (verbose) std::cout << "Instantiated " << num_bars << " summands" << std::endl;
Expand Down Expand Up @@ -708,10 +709,7 @@ inline void Module<value_type>::add_barcode(
const Line<value_type> &line,
const std::vector<std::pair<int, std::pair<value_type, value_type>>> &barcode,
const bool threshold_in) {
assert(barcode.size() != module_.size() &&
std::string("Barcode sizes doesn't match. Module is " + std::to_string(module_.size()) + " and barcode is " +
std::to_string(barcode.size()))
.data());
assert(barcode.size() == module_.size() && "Barcode sizes doesn't match.");

auto count = 0U;
for (const auto &extBar : barcode) {
Expand All @@ -724,10 +722,7 @@ template <typename value_type>
inline void Module<value_type>::add_barcode(const Line<value_type> &line,
const std::vector<std::pair<value_type, value_type>> &barcode,
const bool threshold_in) {
assert(barcode.size() != module_.size() &&
std::string("Barcode sizes doesn't match. Module is " + std::to_string(module_.size()) + " and barcode is " +
std::to_string(barcode.size()))
.data());
assert(barcode.size() == module_.size() && "Barcode sizes doesn't match.");

auto count = 0U;
for (const auto &bar : barcode) {
Expand Down

0 comments on commit 38cce40

Please sign in to comment.