Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:24:19

0001 #ifndef PhysicsTools_Utilities_ParametricTrait_h
0002 #define PhysicsTools_Utilities_ParametricTrait_h
0003 
0004 #include "PhysicsTools/Utilities/interface/Functions.h"
0005 #include "PhysicsTools/Utilities/interface/Fraction.h"
0006 #include "PhysicsTools/Utilities/interface/Operations.h"
0007 
0008 namespace funct {
0009 
0010   template <typename F>
0011   struct Parametric {
0012     static const int value = 1;
0013   };
0014 
0015   template <int n>
0016   struct Parametric<Numerical<n> > {
0017     static const int value = 0;
0018   };
0019 
0020   template <int n, int m>
0021   struct Parametric<FractionStruct<n, m> > {
0022     static const int value = 0;
0023   };
0024 
0025 #define NON_PARAMETRIC(FUN)     \
0026   template <>                   \
0027   struct Parametric<FUN> {      \
0028     static const int value = 0; \
0029   }
0030 
0031 #define NON_PARAMETRIC_UNARY(FUN)                  \
0032   template <typename A>                            \
0033   struct Parametric<FUN<A> > {                     \
0034     static const int value = Parametric<A>::value; \
0035   }
0036 
0037   NON_PARAMETRIC_UNARY(AbsStruct);
0038   NON_PARAMETRIC_UNARY(SgnStruct);
0039   NON_PARAMETRIC_UNARY(ExpStruct);
0040   NON_PARAMETRIC_UNARY(LogStruct);
0041   NON_PARAMETRIC_UNARY(SinStruct);
0042   NON_PARAMETRIC_UNARY(CosStruct);
0043   NON_PARAMETRIC_UNARY(TanStruct);
0044   NON_PARAMETRIC_UNARY(MinusStruct);
0045 
0046 #define NON_PARAMETRIC_BINARY(FUN)                                         \
0047   template <typename A, typename B>                                        \
0048   struct Parametric<FUN<A, B> > {                                          \
0049     static const int value = Parametric<A>::value || Parametric<A>::value; \
0050   }
0051 
0052   NON_PARAMETRIC_BINARY(SumStruct);
0053   NON_PARAMETRIC_BINARY(ProductStruct);
0054   NON_PARAMETRIC_BINARY(RatioStruct);
0055   NON_PARAMETRIC_BINARY(PowerStruct);
0056 
0057 #undef NON_PARAMETRIC_UNARY
0058 #undef NON_PARAMETRIC_BINARY
0059 
0060 }  // namespace funct
0061 
0062 #endif