Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:33:26

0001 #ifndef PhysicsTools_Utilities_Abs_h
0002 #define PhysicsTools_Utilities_Abs_h
0003 #include <cmath>
0004 
0005 namespace funct {
0006 
0007   template <typename T>
0008   struct AbsStruct {
0009     AbsStruct(const T& t) : _(t) {}
0010     inline double operator()() const { return ::fabs(_()); }
0011     inline operator double() const { return ::fabs(_()); }
0012     T _;
0013   };
0014 
0015   template <typename T>
0016   struct Abs {
0017     typedef AbsStruct<T> type;
0018     inline static type compose(const T& t) { return type(t); }
0019   };
0020 
0021   template <typename T>
0022   inline typename Abs<T>::type abs(const T& t) {
0023     return Abs<T>::compose(t);
0024   }
0025 
0026 }  // namespace funct
0027 
0028 #endif