GClasses
GClasses::GSparseNeighborFinder Class Reference

Detailed Description

Finds neighbors by measuring the distance to all points using a sparse distance metric.

#include <GNeighborFinder.h>

Inheritance diagram for GClasses::GSparseNeighborFinder:
GClasses::GNeighborFinderGeneralizing GClasses::GNeighborFinder

Public Member Functions

 GSparseNeighborFinder (GSparseMatrix *pData, GMatrix *pBogusData, GSparseSimilarity *pMetric, bool ownMetric=false)
 pData is the sparse dataset in which you want to find neighbors. pBogusData must be a pointer to a valid dense dataset that will be ignored. (Obviously, this is a hack that should be cleaned up.) neighborCount is the number of neighbors that you want to find. pMetric is the similarity metric to use in finding neighbors. Higher similarity indicates closer neighbors. ownMetric specifies whether this object should delete pMetric when it is deleted. More...
 
virtual ~GSparseNeighborFinder ()
 
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::findNearest. More...
 
virtual size_t findWithinRadius (double squaredRadius, size_t index)
 See the comment for GNeighborFinder::findWithinRadius Currently, this method just throws an exception because it is not yet implemented. More...
 
virtual size_t findWithinRadius (double squaredRadius, const GVec &vector)
 See the comment for GNeighborFinderGeneralizing::findWithinRadius Currently, this method just throws an exception because it is not yet implemented. 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 Attributes

bool m_ownSparseMetric
 
GSparseMatrixm_pData
 
GSparseSimilaritym_pSparseMetric
 
- 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
 

Additional Inherited Members

- 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...
 

Constructor & Destructor Documentation

GClasses::GSparseNeighborFinder::GSparseNeighborFinder ( GSparseMatrix pData,
GMatrix pBogusData,
GSparseSimilarity pMetric,
bool  ownMetric = false 
)

pData is the sparse dataset in which you want to find neighbors. pBogusData must be a pointer to a valid dense dataset that will be ignored. (Obviously, this is a hack that should be cleaned up.) neighborCount is the number of neighbors that you want to find. pMetric is the similarity metric to use in finding neighbors. Higher similarity indicates closer neighbors. ownMetric specifies whether this object should delete pMetric when it is deleted.

virtual GClasses::GSparseNeighborFinder::~GSparseNeighborFinder ( )
virtual

Member Function Documentation

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

See the comment for GNeighborFinder::findNearest.

Implements GClasses::GNeighborFinder.

virtual size_t GClasses::GSparseNeighborFinder::findNearest ( size_t  k,
const GVec vector 
)
virtual
virtual size_t GClasses::GSparseNeighborFinder::findWithinRadius ( double  squaredRadius,
size_t  index 
)
virtual

See the comment for GNeighborFinder::findWithinRadius Currently, this method just throws an exception because it is not yet implemented.

Implements GClasses::GNeighborFinder.

virtual size_t GClasses::GSparseNeighborFinder::findWithinRadius ( double  squaredRadius,
const GVec vector 
)
virtual

See the comment for GNeighborFinderGeneralizing::findWithinRadius Currently, this method just throws an exception because it is not yet implemented.

Implements GClasses::GNeighborFinderGeneralizing.

virtual void GClasses::GSparseNeighborFinder::reoptimize ( )
virtual

This is a no-op method in this class.

Implements GClasses::GNeighborFinderGeneralizing.

Member Data Documentation

bool GClasses::GSparseNeighborFinder::m_ownSparseMetric
protected
GSparseMatrix* GClasses::GSparseNeighborFinder::m_pData
protected
GSparseSimilarity* GClasses::GSparseNeighborFinder::m_pSparseMetric
protected