diff --git a/multipers/gudhi/gudhi/Multi_critical_filtration.h b/multipers/gudhi/gudhi/Multi_critical_filtration.h index d76f32d..588f5c4 100644 --- a/multipers/gudhi/gudhi/Multi_critical_filtration.h +++ b/multipers/gudhi/gudhi/Multi_critical_filtration.h @@ -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; } diff --git a/multipers/multiparameter_module_approximation/approximation.h b/multipers/multiparameter_module_approximation/approximation.h index fa6d7f3..1f70e1c 100644 --- a/multipers/multiparameter_module_approximation/approximation.h +++ b/multipers/multiparameter_module_approximation/approximation.h @@ -599,6 +599,7 @@ Module multiparameter_module_approximation( */ /* threshold, box); */ } + out.add_barcode(current_line, barcode, threshold); if (verbose) std::cout << "Instantiated " << num_bars << " summands" << std::endl; @@ -708,10 +709,7 @@ inline void Module::add_barcode( const Line &line, const std::vector>> &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) { @@ -724,10 +722,7 @@ template inline void Module::add_barcode(const Line &line, const std::vector> &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) {