42 void doTestEpsilon(
const char *fileName,
const int K,
const int method,
const int searchCount)
45 typedef typename NNS::Matrix Matrix;
46 typedef typename NNS::IndexMatrix IndexMatrix;
49 const Matrix d(load<T>(fileName));
52 cerr <<
"Requested more nearest neighbour than points in the data set" << endl;
57 const int itCount(method >= 0 ? method : d.cols() * 2);
60 const Matrix
q(createQuery<T>(d, itCount, method));
61 IndexMatrix indexes_bf(K, q.cols());
62 Matrix dists2_bf(K, q.cols());
64 for (
unsigned bucketSize = 2; bucketSize < 40; ++bucketSize)
66 Parameters additionalParameters(
"bucketSize",
unsigned(bucketSize));
67 NNS*
nns = NNS::createKDTreeLinearHeap(d, std::numeric_limits<typename NNS::Index>::max(), 0, additionalParameters);
70 for (
int s = 0; s < searchCount; ++s)
73 nns->knn(q, indexes_bf, dists2_bf, K, 0, NNS::ALLOW_SELF_MATCH);
76 cout << bucketSize <<
" " << duration/double(searchCount) << endl;
83 int main(
int argc,
char* argv[])
87 cerr <<
"Usage " << argv[0] <<
" DATA K METHOD SEARCH_COUNT" << endl;
91 const int K(atoi(argv[2]));
92 const int method(atoi(argv[3]));
93 const int searchCount(atoi(argv[4]));
95 cout <<
"bucketSize average_duration\n";
96 doTestEpsilon<double>(argv[1], K, method, searchCount);
Nearest neighbour search interface, templatized on scalar type.
void doTestEpsilon(const char *fileName, const int K, const int method, const int searchCount)
int main(int argc, char *argv[])