source: trunk/yat/statistics/euclidean_vector_distance.h @ 890

Last change on this file since 890 was 890, checked in by Markus Ringnér, 14 years ago

Refs #245 #246 #247

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$
5
6#include "AveragerPair.h"
7#include "AveragerPairWeighted.h"
8#include "vector_distance.h"
9
10#include <cmath>
11
12namespace theplu {
13namespace yat {
14
15namespace statistics {
16
17  ///
18  /// Provides a "label" for
19  /// the Euclidean distance measure.
20  ///
21  struct euclidean_vector_distance_tag 
22    : public vector_distance_tag
23  {
24    typedef euclidean_vector_distance_tag distance;
25  };
26
27
28  ///
29  /// implementation for distances between vectors
30  /// (containers with random access iterators) using a Euclidean
31  /// distance measure and iterators to unweighted containers.
32  ///
33  template <class Iter>
34  double vector_distance(Iter beg1,Iter end1, Iter beg2,
35                         const euclidean_vector_distance_tag& disttype,
36                         std::random_access_iterator_tag)
37  {
38    AveragerPair ap;
39    add(ap,beg1,end1,beg2);
40    return sqrt(ap.sum_squared_deviation());
41  }
42 
43
44  ///
45  /// implementation for distances between vectors
46  /// (containers with random access iterators) using a Euclidean
47  /// distance measure and iterators to weighted containers.
48  ///
49  template <class Iter>
50  double vector_distance(Iter beg1,Iter end1, Iter beg2,
51                         const euclidean_vector_distance_tag& disttype,
52                         std::weighted_random_access_iterator_tag)
53  {
54    AveragerPairWeighted ap;
55    add(ap,beg1,end1,beg2);
56    return sqrt(ap.sum_squared_deviation());
57  }
58
59 
60}}} // of namespace statistics, yat, and theplu
61   
62#endif
Note: See TracBrowser for help on using the repository browser.