Skip to content
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

incorrect computation of nearest neighbor #9

Open
bhatiaharsh opened this issue Aug 1, 2018 · 0 comments
Open

incorrect computation of nearest neighbor #9

bhatiaharsh opened this issue Aug 1, 2018 · 0 comments

Comments

@bhatiaharsh
Copy link

Hello, I am finding that the nearestNeighbour queries are not giving the correct result.

In the attached test case, i have three 2D points in the cover-tree, and for two test points, I do get the correct kNearestneighbours (k=3) with correct distances. But the nearest neighbor is incorrect.

I will try to look into the code in detail to figure out the cause. But if you have any ideas as to why this could be happening, I would appreciate the fix for this.

The attached program produces the following output.

Number of OpenMP threads: 1
 adding 3 points to cover tree!
Entered case 1: 3.31402 1 0
Requesting global lock!
 testing for nearest neighbors!

 query point 0 : (-0.944485 0.116473)
 doing 3-nearest neighbors using direct computation!
 	 nearest 0 : 1, 1.438655
 	 nearest 1 : 2, 1.651407
 	 nearest 2 : 0, 2.003489
 doing 3-nearest neighbors using cover_tree!
	 cover_tree 0 : 2, 1.438655
	 cover_tree 1 : 0, 1.651407
	 cover_tree 2 : 0, 2.003489
 nearest	 :: direct = (1, 1.438655)	 cover_tree = (0, 1.651407)
---------------------------------------------------------------------> mismatch

 query point 1 : (-0.931471 0.781848)
 doing 3-nearest neighbors using direct computation!
 	 nearest 0 : 1, 1.537557
 	 nearest 1 : 2, 2.114969
 	 nearest 2 : 0, 2.256513
 doing 3-nearest neighbors using cover_tree!
	 cover_tree 0 : 2, 1.537557
	 cover_tree 1 : 0, 2.114969
	 cover_tree 2 : 0, 2.256513
 nearest	 :: direct = (1, 1.537557)	 cover_tree = (0, 2.114969)
---------------------------------------------------------------------> mismatch

main.cpp.txt

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

No branches or pull requests

1 participant