CMS 3D CMS Logo

Sum.h

Go to the documentation of this file.
00001 #ifndef PhysicsTools_Utilities_Sum_h
00002 #define PhysicsTools_Utilities_Sum_h
00003 #include "PhysicsTools/Utilities/interface/Numerical.h"
00004 #include <boost/static_assert.hpp>
00005 
00006 namespace funct {
00007   template<typename A, typename B>
00008   struct SumStruct { 
00009     SumStruct(const A & a, const B & b) : _1(a), _2(b) { }
00010     double operator()() const {
00011       return _1() + _2();
00012     }
00013     operator double() const {
00014       return _1() + _2();
00015     }
00016     double operator()(double x) const {
00017       return _1(x) + _2(x);
00018     }
00019     double operator()(double x, double y) const {
00020       return _1(x, y) + _2(x, y);
00021     }
00022     A _1; 
00023     B _2;
00024   };
00025 
00026   template<typename A, typename B>
00027   struct Sum {
00028     typedef SumStruct<A, B> type;
00029     static type combine(const A& a, const B& b) { return type(a, b); } 
00030   }; 
00031 
00032   template<typename A, typename B>
00033   inline typename Sum<A, B>::type operator+(const A& a, const B& b) {
00034     return Sum<A, B>::combine(a, b);
00035   }
00036 
00037 }
00038 
00039 #endif

Generated on Tue Jun 9 17:42:51 2009 for CMSSW by  doxygen 1.5.4