Changeset 18915
- Timestamp:
- 12/03/14 12:06:52 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk-jpl/src/c/classes/kriging/Observations.cpp
r18912 r18915 628 628 Observation observation=Observation(x_interp,y_interp,0.); 629 629 std::vector<Observation> kNN; 630 631 /*If radius is not provided or is 0, return all observations*/ 632 if(radius==0.) 633 { 634 kNN=(this->covertree->getRoot())->getObservations(); 635 } 636 else 637 { 638 kNN=(this->covertree->kNearestNeighbors(observation, maxdata)); 639 //cout << "kNN's size: " << kNN.size() << endl; 640 641 } 630 631 kNN=(this->covertree->kNearestNeighbors(observation, maxdata)); 632 //cout << "kNN's size: " << kNN.size() << endl; 642 633 643 634 //kNN is sort from closest to farthest neighbor … … 645 636 //deletes and resizes the kNN vector 646 637 vector<Observation>::iterator it; 647 for (it = kNN.begin(); it != kNN.end(); ++it) { 648 //(*it).print(); 649 //cout << "\n" << (*it).distance(observation) << endl; 650 if ((*it).distance(observation) > radius) { 651 break; 652 } 653 } 654 kNN.erase(it, kNN.end()); 638 if(radius>0.){ 639 for (it = kNN.begin(); it != kNN.end(); ++it) { 640 //(*it).print(); 641 //cout << "\n" << (*it).distance(observation) << endl; 642 if ((*it).distance(observation) > radius) { 643 break; 644 } 645 } 646 kNN.erase(it, kNN.end()); 647 } 655 648 656 649 /*Allocate vectors*/ … … 661 654 /*Loop over all observations and fill in x, y and obs*/ 662 655 int i = 0; 663 for 656 for(it = kNN.begin(); it != kNN.end(); ++it) { 664 657 (*it).WriteXYObs((*it), &x[i], &y[i], &obs[i]); 665 658 i++; … … 669 662 *py=y; 670 663 *pobs=obs; 671 *pnobs = kNN.size();672 }/*}}}*/ 664 *pnobs = kNN.size(); 665 }/*}}}*/
Note:
See TracChangeset
for help on using the changeset viewer.