| Description |
This is just a brute force implementation of k nearest neighbor search without using any fancy data structure, such as kd-tree. However it is the fastest knn matlab implementation I can find.
A partial sort mex function is implemented which is a simple wrapper of c++ partial_sort.
Provided the sort function, the matlab code is only of two lines. However, it is extremely fast.
install:
build;
usage:
[distance, index] = knn(query,data,k);
example:
X=rand(200,2000);Y=rand(200,5000);
tic;[D,N]=knn(X,Y,50);toc
|