-
Notifications
You must be signed in to change notification settings - Fork 67
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Simplex tree] Additional copy constructor for Simplex_tree #1121
[Simplex tree] Additional copy constructor for Simplex_tree #1121
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
some quick comments
src/Simplex_tree/include/gudhi/Simplex_tree/Simplex_tree_node_explicit_storage.h
Outdated
Show resolved
Hide resolved
for (auto& p : root_source.members()){ | ||
auto it = root_.members().try_emplace(root_.members().end(), p.first); | ||
it->second.assign_children(&root_); | ||
it->second.assign_filtration(translate_filtration_value(p.second.filtration())); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For multi, do we have that emplace
creates a vector of size 1 containing +inf, then translate
creates a vector of size 2 (for instance), then assign_filtration
copies that vector, for a total of 3 allocations?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Deleted old answer, as I just realized I remembered it all wrong... And I don't remember why I made this choice. I will try the constructor version, that should avoid at least one allocation.
…explicit_storage.h Co-authored-by: Marc Glisse <[email protected]>
…hreiber/gudhi-devel into simplex_tree_custom_copy_constructor
src/Simplex_tree/include/gudhi/Simplex_tree/Simplex_tree_node_explicit_storage.h
Outdated
Show resolved
Hide resolved
void assign_key(Simplex_key k) { key_ = k; } | ||
Simplex_key key() const { return key_; } | ||
private: | ||
Simplex_key key_; | ||
}; | ||
struct Key_simplex_base_dummy { | ||
Key_simplex_base_dummy() {} | ||
Key_simplex_base_dummy(Simplex_key k) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the conclusion was to remove this constructor?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it should be done now.
Co-authored-by: Marc Glisse <[email protected]>
Another copy constructor for the simplex tree copying from a simplex tree with eventually different options as template parameter. Takes also a method converting the filtration values. Will be used to replace the methods
multify
andflatten
in PR #976.I also changed the default copy constructor such that it copies all the keys. For now, it copied the keys of the vertices (with the default copy constructors of the node), but not for the other faces (the nodes were reconstructed from scratch). Copying the keys is not adding to the complexity, so I think that it is worth correcting the inconsistency. Also, I can imagine scenarios where having the keys can be useful when flatten a multi simplex tree (to keep the correspondences of the boundaries in the boundary matrix used for most of the computations).
Edit: we should also think about the attribute 'data' in the nodes to be copied or not.