CMS 3D CMS Logo

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>
23  struct AbsReturnType {
24  typedef T type;
25  };
26 
27  template <typename T>
28  struct AbsReturnType<std::complex<T> > {
29  typedef T type;
30  };
31 
32  template <typename T>
33  struct AbsReturnType<const std::complex<T> > {
34  typedef T type;
35  };
36 
37  template <typename T>
38  struct AbsReturnType<volatile std::complex<T> > {
39  typedef T type;
40  };
41 
42  template <typename T>
43  struct AbsReturnType<const volatile std::complex<T> > {
44  typedef T type;
45  };
46 
47  // Signed type
48  template <typename T, int Unsigned = 0>
49  struct AbsHelper {
51 
52  inline static return_type delta(const T& v1, const T& v2) { return std::abs(v1 - v2); }
53 
54  inline static return_type value(const T& v1) { return std::abs(v1); }
55  };
56 
57  // Unsigned type
58  template <typename T>
59  struct AbsHelper<T, 1> {
61 
62  inline static return_type delta(const T& v1, const T& v2) { return v1 > v2 ? v1 - v2 : v2 - v1; }
63 
64  inline static return_type value(const T& v1) { return v1; }
65  };
66  } // namespace Private
67 
72  template <typename T>
73  inline typename Private::AbsReturnType<T>::type absDifference(const T& v1, const T& v2) {
75  }
76 
81  template <typename T>
82  inline typename Private::AbsReturnType<T>::type absValue(const T& v1) {
84  }
85 } // namespace npstat
86 
87 #endif // NPSTAT_ABSDIFFERENCE_HH_
npstat::Private::AbsHelper::value
static return_type value(const T &v1)
Definition: absDifference.h:54
npstat::Private::AbsHelper::return_type
Private::AbsReturnType< T >::type return_type
Definition: absDifference.h:50
watchdog.const
const
Definition: watchdog.py:83
npstat
Definition: AbsArrayProjector.h:14
npstat::absDifference
Private::AbsReturnType< T >::type absDifference(const T &v1, const T &v2)
Definition: absDifference.h:73
npstat::Private::AbsReturnType
Definition: absDifference.h:23
npstat::Private::AbsReturnType< const std::complex< T > >::type
T type
Definition: absDifference.h:34
npstat::Private::AbsReturnType< std::complex< T > >::type
T type
Definition: absDifference.h:29
dumpMFGeometry_cfg.delta
delta
Definition: dumpMFGeometry_cfg.py:25
npstat::Private::AbsHelper< T, 1 >::return_type
Private::AbsReturnType< T >::type return_type
Definition: absDifference.h:60
npstat::absValue
Private::AbsReturnType< T >::type absValue(const T &v1)
Definition: absDifference.h:82
npstat::Private::AbsReturnType< const volatile std::complex< T > >::type
T type
Definition: absDifference.h:44
npstat::Private::AbsHelper::delta
static return_type delta(const T &v1, const T &v2)
Definition: absDifference.h:52
npstat::Private::AbsHelper
Definition: absDifference.h:49
npstat::Private::AbsHelper< T, 1 >::value
static return_type value(const T &v1)
Definition: absDifference.h:64
std
Definition: JetResolutionObject.h:76
T
long double T
Definition: Basic3DVectorLD.h:48
relativeConstraints.value
value
Definition: relativeConstraints.py:53
npstat::Private::AbsReturnType::type
T type
Definition: absDifference.h:24
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
npstat::Private::AbsHelper< T, 1 >::delta
static return_type delta(const T &v1, const T &v2)
Definition: absDifference.h:62
npstat::Private::AbsReturnType< volatile std::complex< T > >::type
T type
Definition: absDifference.h:39