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

Refs #245. A new structure to calculate distances between vectors that is based on iterators and traits patterns. Will replace the old inherited Distance structure. Support for iterators to weighted containers is not yet added

File size:
993 bytes

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 "vector_distance.h" 

8  

9  #include <cmath> 

10  

11  namespace theplu { 

12  namespace yat { 

13  

14  namespace statistics { 

15  

16  /// 

17  /// Provides a "label" for 

18  /// the Euclidean distance measure. 

19  /// 

20  struct euclidean_vector_distance_tag 

21  : public vector_distance_tag 

22  { 

23  typedef euclidean_vector_distance_tag distance; 

24  }; 

25  

26  

27  /// 

28  /// implementation for distances between vectors 

29  /// (containers with random access iterators) using a Euclidean 

30  /// distance measure and iterators to unweighted containers. 

31  /// 

32  template <class Iter> 

33  double vector_distance(Iter beg1,Iter end1, Iter beg2, 

34  const euclidean_vector_distance_tag& disttype, 

35  std::random_access_iterator_tag) 

36  { 

37  AveragerPair ap; 

38  add(ap,beg1,end1,beg2); 

39  return sqrt(ap.sum_squared_deviation()); 

40  } 

41  

42  

43  }}} // of namespace statistics, yat, and theplu 

44  

45  #endif 

Note: See
TracBrowser
for help on using the repository browser.