本文整理汇总了C++中Searcher::geterr方法的典型用法代码示例。如果您正苦于以下问题:C++ Searcher::geterr方法的具体用法?C++ Searcher::geterr怎么用?C++ Searcher::geterr使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Searcher
的用法示例。
在下文中一共展示了Searcher::geterr方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: nn_search
void nn_search(Searcher& searcher, double* const nn, double* const dists, const long R, const long N,
const long dim, const double* p, const double* ref, const long NNR, const mmatrix& past, const double epsilon,
const int ref_or_direct)
{
if (searcher.geterr()) {
mexErrMsgTxt("Error preparing searcher, maybe wrong preprocessing data were given or the point set has changed");
}
double* const coord = (double*) malloc(dim * sizeof(double));
for (long n=0; n < R; n++) { /* iterate over all reference points */
vector<neighbor> v;
if (ref_or_direct) {
const long actual = int(ref[n])-1; // Matlab to C means indices change from 1 to 0, 2 to 1, 3 to 2
for (long k=0; k < dim; k++)
coord[k] = p[actual+k*N];
searcher.search_k_neighbors(v, NNR, coord, (long) past(n+1,1)-1, (long) past(n+1,2)-1, epsilon);
} else {
for (long k=0; k < dim; k++)
coord[k] = ref[n+k*R];
searcher.search_k_neighbors(v, NNR, coord, (long) past(n+1,1)-1, (long) past(n+1,2)-1, epsilon);
}
for (long k = 0; k < v.size(); k++) { // v is the sorted vector of neighbors
nn[n+k*R] = v[k].index() +1; // convert indices back to Matlab (1..N) style
dists[n+k*R] = v[k].dist();
}
}
free(coord);
}