Skip to content

Update kdtree kr with dist (and refactor) #303

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

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

tremblap
Copy link
Member

Using the latest refactor in DS.kr, enacted the following changes:

  1. made the variable names more explicit (mLastNumPoints and kLookupDataSet)
  2. removed the temp output vector and its allocator
  3. replaced loops with sdt::iterators
  4. added the distance output when no lookupDataSet is provided

still 2 questions pending:

  1. line 230: I wasn't able to remove the 'point' allocation, as the first argument of kdtree.algo.knearest is not templatable for me
  2. line 243: I needed to dereference id - i don't know why, as I though that id would be an iteration of ids, each being a pointer to a string in the vector of strings pointers, like in DataSet.kr

any pointer (pun intended) welcome

@tremblap tremblap requested a review from weefuzzy April 16, 2025 06:56
@tremblap
Copy link
Member Author

the 2nd commit also corrects the error for non-triggered kr output post negative triggered output

@weefuzzy
Copy link
Member

  • line 230: I wasn't able to remove the 'point' allocation, as the first argument of kdtree.algo.knearest is not templatable for me

It's not calling into already generic code, so there would be some extra work in updating other functions too. Given the amount of other apparatus querying KDTree creates, the pay off from avoiding this one temporary pales a bit.

  • line 243: I needed to dereference id - i don't know why, as I though that id would be an iteration of ids, each being a pointer to a string in the vector of strings pointers, like in DataSet.kr

There's no particular reason to suppose it should work like the query for DataSet. kNearest here returns a KNNResult which is a pair<vector<double>, vector<const string*>>. So you need to deference the id when you call get because it's a string* and you need a string& there.

@tremblap
Copy link
Member Author

thanks for this, pushed the change. Now, I have avoided the TODO at line 108, mostly because I didn't know how to overload a single function with a fork in the end... or maybe I have a private (computeKnearest that is called with a bool argument on output one or the other?)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants