GClasses
|
Finds the k-nearest neighbors of any vector in a dataset. More...
#include <GNeighborFinder.h>
Public Member Functions | |
GNeighborFinder (const GMatrix *pData, size_t neighborCount) | |
virtual | ~GNeighborFinder () |
virtual bool | canGeneralize () |
Returns true if this neighbor finder can operate on points that are not in the dataset passed to the constructor. More... | |
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... | |
Static Public Member Functions | |
static void | sortNeighbors (size_t neighborCount, 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... | |
Protected Attributes | |
size_t | m_neighborCount |
const GMatrix * | m_pData |
Finds the k-nearest neighbors of any vector in a dataset.
|
inline |
|
inlinevirtual |
|
inlinevirtual |
Returns true if this neighbor finder can operate on points that are not in the dataset passed to the constructor.
Reimplemented in GClasses::GNeighborFinderGeneralizing.
|
inline |
Returns the data passed to the constructor of this object.
|
inlinevirtual |
Returns true iff the neighbors and distances are pre-computed.
Reimplemented in GClasses::GNeighborGraph.
|
inline |
Returns the number of neighbors to find.
|
pure virtual |
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.
Implemented in GClasses::GSequenceNeighborFinder, GClasses::GTemporalNeighborFinder, GClasses::GSaffron, GClasses::GBallTree, GClasses::GKdTree, GClasses::GBruteForceNeighborFinder, and GClasses::GNeighborGraph.
|
pure virtual |
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.
Implemented in GClasses::GSequenceNeighborFinder, GClasses::GTemporalNeighborFinder, GClasses::GSaffron, GClasses::GBallTree, GClasses::GKdTree, GClasses::GBruteForceNeighborFinder, and GClasses::GNeighborGraph.
|
static |
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)
void GClasses::GNeighborFinder::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)
|
protected |
|
protected |