CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_10_patch1/src/PhysicsTools/Utilities/interface/NthDerivative.h

Go to the documentation of this file.
00001 #ifndef PhysicsTools_Utilities_NthDerivative_h
00002 #define PhysicsTools_Utilities_NthDerivative_h
00003 
00004 #include "PhysicsTools/Utilities/interface/Derivative.h"
00005 
00006 namespace funct {
00007 
00008   template<unsigned n, typename X, typename F>
00009     struct NthDerivative {
00010       typedef typename Derivative<X, typename NthDerivative<n - 1, X, F>::type>::type type;
00011       inline static type get(const F& f) { 
00012         return derivative<X>(NthDerivative< n - 1, X, F>::get(f)); 
00013       }
00014     };
00015 
00016   template<typename X, typename F>
00017     struct NthDerivative<1, X, F> : public Derivative< X, F > { };
00018 
00019   template<typename X, typename F> struct NthDerivative<0, X, F> {
00020     typedef F type;
00021     inline static type get(const F& f) { return f; }
00022   };
00023   
00024   template<unsigned n, typename X, typename F>
00025     typename NthDerivative<n, X, F>::type
00026     nth_derivative(const F& f) { return NthDerivative< n, X, F >::get(f); }
00027   
00028 }
00029 
00030 #endif