Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #ifndef PhysicsTools_Utilities_Sum_h
0002 #define PhysicsTools_Utilities_Sum_h
0003 #include "PhysicsTools/Utilities/interface/Numerical.h"
0004 
0005 namespace funct {
0006   template <typename A, typename B>
0007   struct SumStruct {
0008     SumStruct(const A& a, const B& b) : _1(a), _2(b) {}
0009     double operator()() const { return _1() + _2(); }
0010     operator double() const { return _1() + _2(); }
0011     double operator()(double x) const { return _1(x) + _2(x); }
0012     double operator()(double x, double y) const { return _1(x, y) + _2(x, y); }
0013     A _1;
0014     B _2;
0015   };
0016 
0017   template <typename A, typename B>
0018   struct Sum {
0019     typedef SumStruct<A, B> type;
0020     static type combine(const A& a, const B& b) { return type(a, b); }
0021   };
0022 
0023   template <typename A, typename B>
0024   inline typename Sum<A, B>::type operator+(const A& a, const B& b) {
0025     return Sum<A, B>::combine(a, b);
0026   }
0027 
0028 }  // namespace funct
0029 
0030 #endif