GClasses
GClasses::GBruteForceNeighborFinder Class Reference

Detailed Description

Finds neighbors by measuring the distance to all points. This one should work properly even if the distance metric does not support the triangle inequality.

#include <GNeighborFinder.h>

Inheritance diagram for GClasses::GBruteForceNeighborFinder:
GClasses::GNeighborFinderGeneralizing GClasses::GNeighborFinder

Public Member Functions

 GBruteForceNeighborFinder (GMatrix *pData, GDistanceMetric *pMetric=NULL, bool ownMetric=false)
 
virtual ~GBruteForceNeighborFinder ()
 
virtual size_t findNearest (size_t k, size_t index)
 See the comment for GNeighborFinder::findNearest. More...
 
virtual size_t findNearest (size_t k, const GVec &vector)
 See the comment for GNeighborFinderGeneralizing::neighbors. More...
 
virtual size_t findWithinRadius (double squaredRadius, size_t index)
 See the comment for GNeighborFinder::findWithinRadius. More...
 
virtual size_t findWithinRadius (double squaredRadius, const GVec &vector)
 See the comment for GNeighborFinderGeneralizing::findWithinRadius. More...
 
virtual void reoptimize ()
 This is a no-op method in this class. More...
 
- Public Member Functions inherited from GClasses::GNeighborFinderGeneralizing
 GNeighborFinderGeneralizing (const GMatrix *pData, 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 double distance (size_t i)
 See the comment for GNeighborFinder::distance. More...
 
GDistanceMetricmetric ()
 Returns the metric. More...
 
virtual size_t neighbor (size_t i)
 See the comment for GNeighborFinder::neighbor. More...
 
void sortNeighbors (size_t start=0, size_t end=INVALID_INDEX)
 Uses Quick Sort to sort the neighbors from least to most distant. More...
 
- Public Member Functions inherited from GClasses::GNeighborFinder
 GNeighborFinder (const GMatrix *pData)
 
virtual ~GNeighborFinder ()
 
const GMatrixdata ()
 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...
 

Protected Member Functions

size_t findNearest (size_t k, const GVec &vec, size_t exclude)
 
size_t findWithinRadius (double squaredRadius, const GVec &vec, size_t exclude)
 
- Protected Member Functions inherited from GClasses::GNeighborFinderGeneralizing
void insertionSortNeighbors (size_t start, size_t end)
 A helper method used by sortNeighbors when the remaining portion to sort is small. More...
 

Additional Inherited Members

- Protected Attributes inherited from GClasses::GNeighborFinderGeneralizing
std::vector< double > m_dists
 
std::vector< size_t > m_neighs
 
bool m_ownMetric
 
GDistanceMetricm_pMetric
 
- Protected Attributes inherited from GClasses::GNeighborFinder
const GMatrixm_pData
 

Constructor & Destructor Documentation

GClasses::GBruteForceNeighborFinder::GBruteForceNeighborFinder ( GMatrix pData,
GDistanceMetric pMetric = NULL,
bool  ownMetric = false 
)
virtual GClasses::GBruteForceNeighborFinder::~GBruteForceNeighborFinder ( )
virtual

Member Function Documentation

virtual size_t GClasses::GBruteForceNeighborFinder::findNearest ( size_t  k,
size_t  index 
)
virtual

See the comment for GNeighborFinder::findNearest.

Implements GClasses::GNeighborFinder.

virtual size_t GClasses::GBruteForceNeighborFinder::findNearest ( size_t  k,
const GVec vector 
)
virtual

See the comment for GNeighborFinderGeneralizing::neighbors.

Implements GClasses::GNeighborFinderGeneralizing.

size_t GClasses::GBruteForceNeighborFinder::findNearest ( size_t  k,
const GVec vec,
size_t  exclude 
)
protected
virtual size_t GClasses::GBruteForceNeighborFinder::findWithinRadius ( double  squaredRadius,
size_t  index 
)
virtual
virtual size_t GClasses::GBruteForceNeighborFinder::findWithinRadius ( double  squaredRadius,
const GVec vector 
)
virtual
size_t GClasses::GBruteForceNeighborFinder::findWithinRadius ( double  squaredRadius,
const GVec vec,
size_t  exclude 
)
protected
virtual void GClasses::GBruteForceNeighborFinder::reoptimize ( )
virtual

This is a no-op method in this class.

Implements GClasses::GNeighborFinderGeneralizing.