当前位置: 首页>>代码示例>>C++>>正文


C++ Index::buildIndex方法代码示例

本文整理汇总了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;
    }
}
开发者ID:abramhindle,项目名称:flann,代码行数:31,代码来源:flann.cpp

示例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;
}
开发者ID:abramhindle,项目名称:flann,代码行数:27,代码来源:flann.cpp

示例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;
    }
}
开发者ID:ankush1123roy,项目名称:Flann-Search-Deep-Learning,代码行数:30,代码来源:flann.cpp


注:本文中的Index::buildIndex方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。