Multiparameter simplextree, C++ part.#976
Multiparameter simplextree, C++ part.#976DavidLapous wants to merge 261 commits intoGUDHI:masterfrom
Conversation
src/Simplex_tree/include/gudhi/Simplex_tree/multi_filtrations/box.h
Outdated
Show resolved
Hide resolved
src/Simplex_tree/include/gudhi/Simplex_tree/multi_filtrations/finitely_critical_filtrations.h
Outdated
Show resolved
Hide resolved
src/Simplex_tree/include/gudhi/Simplex_tree/multi_filtrations/line.h
Outdated
Show resolved
Hide resolved
src/Simplex_tree/include/gudhi/Simplex_tree/multi_filtrations/finitely_critical_filtrations.h
Outdated
Show resolved
Hide resolved
| void assign_filtration(Filtration_value GUDHI_CHECK_code(f)) { GUDHI_CHECK(f == 0, "filtration value specified for a complex that does not store them"); } | ||
| Filtration_value filtration() const { return 0; } | ||
| const Filtration_value& filtration() const { return null_value; } | ||
| static constexpr Filtration_value null_value={}; |
There was a problem hiding this comment.
If we say:
struct MyOptions : Simplex_tree_options_multidimensional_filtration {
// is_multi_parameter but not store_filtration
static const bool store_filtration = false;
};
Simplex_tree<MyOptions> stree;We are facing the error:
gudhi-devel/src/Simplex_tree/include/gudhi/Simplex_tree.h:165:39: error: the type 'const Filtration_value' {aka 'const Gudhi::multiparameter::multi_filtrations::Finitely_critical_multi_filtration<float>'} of 'constexpr' variable 'Gudhi::Simplex_tree<MyOptions>::Filtration_simplex_base_dummy::null_value' is not literal
static constexpr Filtration_value null_value={};
^~~~~~~~~~
But maybe this error is normal ? I was wondering to see if we should static_assert some error in this weird case.
There was a problem hiding this comment.
A static_assert could be a good idea, as the multi parameter tree only differentiate it self from the standard with its filtration values. If store_filtration == false, is_multi_parameter set to true makes no sense. But the problem could also be solved by removing null_value (see Issue #977), then we can just document that is_multi_parameter is ignored if store_filtration == false.
There was a problem hiding this comment.
A simple fix is to do a static_assert(!store_filtration || is_multi_parameter). thoughts ?
There was a problem hiding this comment.
I guess you meant static_assert(store_filtration || !is_multi_parameter) instead?
| static const Filtration_value& filtration(Simplex_handle sh){ | ||
| if (sh != null_simplex()) { | ||
| return sh->second.filtration(); | ||
| } else { | ||
| return std::numeric_limits<Filtration_value>::infinity(); | ||
| return inf_; | ||
| } | ||
| } | ||
| static Filtration_value& filtration_mutable(Simplex_handle sh){ | ||
| if (sh != null_simplex()) { | ||
| return sh->second.filtration(); | ||
| } else { | ||
| return inf_; |
There was a problem hiding this comment.
Already from the previous PR:
I am wondering if we could not just keep the version with the non
const, as the validity of the filtration in the simplex tree is already responsibility of the user. This would avoid having to find a different name when it does exactly the same thing thanfiltration(). Or could there be performance issues when using non const references for numerical values (i.e., when the simplex tree is not multi)? If it is the case, an ugly way to solve this would be to return astd::conditionalto switch betweenFiltration_value&andFiltration_valuedepending on the value ofis_multi_parameter.
There was a problem hiding this comment.
I don't have a fixed point of view on this. So its only a matter of what's the gudhi style of accessing a filtration value by reference.
There was a problem hiding this comment.
If they really do the same thing, I am ok with filtration returning a non-const reference. But I wonder if filtration_mutable actually needs to return infinity for the null simplex. If we decided instead that filtration_mutable only accepts real simplices (GUDHI_CHECK that sh!=null_simplex()), it could make sense for it to be a separate function, and it would let us declare inf_ const.
IIRC (that was a while ago, so I am likely wrong), handling null_simplex was mostly for convenience for the output of persistent cohomology, not some fundamental reason.
src/Simplex_tree/include/gudhi/Simplex_tree/Simplex_tree_multi.h
Outdated
Show resolved
Hide resolved
| * Modification(s): | ||
| * - YYYY/MM Author: Description of the modification | ||
| */ | ||
| #ifndef SIMPLEX_TREE_MULTI_H_ |
There was a problem hiding this comment.
Simplex_tree_multi_utilities.h seems more precise and less misleading to me than Simplex_tree_multi.h. What do you think?
There was a problem hiding this comment.
I'm not a big fan of the utilities name, but the name can be changed indeed. Let's fix the other issues and we'll decide that once the content of this file is fixed.
src/Simplex_tree/include/gudhi/Simplex_tree/Simplex_tree_multi.h
Outdated
Show resolved
Hide resolved
| std::vector<int> simplex; | ||
| for (auto vertex : st_multi.simplex_vertex_range(simplex_handle)) | ||
| simplex.push_back(vertex); | ||
| typename simplextree_multi::Options::value_type f = dimension >= 0 ? st_multi.filtration(simplex_handle)[dimension] : 0; |
There was a problem hiding this comment.
What is the use of dimension to possibly be negative?
There was a problem hiding this comment.
put every filtration values of st to 0. May be useful to copy a simplextree when we don't care about filtration values.
There was a problem hiding this comment.
Ok, I see. You should say this in the description of dimension, now that you added the doc.
|
|
||
|
|
||
|
|
||
| // Turns a multi-parameter simplextree into a 1-parameter simplextree |
There was a problem hiding this comment.
Should precise that the filtration values are not token over (which makes sense, but still). Could also add, that for the filtration values, linear_projection can be used.
There was a problem hiding this comment.
I'm not sure what you mean, each flatten function take into account filtration values.
There was a problem hiding this comment.
Huh? You are right, I think I completely missed a line here as I had the feeling that the filtration value was always put to 0. Which would also explain why I didn't understood the role of the dimension.
src/Simplex_tree/include/gudhi/Simplex_tree/Simplex_tree_multi.h
Outdated
Show resolved
Hide resolved
src/Simplex_tree/include/gudhi/Simplex_tree/Simplex_tree_multi.h
Outdated
Show resolved
Hide resolved
src/Simplex_tree/include/gudhi/Simplex_tree/multi_filtrations/Finitely_critical_filtrations.h
Outdated
Show resolved
Hide resolved
src/Simplex_tree/include/gudhi/Simplex_tree/Simplex_tree_multi.h
Outdated
Show resolved
Hide resolved
src/Simplex_tree/include/gudhi/Simplex_tree/Simplex_tree_multi.h
Outdated
Show resolved
Hide resolved
src/Simplex_tree/include/gudhi/Simplex_tree/Simplex_tree_multi.h
Outdated
Show resolved
Hide resolved
src/Simplex_tree/include/gudhi/Simplex_tree/Simplex_tree_multi.h
Outdated
Show resolved
Hide resolved
src/Simplex_tree/include/gudhi/Simplex_tree/Simplex_tree_multi.h
Outdated
Show resolved
Hide resolved
src/Simplex_tree/include/gudhi/Simplex_tree/Simplex_tree_multi.h
Outdated
Show resolved
Hide resolved
src/Simplex_tree/include/gudhi/Simplex_tree/multi_filtrations/Finitely_critical_filtrations.h
Outdated
Show resolved
Hide resolved
Co-authored-by: hschreiber <48448038+hschreiber@users.noreply.github.com>
…dLapous/gudhi-devel-multi into Multiparameter-Simplextree-C++-part
| Filtration_simplex_base_real() : filt_{} {} | ||
| void assign_filtration(const Filtration_value& f) { filt_ = f; } | ||
| const Filtration_value& filtration() const { return filt_; } | ||
| Filtration_value& filtration() { return filt_; } |
There was a problem hiding this comment.
TBD, but I am not sure we should add this method.
And if we add it we should add it to the dummy one.
…Finitely_critical_filtrations.h Co-authored-by: hschreiber <48448038+hschreiber@users.noreply.github.com>
src/Simplex_tree/include/gudhi/Simplex_tree/Simplex_tree_multi.h
Outdated
Show resolved
Hide resolved
src/Simplex_tree/include/gudhi/Simplex_tree/Simplex_tree_multi.h
Outdated
Show resolved
Hide resolved
Co-authored-by: Vincent Rouvreau <10407034+VincentRouvreau@users.noreply.github.com>
Co-authored-by: Vincent Rouvreau <10407034+VincentRouvreau@users.noreply.github.com>
…iparameter-Simplextree-C++-part
…istent with the other filtration classes
…iparameter-Simplextree-C++-part
Cpp part of PR #817.
List of changes :
is_multi_parameterflag in the simplextree's options to deal with filtration values that behave as array-like instead of float-like.null_valueandinf_filtration_mutableto have a non-const access to the filtration.assignbehavior of the insert to prevent unwanted behaviors (and stay 1-critical). The filtration property is no longer maintained.Filtration_value, child ofstd::vectorwith numpy-like pointwise operations, inSimplex_tree/multi_filtrations/Finitely_critical_multi_filtrations.hSimplex_tree/Simplex_tree_multi.hcontains the options of a simplextree multi, functions that can convert a 1-parameter simplextree to a multiparameter simplextree and vice versa, aswell as useful functions to push filtration values on a discrete grid (for discrete computations.Feel free to move files/functions if they don't follow Gudhi's standard, or commit if its moral changes.