damina::L1Distance Class Reference

L1 Distance implementation. More...

#include <L1Distance.h>

Inheritance diagram for damina::L1Distance:

Inheritance graph
[legend]
Collaboration diagram for damina::L1Distance:

Collaboration graph
[legend]
List of all members.

Public Member Functions

virtual double calculateDistance (struct svm_node *, struct svm_node *)
 Computes the L1 Distance between two points (poits are in libsvm format).
 L1Distance ()
 Constructor.
virtual ~L1Distance ()
 Destructor.

Detailed Description

L1 Distance implementation.

Definition at line 12 of file L1Distance.h.


Constructor & Destructor Documentation

damina::L1Distance::L1Distance (  ) 

Constructor.

Definition at line 8 of file L1Distance.cpp.

00008                                {
00009                 
00010         }

damina::L1Distance::~L1Distance (  )  [virtual]

Destructor.

Definition at line 15 of file L1Distance.cpp.

00015                                 {
00016         
00017         }


Member Function Documentation

double damina::L1Distance::calculateDistance ( struct svm_node *  px,
struct svm_node *  py 
) [virtual]

Computes the L1 Distance between two points (poits are in libsvm format).

Parameters:
px The first point
py The second point
Returns:
The value of the distance between two points

Implements damina::EuclideanDistance.

Definition at line 26 of file L1Distance.cpp.

00026                                                                                      {
00027                         double sum = 0;
00028                         while(px->index != -1 && py->index != -1)
00029                         {
00030                                 if(px->index == py->index)
00031                                 {
00032                                         sum += fabs(px->value - py->value);
00033                                         ++px;
00034                                         ++py;
00035                                 }
00036                                 else
00037                                 {
00038                                         if(px->index > py->index)
00039                                         {
00040                                                 sum += fabs(py->value);
00041                                                 ++py;
00042                                         }
00043                                         else
00044                                         {
00045                                                 sum += fabs(px->value);
00046                                                 ++px;
00047                                         }
00048                                 }
00049                         
00050                         }
00051                         while(px->index != -1)
00052                         {
00053                                 sum += fabs(px->value);
00054                                 ++px;
00055                         }
00056                         while (py->index != -1)
00057                         {
00058                                 sum += fabs (py->value);
00059                                 ++py;
00060                         }
00061                         return sum;
00062         }


The documentation for this class was generated from the following files:
Generated on Mon Sep 24 22:26:59 2007 for SVClustering by  doxygen 1.5.2