# source:trunk/yat/statistics/euclidean_vector_distance.h@937

Last change on this file since 937 was 937, checked in by Peter, 16 years ago

changing name of IteratorTraits? to iterator_traits

• Property svn:eol-style set to `native`
• Property svn:keywords set to `Id`
File size: 1.5 KB
Line
1#ifndef theplu_yat_statistics_euclidean_vector_distance_h
2#define theplu_yat_statistics_euclidean_vector_distance_h
3
4// \$Id: euclidean_vector_distance.h 937 2007-10-05 23:11:18Z peter \$
5
6#include "AveragerPair.h"
7#include "AveragerPairWeighted.h"
8#include "vector_distance.h"
9#include "yat/utility/iterator_traits.h"
10
11#include <cmath>
12
13namespace theplu {
14namespace yat {
15
16namespace statistics {
17
18  ///
19  /// Provides a "label" for
20  /// the Euclidean distance measure.
21  ///
22  struct euclidean_vector_distance_tag
23    : public vector_distance_tag
24  {
25    typedef euclidean_vector_distance_tag distance;
26  };
27
28
29  ///
30  /// implementation for distances between vectors
31  /// (containers with random access iterators) using a Euclidean
32  /// distance measure and iterators to unweighted containers.
33  ///
34  template <typename Iter1, typename Iter2>
35  double vector_distance(Iter1 beg1,Iter1 end1, Iter2 beg2,
36                         const euclidean_vector_distance_tag& disttype,
37                         utility::unweighted_type)
38  {
39    AveragerPair ap;
41    return sqrt(ap.sum_squared_deviation());
42  }
43
44
45  ///
46  /// implementation for distances between vectors
47  /// (containers with random access iterators) using a Euclidean
48  /// distance measure and iterators to weighted containers.
49  ///
50  template <typename Iter1, typename Iter2>
51  double vector_distance(Iter1 beg1, Iter1 end1, Iter2 beg2,
52                         const euclidean_vector_distance_tag& disttype,
53                         utility::weighted_type)
54  {
55    AveragerPairWeighted ap;