CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
absDifference.h
Go to the documentation of this file.
1 #ifndef NPSTAT_ABSDIFFERENCE_HH_
2 #define NPSTAT_ABSDIFFERENCE_HH_
3 
15 #include <cmath>
16 #include <complex>
17 
18 #include "Alignment/Geners/interface/IOIsUnsigned.hh"
19 
20 namespace npstat {
21  namespace Private {
22  template <typename T>
24  {
25  typedef T type;
26  };
27 
28  template <typename T>
29  struct AbsReturnType<std::complex<T> >
30  {
31  typedef T type;
32  };
33 
34  template <typename T>
35  struct AbsReturnType<const std::complex<T> >
36  {
37  typedef T type;
38  };
39 
40  template <typename T>
41  struct AbsReturnType<volatile std::complex<T> >
42  {
43  typedef T type;
44  };
45 
46  template <typename T>
47  struct AbsReturnType<const volatile std::complex<T> >
48  {
49  typedef T type;
50  };
51 
52  // Signed type
53  template <typename T, int Unsigned=0>
54  struct AbsHelper
55  {
57 
58  inline static return_type delta(const T& v1, const T& v2)
59  {return std::abs(v1 - v2);}
60 
61  inline static return_type value(const T& v1)
62  {return std::abs(v1);}
63  };
64 
65  // Unsigned type
66  template <typename T>
67  struct AbsHelper<T, 1>
68  {
70 
71  inline static return_type delta(const T& v1, const T& v2)
72  {return v1 > v2 ? v1 - v2 : v2 - v1;}
73 
74  inline static return_type value(const T& v1)
75  {return v1;}
76  };
77  }
78 
83  template<typename T>
84  inline typename Private::AbsReturnType<T>::type
85  absDifference(const T& v1, const T& v2)
86  {
88  }
89 
94  template<typename T>
95  inline typename Private::AbsReturnType<T>::type
96  absValue(const T& v1)
97  {
99  }
100 }
101 
102 #endif // NPSTAT_ABSDIFFERENCE_HH_
103 
dbl * delta
Definition: mlp_gen.cc:36
type
Definition: HCALResponse.h:21
static return_type delta(const T &v1, const T &v2)
Definition: absDifference.h:71
static return_type value(const T &v1)
Definition: absDifference.h:74
Private::AbsReturnType< T >::type absDifference(const T &v1, const T &v2)
Definition: absDifference.h:85
static return_type value(const T &v1)
Definition: absDifference.h:61
Private::AbsReturnType< T >::type return_type
Definition: absDifference.h:56
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
Private::AbsReturnType< T >::type absValue(const T &v1)
Definition: absDifference.h:96
Private::AbsReturnType< T >::type return_type
Definition: absDifference.h:69
string const
Definition: compareJSON.py:14
static return_type delta(const T &v1, const T &v2)
Definition: absDifference.h:58
long double T