GClasses
GClasses::GDistanceMetric Class Referenceabstract

Detailed Description

This class enables you to define a distance (or dissimilarity) metric between two vectors. pScaleFactors is an optional parameter (it can be NULL) that lets the calling class scale the significance of each dimension. Distance metrics that do not mix with this concept may simply ignore any scale factors. Typically, classes that use this should be able to assume that the triangle inequality will hold, but do not necessarily enforce the parallelogram law.

#include <GDistance.h>

Inheritance diagram for GClasses::GDistanceMetric:
GClasses::GDenseCosineDistance GClasses::GKernelDistance GClasses::GLNormDistance GClasses::GRowDistance

Public Member Functions

 GDistanceMetric ()
 
 GDistanceMetric (GDomNode *pNode)
 
virtual ~GDistanceMetric ()
 
virtual void init (const GRelation *pRelation, bool own)=0
 This must be called before squaredDistance can be called. Takes ownership of pRelation iff own is true. More...
 
virtual const char * name () const =0
 Returns the name of this class. More...
 
double operator() (const GVec &a, const GVec &b) const
 Return squaredDistance(pA, pB). Allows dissimilarity metrics to be used as function objects. Do not override. Override squaredDistance(pA,pB) instead. See GDistanceMetric::squaredDistance(const GVec&, const GVec&) More...
 
const GRelationrelation () const
 Returns the relation that specifies the meaning of the vector elements. More...
 
virtual GVecscaleFactors ()
 Returns a reference to the vector of attribute scalars. More...
 
virtual GDomNodeserialize (GDom *pDoc) const =0
 Marshal this object into a DOM, which can then be converted to a variety of serial formats. More...
 
virtual double squaredDistance (const GVec &a, const GVec &b) const =0
 Computes the squared distance (or squared dissimilarity) between the two specified vectors. More...
 

Static Public Member Functions

static GDistanceMetricdeserialize (GDomNode *pNode)
 Deserializes a distance metric. More...
 
static void test ()
 

Protected Member Functions

GDomNodebaseDomNode (GDom *pDoc) const
 
void setRelation (const GRelation *pRelation, bool own)
 Sets the relation to use with this metric. Takes ownership of the relation iff own is true. More...
 

Protected Attributes

bool m_ownRelation
 
const GRelationm_pRelation
 
GVec m_scaleFactors
 

Constructor & Destructor Documentation

GClasses::GDistanceMetric::GDistanceMetric ( )
inline
GClasses::GDistanceMetric::GDistanceMetric ( GDomNode pNode)
virtual GClasses::GDistanceMetric::~GDistanceMetric ( )
virtual

Member Function Documentation

GDomNode* GClasses::GDistanceMetric::baseDomNode ( GDom pDoc) const
protected
static GDistanceMetric* GClasses::GDistanceMetric::deserialize ( GDomNode pNode)
static

Deserializes a distance metric.

virtual void GClasses::GDistanceMetric::init ( const GRelation pRelation,
bool  own 
)
pure virtual

This must be called before squaredDistance can be called. Takes ownership of pRelation iff own is true.

Implemented in GClasses::GKernelDistance, GClasses::GDenseCosineDistance, GClasses::GLNormDistance, and GClasses::GRowDistance.

virtual const char* GClasses::GDistanceMetric::name ( ) const
pure virtual
double GClasses::GDistanceMetric::operator() ( const GVec a,
const GVec b 
) const
inline

Return squaredDistance(pA, pB). Allows dissimilarity metrics to be used as function objects. Do not override. Override squaredDistance(pA,pB) instead. See GDistanceMetric::squaredDistance(const GVec&, const GVec&)

const GRelation* GClasses::GDistanceMetric::relation ( ) const
inline

Returns the relation that specifies the meaning of the vector elements.

virtual GVec& GClasses::GDistanceMetric::scaleFactors ( )
inlinevirtual

Returns a reference to the vector of attribute scalars.

virtual GDomNode* GClasses::GDistanceMetric::serialize ( GDom pDoc) const
pure virtual

Marshal this object into a DOM, which can then be converted to a variety of serial formats.

Implemented in GClasses::GKernelDistance, GClasses::GDenseCosineDistance, GClasses::GLNormDistance, and GClasses::GRowDistance.

void GClasses::GDistanceMetric::setRelation ( const GRelation pRelation,
bool  own 
)
protected

Sets the relation to use with this metric. Takes ownership of the relation iff own is true.

virtual double GClasses::GDistanceMetric::squaredDistance ( const GVec a,
const GVec b 
) const
pure virtual

Computes the squared distance (or squared dissimilarity) between the two specified vectors.

Implemented in GClasses::GKernelDistance, GClasses::GDenseCosineDistance, GClasses::GLNormDistance, and GClasses::GRowDistance.

static void GClasses::GDistanceMetric::test ( )
static

Member Data Documentation

bool GClasses::GDistanceMetric::m_ownRelation
protected
const GRelation* GClasses::GDistanceMetric::m_pRelation
protected
GVec GClasses::GDistanceMetric::m_scaleFactors
protected