CDistance Class Reference


Detailed Description

class Distance

All distance classes are derived from this base class.

Definition at line 53 of file Distance.h.

Inheritance diagram for CDistance:
Inheritance graph
[legend]

List of all members.

Public Member Functions

 CDistance ()
 CDistance (CFeatures *lhs, CFeatures *rhs)
virtual ~CDistance ()
float64_t distance (int32_t idx_a, int32_t idx_b)
void get_distance_matrix (float64_t **dst, int32_t *m, int32_t *n)
virtual float64_tget_distance_matrix_real (int32_t &m, int32_t &n, float64_t *target)
virtual float32_tget_distance_matrix_shortreal (int32_t &m, int32_t &n, float32_t *target)
virtual bool init (CFeatures *lhs, CFeatures *rhs)
virtual void cleanup ()=0
bool load (char *fname)
bool save (char *fname)
CFeaturesget_lhs ()
CFeaturesget_rhs ()
CFeaturesreplace_rhs (CFeatures *rhs)
virtual void remove_lhs_and_rhs ()
virtual void remove_lhs ()
 takes all necessary steps if the lhs is removed from distance matrix
virtual void remove_rhs ()
 takes all necessary steps if the rhs is removed from distance matrix
virtual EDistanceType get_distance_type ()=0
virtual EFeatureType get_feature_type ()=0
virtual EFeatureClass get_feature_class ()=0
bool get_precompute_matrix ()
virtual void set_precompute_matrix (bool flag)
int32_t get_num_vec_lhs ()
int32_t get_num_vec_rhs ()
bool has_features ()
bool lhs_equals_rhs ()

Protected Member Functions

virtual float64_t compute (int32_t x, int32_t y)=0
void do_precompute_matrix ()
 matrix precomputation

Protected Attributes

float32_tprecomputed_matrix
bool precompute_matrix
CFeatureslhs
 feature vectors to occur on left hand side
CFeaturesrhs
 feature vectors to occur on right hand side

Constructor & Destructor Documentation

CDistance (  ) 

default constructor

Definition at line 32 of file Distance.cpp.

CDistance ( CFeatures lhs,
CFeatures rhs 
)

init distance

Parameters:
lhs features of left-hand side
rhs features of right-hand side
Returns:
if init was successful

Definition at line 39 of file Distance.cpp.

~CDistance (  )  [virtual]

Definition at line 46 of file Distance.cpp.


Member Function Documentation

virtual void cleanup (  )  [pure virtual]
virtual float64_t compute ( int32_t  x,
int32_t  y 
) [protected, pure virtual]

compute distance function for features a and b idx_{a,b} denote the index of the feature vectors in the corresponding feature object

Implemented in CBrayCurtisDistance, CCanberraMetric, CCanberraWordDistance, CChebyshewMetric, CChiSquareDistance, CCosineDistance, CEuclidianDistance, CGeodesicMetric, CHammingWordDistance, CJensenMetric, CManhattanMetric, CManhattanWordDistance, CMinkowskiMetric, CSparseEuclidianDistance, and CTanimotoDistance.

float64_t distance ( int32_t  idx_a,
int32_t  idx_b 
)

get distance function for lhs feature vector a and rhs feature vector b

Parameters:
idx_a feature vector a at idx_a
idx_b feature vector b at idx_b
Returns:
distance value

Definition at line 75 of file Distance.h.

void do_precompute_matrix (  )  [protected]

matrix precomputation

Definition at line 160 of file Distance.cpp.

void get_distance_matrix ( float64_t **  dst,
int32_t *  m,
int32_t *  n 
)

get distance matrix

Parameters:
dst distance matrix is stored in here
m dimension m of matrix is stored in here
n dimension n of matrix is stored in here

Definition at line 184 of file Distance.cpp.

float64_t * get_distance_matrix_real ( int32_t &  m,
int32_t &  n,
float64_t target 
) [virtual]

get distance matrix real

Parameters:
m dimension m
n dimension n
target target matrix
Returns:
target matrix

Definition at line 320 of file Distance.cpp.

float32_t * get_distance_matrix_shortreal ( int32_t &  m,
int32_t &  n,
float32_t target 
) [virtual]

get distance matrix short real

Parameters:
m dimension m
n dimension n
target target matrix
Returns:
target matrix

Definition at line 251 of file Distance.cpp.

virtual EDistanceType get_distance_type (  )  [pure virtual]
virtual EFeatureClass get_feature_class (  )  [pure virtual]

