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 NNS*
nns = NNS::createKDTreeLinearHeap(d, std::numeric_limits<typename NNS::Index>::max(), NNS::TOUCH_STATISTICS);
65 for (T epsilon = 0; epsilon < 2; epsilon += 0.01)
69 for (
int s = 0; s < searchCount; ++s)
72 touchStats +=
nns->knn(
q, indexes_bf, dists2_bf, K, epsilon, NNS::ALLOW_SELF_MATCH);
75 cout << epsilon <<
" " << duration/double(searchCount) <<
" " << touchStats/double(searchCount) << endl;
81 int main(
int argc,
char* argv[])
85 cerr <<
"Usage " << argv[0] <<
" DATA K METHOD SEARCH_COUNT" << endl;
89 const int K(atoi(argv[2]));
90 const int method(atoi(argv[3]));
91 const int searchCount(atoi(argv[4]));
95 cout <<
"epsilon average_duration search_count\n";
96 doTestEpsilon<double>(argv[1], K, method, searchCount);