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. More...
#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... | |
double | operator() (const std::vector< double > &a, const std::vector< double > &b) const |
Return squaredDistance(a,b). Allows dissimilarity metrics to be used as function objects. Do not override. Override squaredDistance(a,b) instead. See GDistanceMetric::squaredDistance(const std::vector<double>&, const std::vector<double>&) More... | |
double | operator() (const double *pA, const double *pB) 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 double*, const double*) More... | |
const GRelation * | relation () const |
Returns the relation that specifies the meaning of the vector elements. More... | |
virtual double * | scaleFactors () |
Returns a pointer to the vector of scale factors. This may be NULL if the metric does not use scale factors. 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 std::vector< double > &a, const std::vector< double > &b) const |
Return the squared distance (or squared dissimilarity) between the two specified vectors. More... | |
virtual double | squaredDistance (const double *pA, const double *pB) 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... | |
Protected Member Functions | |
GDomNode * | baseDomNode (GDom *pDoc, const char *szClassName) 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 |
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.
|
inline |
GClasses::GDistanceMetric::GDistanceMetric | ( | GDomNode * | pNode | ) |
|
virtual |
|
protected |
|
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::GLNormDistance, GClasses::GRowDistanceScaled, and GClasses::GRowDistance.
|
inline |
Return squaredDistance(a,b). Allows dissimilarity metrics to be used as function objects. Do not override. Override squaredDistance(a,b) instead. See GDistanceMetric::squaredDistance(const std::vector<double>&, const std::vector<double>&)
|
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 double*, const double*)
|
inline |
Returns the relation that specifies the meaning of the vector elements.
|
inlinevirtual |
Returns a pointer to the vector of scale factors. This may be NULL if the metric does not use scale factors.
Reimplemented in GClasses::GRowDistanceScaled.
Marshal this object into a DOM, which can then be converted to a variety of serial formats.
Implemented in GClasses::GLNormDistance, GClasses::GRowDistanceScaled, and GClasses::GRowDistance.
|
protected |
Sets the relation to use with this metric. Takes ownership of the relation iff own is true.
|
virtual |
Return the squared distance (or squared dissimilarity) between the two specified vectors.
It is assumed that a and b are vectors of the same dimension - and that that dimension is compatible with the relation given in init. By default uses squaredDistance(const double*, const double*) const so subclassers only need to change that method.
|
pure virtual |
Computes the squared distance (or squared dissimilarity) between the two specified vectors.
Implemented in GClasses::GLNormDistance, GClasses::GRowDistanceScaled, and GClasses::GRowDistance.
|
protected |
|
protected |