get feature class the distance can deal with

abstract base method

Returns:
feature class

Implemented in CSimpleDistance< ST >, CSparseDistance< ST >, CStringDistance< ST >, CSimpleDistance< float64_t >, CSparseDistance< float64_t >, and CStringDistance< uint16_t >.

virtual EFeatureType get_feature_type (  )  [pure virtual]
CFeatures* get_lhs (  ) 

get left-hand side features used in distance matrix

Returns:
left-hand side features

Definition at line 171 of file Distance.h.

int32_t get_num_vec_lhs (  ) 

get number of vectors of lhs features

Returns:
number of vectors of left-hand side

Definition at line 249 of file Distance.h.

int32_t get_num_vec_rhs (  ) 

get number of vectors of rhs features

Returns:
number of vectors of right-hand side

Definition at line 261 of file Distance.h.

bool get_precompute_matrix (  ) 

FIXME: precompute matrix should be dropped, handling should be via customdistance

Returns:
if precompute_matrix

Definition at line 227 of file Distance.h.

CFeatures* get_rhs (  ) 

get right-hand side features used in distance matrix

Returns:
right-hand side features

Definition at line 177 of file Distance.h.

bool has_features (  ) 

test whether features have been assigned to lhs and rhs

Returns:
true if features are assigned

Definition at line 273 of file Distance.h.

bool init ( CFeatures lhs,
CFeatures rhs 
) [virtual]

init distance

make sure to check that your distance can deal with the supplied features (!)

Parameters:
lhs features of left-hand side
rhs features of right-hand side
Returns:
if init was successful

Reimplemented in CBrayCurtisDistance, CCanberraMetric, CCanberraWordDistance, CChebyshewMetric, CChiSquareDistance, CCosineDistance, CEuclidianDistance, CGeodesicMetric, CHammingWordDistance, CJensenMetric, CManhattanMetric, CManhattanWordDistance, CMinkowskiMetric, CRealDistance, CSimpleDistance< ST >, CSparseDistance< ST >, CSparseEuclidianDistance, CStringDistance< ST >, CTanimotoDistance, CSimpleDistance< float64_t >, CSparseDistance< float64_t >, and CStringDistance< uint16_t >.

Definition at line 54 of file Distance.cpp.

bool lhs_equals_rhs (  ) 

test whether features on lhs and rhs are the same

Returns:
true if features are the same

Definition at line 282 of file Distance.h.

bool load ( char *  fname  ) 

load distance matrix from file

Parameters:
fname filename to load from
Returns:
if loading was successful

Definition at line 81 of file Distance.cpp.

void remove_lhs (  )  [virtual]

takes all necessary steps if the lhs is removed from distance matrix

Definition at line 127 of file Distance.cpp.

void remove_lhs_and_rhs (  )  [virtual]

remove lhs and rhs from distance

Definition at line 117 of file Distance.cpp.

void remove_rhs (  )  [virtual]

takes all necessary steps if the rhs is removed from distance matrix

takes all necessary steps if the rhs is removed from kernel

Definition at line 134 of file Distance.cpp.

CFeatures * replace_rhs ( CFeatures rhs  ) 

replace right-hand side features used in distance matrix

make sure to check that your distance can deal with the supplied features (!)

Parameters:
rhs features of right-hand side
Returns:
replaced right-hand side features

Definition at line 140 of file Distance.cpp.

bool save ( char *  fname  ) 

save distance matrix to file

Parameters:
fname filename to save to
Returns:
if saving was successful

Definition at line 86 of file Distance.cpp.

virtual void set_precompute_matrix ( bool  flag  )  [virtual]

FIXME: precompute matrix should be dropped, handling should be via customdistance

Parameters:
flag if precompute_matrix

Definition at line 234 of file Distance.h.


Member Data Documentation

CFeatures* lhs [protected]

feature vectors to occur on left hand side

Definition at line 308 of file Distance.h.

bool precompute_matrix [protected]

FIXME: precompute matrix should be dropped, handling should be via customdistance

Definition at line 305 of file Distance.h.

FIXME: precompute matrix should be dropped, handling should be via customdistance

Definition at line 300 of file Distance.h.

CFeatures* rhs [protected]

feature vectors to occur on right hand side

Definition at line 310 of file Distance.h.


The documentation for this class was generated from the following files:

SHOGUN Machine Learning Toolbox - Documentation