void doTestEpsilon(const char *fileName, const int K, const int method, const int searchCount) { typedef Nabo::NearestNeighbourSearch<T> NNS; typedef typename NNS::Matrix Matrix; typedef typename NNS::Vector Vector; typedef typename NNS::Index Index; typedef typename NNS::IndexVector IndexVector; typedef typename NNS::IndexMatrix IndexMatrix; // check if file is ok const Matrix d(load<T>(fileName)); if (K >= d.cols()) { cerr << "Requested more nearest neighbour than points in the data set" << endl; exit(2); } // check methods together const int itCount(method >= 0 ? method : d.cols() * 2); // create big query const Matrix q(createQuery<T>(d, itCount, method)); IndexMatrix indexes_bf(K, q.cols()); Matrix dists2_bf(K, q.cols()); NNS* nns = NNS::createKDTreeLinearHeap(d, std::numeric_limits<typename NNS::Index>::max(), NNS::TOUCH_STATISTICS); for (T epsilon = 0; epsilon < 2; epsilon += 0.01) { double duration(0); double touchStats(0); for (int s = 0; s < searchCount; ++s) { boost::timer t; touchStats += nns->knn(q, indexes_bf, dists2_bf, K, epsilon, NNS::ALLOW_SELF_MATCH); duration += t.elapsed(); } cout << epsilon << " " << duration/double(searchCount) << " " << touchStats/double(searchCount) << endl; } delete nns; }
void doTestEpsilon(const char *fileName, const int K, const int method, const int searchCount) { typedef Nabo::NearestNeighbourSearch<T> NNS; typedef typename NNS::Matrix Matrix; typedef typename NNS::IndexMatrix IndexMatrix; // check if file is ok const Matrix d(load<T>(fileName)); if (K >= d.cols()) { cerr << "Requested more nearest neighbour than points in the data set" << endl; exit(2); } // check methods together const int itCount(method >= 0 ? method : d.cols() * 2); // create big query const Matrix q(createQuery<T>(d, itCount, method)); IndexMatrix indexes_bf(K, q.cols()); Matrix dists2_bf(K, q.cols()); for (unsigned bucketSize = 2; bucketSize < 40; ++bucketSize) { Parameters additionalParameters("bucketSize", unsigned(bucketSize)); NNS* nns = NNS::createKDTreeLinearHeap(d, std::numeric_limits<typename NNS::Index>::max(), 0, additionalParameters); double duration(0); for (int s = 0; s < searchCount; ++s) { boost::timer t; nns->knn(q, indexes_bf, dists2_bf, K, 0, NNS::ALLOW_SELF_MATCH); duration += t.elapsed(); } cout << bucketSize << " " << duration/double(searchCount) << endl; delete nns; } }