GClasses
|
Finds the k-nearest neighbors (in a dataset) of an arbitrary vector (which may or may not be in the dataset). More...
#include <GNeighborFinder.h>
Public Member Functions | |
GNeighborFinderGeneralizing (GMatrix *pData, size_t neighborCount, GDistanceMetric *pMetric, bool ownMetric) | |
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. | |
virtual | ~GNeighborFinderGeneralizing () |
virtual bool | canGeneralize () |
Returns true. See the comment for GNeighborFinder::canGeneralize. | |
virtual size_t | addCopy (const double *pVector)=0 |
Add a copy of pVector to the data set. | |
virtual double * | releaseVector (size_t nIndex)=0 |
Releases a vector from the dataset. You are responsible to delete[] the vector that this returns. | |
virtual void | reoptimize ()=0 |
If you make major changes, you can call this to tell it to rebuild any optimization structures. | |
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. | |
Protected Attributes | |
GDistanceMetric * | m_pMetric |
bool | m_ownMetric |
Finds the k-nearest neighbors (in a dataset) of an arbitrary vector (which may or may not be in the dataset).
GClasses::GNeighborFinderGeneralizing::GNeighborFinderGeneralizing | ( | GMatrix * | pData, |
size_t | neighborCount, | ||
GDistanceMetric * | pMetric, | ||
bool | ownMetric | ||
) |
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.
virtual GClasses::GNeighborFinderGeneralizing::~GNeighborFinderGeneralizing | ( | ) | [virtual] |
virtual size_t GClasses::GNeighborFinderGeneralizing::addCopy | ( | const double * | pVector | ) | [pure virtual] |
Add a copy of pVector to the data set.
Implemented in GClasses::GBruteForceNeighborFinder, and GClasses::GKdTree.
virtual bool GClasses::GNeighborFinderGeneralizing::canGeneralize | ( | ) | [inline, virtual] |
Returns true. See the comment for GNeighborFinder::canGeneralize.
Reimplemented from GClasses::GNeighborFinder.
virtual void GClasses::GNeighborFinderGeneralizing::neighbors | ( | size_t * | pOutNeighbors, |
double * | pOutDistances, | ||
const double * | pInputVector | ||
) | [pure virtual] |
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.
Implemented in GClasses::GBruteForceNeighborFinder, and GClasses::GKdTree.
virtual double* GClasses::GNeighborFinderGeneralizing::releaseVector | ( | size_t | nIndex | ) | [pure virtual] |
Releases a vector from the dataset. You are responsible to delete[] the vector that this returns.
Implemented in GClasses::GBruteForceNeighborFinder, and GClasses::GKdTree.
virtual void GClasses::GNeighborFinderGeneralizing::reoptimize | ( | ) | [pure virtual] |
If you make major changes, you can call this to tell it to rebuild any optimization structures.
Implemented in GClasses::GBruteForceNeighborFinder, and GClasses::GKdTree.
bool GClasses::GNeighborFinderGeneralizing::m_ownMetric [protected] |