00001 #ifndef theplu_yat_statistics_euclidean_distance_h
00002 #define theplu_yat_statistics_euclidean_distance_h
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #include "AveragerPair.h"
00026 #include "AveragerPairWeighted.h"
00027 #include "yat/utility/iterator_traits.h"
00028
00029 #include <cmath>
00030
00031 namespace theplu {
00032 namespace yat {
00033 namespace statistics {
00034
00042 struct EuclideanDistance
00043 {
00062 template <typename Iter1, typename Iter2>
00063 double operator()
00064 (Iter1 beg1,Iter1 end1, Iter2 beg2) const
00065 {
00066 return this->distance(beg1, end1, beg2,
00067 typename utility::weighted_if_any2<Iter1,Iter2>::type());
00068 }
00069
00070 private:
00071 template <typename Iter1, typename Iter2>
00072 double distance (Iter1 beg1,Iter1 end1, Iter2 beg2,
00073 utility::unweighted_iterator_tag) const
00074 {
00075 AveragerPair ap;
00076 add(ap,beg1,end1,beg2);
00077 return sqrt(ap.sum_squared_deviation());
00078 }
00079
00080 template <typename Iter1, typename Iter2>
00081 double distance (Iter1 beg1,Iter1 end1, Iter2 beg2,
00082 utility::weighted_iterator_tag) const
00083 {
00084 AveragerPairWeighted ap;
00085 add(ap,beg1,end1,beg2);
00086 return sqrt(std::distance(beg1,end1)*ap.msd());
00087 }
00088
00089 };
00090
00091 }}}
00092
00093 #endif