#include <L1Distance.h>
Inheritance diagram for damina::L1Distance:


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. | |
Definition at line 12 of file L1Distance.h.
| damina::L1Distance::L1Distance | ( | ) |
| damina::L1Distance::~L1Distance | ( | ) | [virtual] |
| 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).
| px | The first point | |
| py | The second point |
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 }
1.5.2