source: trunk/yat/statistics/vector_distance.h @ 966

Last change on this file since 966 was 966, checked in by Peter, 15 years ago

fixing some doxygen warnings

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 2.0 KB
Line 
1#ifndef theplu_yat_statistics_vector_distance_h
2#define theplu_yat_statistics_vector_distance_h
3
4// $Id: vector_distance.h 966 2007-10-11 17:01:01Z peter $
5
6#include <iterator>
7
8#include "yat/classifier/DataLookup1D.h"
9#include "yat/classifier/DataLookupWeighted1D.h"
10#include "yat/utility/iterator_traits.h"
11
12namespace theplu {
13namespace yat {
14
15namespace statistics {
16 
17  ///
18  /// For each measure to calculate distances between containers
19  /// with random access iterators one should provide a struct
20  /// that inherits from vector_distance_tag and provides a "label" for
21  /// the distance measure.
22  ///
23  struct vector_distance_tag {
24    /// tag defining distance measure
25    typedef vector_distance_tag distance;
26  };
27
28
29  ///
30  /// We are writing a generic function for all distance measures
31  /// between containers with random access iterators (below). The
32  /// general function does not have to know anything about different
33  /// distance measures.  Instead it can access the "label" of each
34  /// distance measure through the special template structure
35  /// vector_distance_traits.
36  ///
37  template <class T>
38  struct vector_distance_traits {
39    /// \return distance type
40    typedef typename T::distance distance;
41  };
42
43
44  ///
45  /// The general function for calculating distances between vectors
46  /// (containers with random access iterators). This general function
47  /// calls specialized distance functions implementing various
48  /// distance measures based on the "label" of a distance type object
49  /// (templatized as Dist). It can also call separate implementations
50  /// for iterators to weighted and unweighted iterators based on the
51  /// trait of the iterators (templatized as Iter1 and Iter2).
52  ///
53  template <typename Iter1, typename Iter2, typename Dist>
54  double vector_distance(Iter1 beg1, Iter1 end1, Iter2 beg2, const Dist disttag)
55  {
56    return 
57      vector_distance(beg1,end1,beg2,
58                      typename vector_distance_traits<Dist>::distance(),
59                      typename utility::weighted_if_any2<Iter1, Iter2>::type());
60  }       
61
62}}} // of namespace statistics, yat, and theplu
63
64#endif
Note: See TracBrowser for help on using the repository browser.