本文整理汇总了C++中Index::buildIndex方法的典型用法代码示例。如果您正苦于以下问题:C++ Index::buildIndex方法的具体用法?C++ Index::buildIndex怎么用?C++ Index::buildIndex使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Index
的用法示例。
在下文中一共展示了Index::buildIndex方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: __flann_build_index
flann_index_t __flann_build_index(typename Distance::ElementType* dataset, int rows, int cols, float* speedup,
FLANNParameters* flann_params, Distance d = Distance())
{
typedef typename Distance::ElementType ElementType;
try {
init_flann_parameters(flann_params);
if (flann_params == NULL) {
throw FLANNException("The flann_params argument must be non-null");
}
IndexParams params = create_parameters(flann_params);
Index<Distance>* index = new Index<Distance>(Matrix<ElementType>(dataset,rows,cols), params, d);
index->buildIndex();
if (flann_params->algorithm==FLANN_INDEX_AUTOTUNED) {
IndexParams params = index->getParameters();
update_flann_parameters(params,flann_params);
SearchParams search_params = get_param<SearchParams>(params,"search_params");
*speedup = get_param<float>(params,"speedup");
flann_params->checks = search_params.checks;
flann_params->eps = search_params.eps;
flann_params->cb_index = get_param<float>(params,"cb_index",0.0);
}
return index;
}
catch (std::runtime_error& e) {
Logger::error("Caught exception: %s\n",e.what());
return NULL;
}
}
示例2: __flann_find_nearest_neighbors
int __flann_find_nearest_neighbors(typename Distance::ElementType* dataset, int rows, int cols, typename Distance::ElementType* testset, int tcount,
int* result, typename Distance::ResultType* dists, int nn, FLANNParameters* flann_params, Distance d = Distance())
{
typedef typename Distance::ElementType ElementType;
typedef typename Distance::ResultType DistanceType;
try {
init_flann_parameters(flann_params);
IndexParams params = create_parameters(flann_params);
Index<Distance>* index = new Index<Distance>(Matrix<ElementType>(dataset,rows,cols), params, d);
index->buildIndex();
Matrix<int> m_indices(result,tcount, nn);
Matrix<DistanceType> m_dists(dists,tcount, nn);
SearchParams search_params = create_search_params(flann_params);
index->knnSearch(Matrix<ElementType>(testset, tcount, index->veclen()),
m_indices,
m_dists, nn, search_params );
delete index;
return 0;
}
catch (std::runtime_error& e) {
Logger::error("Caught exception: %s\n",e.what());
return -1;
}
return -1;
}
示例3: __flann_build_index
flann_index_t __flann_build_index(typename Distance::ElementType* dataset, int rows, int cols, float* speedup,
FLANNParameters* flann_params, Distance d = Distance())
{
typedef typename Distance::ElementType ElementType;
try {
init_flann_parameters(flann_params);
if (flann_params == NULL) {
throw FLANNException("The flann_params argument must be non-null");
}
IndexParams* params = IndexParams::createFromParameters(*flann_params);
Index<Distance>* index = new Index<Distance>(Matrix<ElementType>(dataset,rows,cols), *params, d);
index->buildIndex();
const IndexParams* index_params = index->getIndexParameters();
index_params->toParameters(*flann_params);
if (index->getIndex()->getType()==FLANN_INDEX_AUTOTUNED) {
AutotunedIndex<Distance>* autotuned_index = (AutotunedIndex<Distance>*)index->getIndex();
flann_params->checks = autotuned_index->getSearchParameters()->checks;
*speedup = autotuned_index->getSpeedup();
}
delete params;
return index;
}
catch (std::runtime_error& e) {
logger.error("Caught exception: %s\n",e.what());
return NULL;
}
}