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 GDomNode * | serialize (GDom *pDoc)=0 |
Marshal this object into a DOM, which can then be converted to a variety of serial formats. | |
virtual void | init (sp_relation &pRelation)=0 |
This must be called before squaredDistance can be called. | |
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. | |
virtual double | squaredDistance (const double *pA, const double *pB) const =0 |
Computes the squared distance (or squared dissimilarity) between the two specified vectors. | |
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>&) | |
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*) | |
sp_relation & | relation () |
Returns the relation that specifies the meaning of the vector elements. | |
virtual double * | scaleFactors () |
Returns a pointer to the vector of scale factors. This may be NULL if the metric does not use scale factors. | |
Static Public Member Functions | |
static GDistanceMetric * | deserialize (GDomNode *pNode) |
Deserializes a distance metric. | |
Protected Member Functions | |
GDomNode * | baseDomNode (GDom *pDoc, const char *szClassName) |
Protected Attributes | |
sp_relation | 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.
GClasses::GDistanceMetric::GDistanceMetric | ( | ) | [inline] |
GClasses::GDistanceMetric::GDistanceMetric | ( | GDomNode * | pNode | ) |
virtual GClasses::GDistanceMetric::~GDistanceMetric | ( | ) | [inline, virtual] |
GDomNode* GClasses::GDistanceMetric::baseDomNode | ( | GDom * | pDoc, |
const char * | szClassName | ||
) | [protected] |
static GDistanceMetric* GClasses::GDistanceMetric::deserialize | ( | GDomNode * | pNode | ) | [static] |
Deserializes a distance metric.
virtual void GClasses::GDistanceMetric::init | ( | sp_relation & | pRelation | ) | [pure virtual] |
This must be called before squaredDistance can be called.
Implemented in GClasses::GRowDistance, GClasses::GRowDistanceScaled, and GClasses::GLNormDistance.
double GClasses::GDistanceMetric::operator() | ( | const std::vector< double > & | a, |
const std::vector< double > & | b | ||
) | const [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>&)
double GClasses::GDistanceMetric::operator() | ( | const double * | pA, |
const double * | pB | ||
) | 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 double*, const double*)
sp_relation& GClasses::GDistanceMetric::relation | ( | ) | [inline] |
Returns the relation that specifies the meaning of the vector elements.
virtual double* GClasses::GDistanceMetric::scaleFactors | ( | ) | [inline, virtual] |
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::GRowDistance, GClasses::GRowDistanceScaled, and GClasses::GLNormDistance.
virtual double GClasses::GDistanceMetric::squaredDistance | ( | const std::vector< double > & | a, |
const std::vector< double > & | b | ||
) | const [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.
virtual double GClasses::GDistanceMetric::squaredDistance | ( | const double * | pA, |
const double * | pB | ||
) | const [pure virtual] |
Computes the squared distance (or squared dissimilarity) between the two specified vectors.
Implemented in GClasses::GRowDistance, GClasses::GRowDistanceScaled, and GClasses::GLNormDistance.
sp_relation GClasses::GDistanceMetric::m_pRelation [protected] |