*/
ANNpointArray dataPts; // data points
- ANNkd_tree* kdTree; // search structure
double *xx;
int *irn, *jcn;
//========= graph when sort based on x ========
nz = 0;
sortPtsX(nPts, dataPts);
- kdTree = new ANNkd_tree( // build search structure
+ ANNkd_tree kdTree( // build search structure
dataPts, // the data points
nPts, // number of points
dim); // dimension of space
for (int ip = 0; ip < nPts; ip++){
- kdTree->annkSearch( // search
+ kdTree.annkSearch( // search
dataPts[ip], // query point
k, // number of near neighbors
nnIdx.data(), // nearest neighbors (returned)
//========= graph when sort based on y ========
sortPtsY(nPts, dataPts);
- kdTree = new ANNkd_tree( // build search structure
+ kdTree = ANNkd_tree( // build search structure
dataPts, // the data points
nPts, // number of points
dim); // dimension of space
for (int ip = 0; ip < nPts; ip++){
- kdTree->annkSearch( // search
+ kdTree.annkSearch( // search
dataPts[ip], // query point
k, // number of near neighbors
nnIdx.data(), // nearest neighbors (returned)
}
}
- delete kdTree; // clean things up
-
*nz0 = nz;
annClose(); // done with ANN