CManhattanMetric Class Reference

Inheritance diagram for CManhattanMetric:

Inheritance graph
[legend]

List of all members.


Detailed Description

class ManhattanMetric

The Manhattan distance (city block distance,$L_{1}$ norm, rectilinear distance or taxi cab metric ) is a special case of general Minkowski metric and computes the absolute differences between the feature dimensions of two data points.

\[\displaystyle d(\bf{x},\bf{x'}) = \sum_{i=1}^{n} |\bf{x_{i}}-\bf{x'_{i}}| \quad \bf{x},\bf{x'} \in R^{n} \]

See also:
CMinkowskiMetric

Wikipedia: Manhattan distance

Definition at line 34 of file ManhattanMetric.h.


Public Member Functions

 CManhattanMetric ()
 CManhattanMetric (CRealFeatures *l, CRealFeatures *r)
virtual ~CManhattanMetric ()
virtual bool init (CFeatures *l, CFeatures *r)
virtual void cleanup ()
virtual bool load_init (FILE *src)
virtual bool save_init (FILE *dest)
virtual EDistanceType get_distance_type ()
virtual const char * get_name ()

Protected Member Functions

virtual float64_t compute (int32_t idx_a, int32_t idx_b)

Constructor & Destructor Documentation

CManhattanMetric::CManhattanMetric (  ) 

default constructor

Definition at line 18 of file ManhattanMetric.cpp.

CManhattanMetric::CManhattanMetric ( CRealFeatures l,
CRealFeatures r 
)

constructor

Parameters:
l features of left-hand side
r features of right-hand side

Definition at line 23 of file ManhattanMetric.cpp.

CManhattanMetric::~CManhattanMetric (  )  [virtual]

Definition at line 29 of file ManhattanMetric.cpp.


Member Function Documentation

bool CManhattanMetric::init ( CFeatures l,
CFeatures r 
) [virtual]

init distance

Parameters:
l features of left-hand side
r features of right-hand side
Returns:
if init was successful

Reimplemented from CSimpleDistance< ST >.

Definition at line 34 of file ManhattanMetric.cpp.

void CManhattanMetric::cleanup (  )  [virtual]

cleanup distance

Implements CDistance.

Definition at line 41 of file ManhattanMetric.cpp.

bool CManhattanMetric::load_init ( FILE *  src  )  [virtual]

load init data from file

Parameters:
src file to load from
Returns:
if loading was successful

Implements CDistance.

Definition at line 45 of file ManhattanMetric.cpp.

bool CManhattanMetric::save_init ( FILE *  dest  )  [virtual]

save init data to file

Parameters:
dest file to save to
Returns:
if saving was successful

Implements CDistance.

Definition at line 50 of file ManhattanMetric.cpp.

virtual EDistanceType CManhattanMetric::get_distance_type (  )  [virtual]

get distance type we are

Returns:
distance type MANHATTAN

Implements CDistance.

Definition at line 77 of file ManhattanMetric.h.

virtual const char* CManhattanMetric::get_name (  )  [virtual]

get name of the distance

Returns:
name Manhattan-Metric

Implements CDistance.

Definition at line 83 of file ManhattanMetric.h.

float64_t CManhattanMetric::compute ( int32_t  idx_a,
int32_t  idx_b 
) [protected, virtual]

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

Implements CDistance.

Definition at line 55 of file ManhattanMetric.cpp.


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

SHOGUN Machine Learning Toolbox - Documentation