Finds the k-nearest neighbors (in a dataset) of an arbitrary vector (which may or may not be in the dataset).
More...
|
| GNeighborFinderGeneralizing (const GMatrix *pData, size_t neighborCount, GDistanceMetric *pMetric=NULL, bool ownMetric=false) |
| Create a neighborfinder for finding the neighborCount nearest neighbors under the given metric. If ownMetric is true, then the neighborFinder takes responsibility for deleting the metric, otherwise it is the caller's responsibility. More...
|
|
virtual | ~GNeighborFinderGeneralizing () |
|
virtual bool | canGeneralize () |
| Returns true. See the comment for GNeighborFinder::canGeneralize. More...
|
|
virtual void | neighbors (size_t *pOutNeighbors, double *pOutDistances, const double *pInputVector)=0 |
| pOutNeighbors and pOutDistances should both be arrays of size neighborCount. pInputVector is the vector whose neighbors will be found. The neighbors are not necessarily sorted, but you can call GNeighborFinder::sortNeighbors if you want them to be sorted. If there are not enough points in the data set to fill the neighbor array, the empty ones will have an index of INVALID_INDEX. More...
|
|
virtual void | reoptimize ()=0 |
| If you make major changes, you can call this to tell it to rebuild any optimization structures. More...
|
|
| GNeighborFinder (const GMatrix *pData, size_t neighborCount) |
|
virtual | ~GNeighborFinder () |
|
const GMatrix * | data () |
| Returns the data passed to the constructor of this object. More...
|
|
virtual bool | isCached () |
| Returns true iff the neighbors and distances are pre-computed. More...
|
|
size_t | neighborCount () |
| Returns the number of neighbors to find. More...
|
|
virtual void | neighbors (size_t *pOutNeighbors, size_t index)=0 |
| Returns the k-nearest neighbors of the point specified by index. The neighbors are not necessarily sorted, but you can call GNeighborFinder::sortNeighbors if you want them to be sorted. pOutNeighbors should be an array of size neighborCount. index refers to the point/vector whose neighbors you want to obtain. The value INVALID_INDEX may be used to fill slots with no point if necessary. More...
|
|
virtual void | neighbors (size_t *pOutNeighbors, double *pOutDistances, size_t index)=0 |
| Returns the k-nearest neighbors of the point specified by index. The neighbors are not necessarily sorted, but you can call GNeighborFinder::sortNeighbors if you want them to be sorted. pOutNeighbors and pOutDistances should both be arrays of size neighborCount. index refers to the point/vector whose neighbors you want to obtain. If there are not enough points in the data set to fill the neighbor array, the empty ones will have an index of INVALID_INDEX. More...
|
|
void | sortNeighbors (size_t *pNeighbors, double *pDistances) |
| Uses Quick Sort to sort the neighbors from least to most dissimilar, followed by any slots for with INVALID_INDEX for the index. (Note: This method is pointless, since the neighors are already guaranteed to come in sorted order. Todo: figure out why it is still here) More...
|
|
Finds the k-nearest neighbors (in a dataset) of an arbitrary vector (which may or may not be in the dataset).