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

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

A first suggestion for how to adress #250. Also removed contamination of namespace std (see #251).

• 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 898 2007-09-26 13:44:19Z markus \$
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 <typename Iter1, typename Iter2>
34  double vector_distance(Iter1 beg1,Iter1 end1, Iter2 beg2,
35                         const euclidean_vector_distance_tag& disttype,
36                         std::random_access_iterator_tag)
37  {
38    AveragerPair ap;
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 <typename Iter1, typename Iter2>
50  double vector_distance(Iter1 beg1, Iter1 end1, Iter2 beg2,
51                         const euclidean_vector_distance_tag& disttype,
52                         utility::weighted_random_access_iterator_tag)
53  {
54    AveragerPairWeighted ap;