GClasses
|
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>
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 GRelation * | relation () const |
Returns the relation that specifies the meaning of the vector elements. More... | |
virtual GVec & | scaleFactors () |
Returns a reference to the vector of attribute scalars. More... | |
virtual GDomNode * | serialize (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 GDistanceMetric * | deserialize (GDomNode *pNode) |
Deserializes a distance metric. More... | |
static void | test () |
Protected Member Functions | |
GDomNode * | baseDomNode (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 GRelation * | m_pRelation |
GVec | m_scaleFactors |
|
inline |
GClasses::GDistanceMetric::GDistanceMetric | ( | GDomNode * | pNode | ) |
|
virtual |
|
static |
Deserializes a distance metric.
|
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.
|
pure virtual |
Returns the name of this class.
Implemented in GClasses::GKernelDistance, GClasses::GDenseCosineDistance, GClasses::GLNormDistance, and GClasses::GRowDistance.
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&)
|
inline |
Returns the relation that specifies the meaning of the vector elements.
|
inlinevirtual |
Returns a reference to the vector of attribute scalars.
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.
|
protected |
Sets the relation to use with this metric. Takes ownership of the relation iff own is true.
|
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 |
|
protected |
|
protected |
|
protected |