-
Notifications
You must be signed in to change notification settings - Fork 124
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
change kdTree code to choose the number of leaves #962
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.
Thanks a lot Mohamed!
Could you please take my remarks into account?
Thanks!
core/base/kdTree/KDTree.h
Outdated
@@ -64,14 +64,18 @@ namespace ttk { | |||
const int &ptNumber, | |||
const int &dimension, | |||
const std::vector<std::vector<dataType>> &weights = {}, | |||
const int weight_number = 1); | |||
const int weight_number = 1, |
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'd recommend to take the habit to use references for function parameters (unless pointers are necessary), even for integers.
const int weight_number = 1
-> const int &weightNumber = 1
(also, we usually don't use underscores for names in TTK, but a camel wording)
core/base/kdTree/KDTree.h
Outdated
@@ -64,14 +64,18 @@ namespace ttk { | |||
const int &ptNumber, | |||
const int &dimension, | |||
const std::vector<std::vector<dataType>> &weights = {}, | |||
const int weight_number = 1); | |||
const int weight_number = 1, | |||
int nodeNumber = -1); |
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.
int &nodeNumber = -1
--> const int &nodeNumber = -1
(unless it is not read only)
|
||
void buildRecursive(dataType *data, | ||
std::vector<int> &idx_side, | ||
const int &ptNumber, | ||
const int &dimension, | ||
KDTree<dataType, Container> *parent, | ||
KDTreeMap &correspondence_map, | ||
const int nodeNumber, | ||
const int maximumLevel, | ||
int &createdNumberNode, |
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.
same as above const
(if indeed read only)
core/base/kdTree/KDTree.h
Outdated
@@ -146,15 +150,67 @@ typename ttk::KDTree<dataType, Container>::KDTreeMap | |||
const int &ptNumber, | |||
const int &dimension, | |||
const std::vector<std::vector<dataType>> &weights, | |||
const int weight_number) { | |||
const int weight_number, | |||
int nodeNumber) { |
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.
same remark as above const int &nodeNumber
core/base/kdTree/KDTree.h
Outdated
@@ -146,15 +150,67 @@ typename ttk::KDTree<dataType, Container>::KDTreeMap | |||
const int &ptNumber, | |||
const int &dimension, | |||
const std::vector<std::vector<dataType>> &weights, | |||
const int weight_number) { | |||
const int weight_number, |
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.
same remark as above const int &weightNumber
.
core/base/kdTree/KDTree.h
Outdated
@@ -225,23 +291,35 @@ void ttk::KDTree<dataType, Container>::buildRecursive( | |||
const int &dimension, | |||
KDTree<dataType, Container> *parent, | |||
KDTreeMap &correspondence_map, | |||
const int nodeNumber, |
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.
const int &nodeNumber
core/base/kdTree/KDTree.h
Outdated
@@ -225,23 +291,35 @@ void ttk::KDTree<dataType, Container>::buildRecursive( | |||
const int &dimension, | |||
KDTree<dataType, Container> *parent, | |||
KDTreeMap &correspondence_map, | |||
const int nodeNumber, | |||
const int maximumLevel, |
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.
const int &maximumLevel
@@ -225,23 +291,35 @@ void ttk::KDTree<dataType, Container>::buildRecursive( | |||
const int &dimension, | |||
KDTree<dataType, Container> *parent, | |||
KDTreeMap &correspondence_map, | |||
const int nodeNumber, | |||
const int maximumLevel, | |||
int &createdNumberNode, |
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.
const int &createdNumberNode
(unless not read-only)
core/base/kdTree/KDTree.h
Outdated
@@ -288,10 +368,13 @@ void ttk::KDTree<dataType, Container>::buildRecursive( | |||
this->left_ | |||
= std::make_unique<KDTree>(this, (coords_number_ + 1) % dimension, true); | |||
this->left_->buildRecursive(data, idx_left, ptNumber, dimension, this, | |||
correspondence_map, weights, weight_number); | |||
correspondence_map, nodeNumber, maximumLevel, | |||
createdNumberNode, weights, weight_number); |
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.
weightNumber
core/base/kdTree/KDTree.h
Outdated
@@ -300,7 +383,8 @@ void ttk::KDTree<dataType, Container>::buildRecursive( | |||
this->right_ | |||
= std::make_unique<KDTree>(this, (coords_number_ + 1) % dimension, false); | |||
this->right_->buildRecursive(data, idx_right, ptNumber, dimension, this, | |||
correspondence_map, weights, weight_number); | |||
correspondence_map, nodeNumber, maximumLevel, | |||
createdNumberNode, weights, weight_number); |
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.
weightNumber
thanks a lot, let's go! |
Thanks for contributing to TTK!
Before submitting your pull request, please:
Review our Contributor Guidelines, in particular regarding code formatting (with clang-format) and continuous integration.
Please provide a quick description of your contributions below:
Your description here