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

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

Minor modifications

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