damina::L2Distance Class Reference

L2 Distance implementation. More...

#include <L2Distance.h>

Inheritance diagram for damina::L2Distance:

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

Collaboration graph
[legend]
List of all members.

Public Member Functions

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

Detailed Description

L2 Distance implementation.

Definition at line 13 of file L2Distance.h.


Constructor & Destructor Documentation

damina::L2Distance::L2Distance (  ) 

Constructor.

Definition at line 8 of file L2Distance.cpp.

00008                                {
00009                 
00010         }

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

Destructor.

Definition at line 15 of file L2Distance.cpp.

00015                                 {
00016         
00017         }


Member Function Documentation

double damina::L2Distance::calculateDistance ( struct svm_node *  x,
struct svm_node *  y 
) [virtual]

Computes the L2 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 L2Distance.cpp.

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


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