2 #ifndef __EUCLIDEAN_H__
3 #define __EUCLIDEAN_H__
5 #include <dignea/utilities/exceptions/Mismatch.h>
24 T
compute(
const vector<T>&,
const vector<T>&);
27 template <
typename I1,
typename I2>
28 T euclidean(I1 first1, I1 last1, I2 first2);
41 if (ind1.size() != ind2.size()) {
42 string where =
"individuals sizes in Euclidean::compute";
43 throw(Mismatch(where));
45 return euclidean(begin(ind1), end(ind1), begin(ind2));
49 template <
typename I1,
typename I2>
52 while (first != last) {
53 double dist = (*first++) - (*first2++);
54 distance += dist * dist;
56 return distance > 0.0 ? sqrt(distance) : 0.0;
Abstract Distance Class to create an interface which can be use in different algorithms.
Definition: Distance.h:20
Euclidean distance.
Definition: Euclidean.h:18
T compute(const vector< T > &, const vector< T > &)
Computes the Euclidean distance between the two vectors.
Definition: Euclidean.h:40