CMS 3D CMS Logo

Sgn.h
Go to the documentation of this file.
1 #ifndef PhysicsTools_Utilities_Sgn_h
2 #define PhysicsTools_Utilities_Sgn_h
3 
4 namespace funct {
5 
6  template<typename T>
7  struct SgnStruct {
8  SgnStruct(const T& t) : _(t) { }
9  inline double operator()() const { return _() >= 0 ? 1 : -1; }
10  inline operator double() const { return _() >= 0 ? 1 : -1; }
11  T _;
12  };
13 
14  template<typename T>
15  struct Sgn {
16  typedef SgnStruct<T> type;
17  inline static type compose(const T& t) { return type(t); }
18  };
19 
20  template<typename T>
21  inline typename Sgn<T>::type sgn(const T & t) {
22  return Sgn<T>::compose(t);
23  }
24 
25 }
26 
27 #endif
Definition: Abs.h:5
static type compose(const T &t)
Definition: Sgn.h:17
Definition: Sgn.h:15
SgnStruct< T > type
Definition: Sgn.h:16
Sgn< T >::type sgn(const T &t)
Definition: Sgn.h:21
arg type
Definition: Factorize.h:38
SgnStruct(const T &t)
Definition: Sgn.h:8
double operator()() const
Definition: Sgn.h:9
long double T