Go to the documentation of this file.00001 #ifndef PhysicsTools_Utilities_SimplifyNumerical_h
00002 #define PhysicsTools_Utilities_SimplifyNumerical_h
00003 #include "PhysicsTools/Utilities/interface/Numerical.h"
00004 #include "PhysicsTools/Utilities/interface/Operations.h"
00005
00006 namespace funct {
00007
00008 template<int n, int m>
00009 struct Sum<Numerical<n>, Numerical<m> > {
00010 typedef Numerical<n + m> type;
00011 inline static type combine(const Numerical<n>&, const Numerical<m>&)
00012 { return type(); }
00013 };
00014
00015 template<int n, int m>
00016 struct Difference<Numerical<n>, Numerical<m> > {
00017 typedef Numerical<n - m> type;
00018 inline static type combine(const Numerical<n>&, const Numerical<m>&)
00019 { return type(); }
00020 };
00021
00022 template<int n>
00023 struct Minus<Numerical<n> > {
00024 typedef Numerical<- n> type;
00025 inline static type operate(const Numerical<n>&)
00026 { return type(); }
00027 };
00028
00029 template<int n, int m>
00030 struct Product<Numerical<n>, Numerical<m> > {
00031 typedef Numerical<n * m> type;
00032 inline static type combine(const Numerical<n>&, const Numerical<m>&)
00033 { return type(); }
00034 };
00035
00036 template<int n>
00037 struct Ratio<Numerical<n>, Numerical<1> > {
00038 typedef Numerical<n> type;
00039 inline static type combine(const Numerical<n>&, const Numerical<1>&)
00040 { return type(); }
00041 };
00042
00043
00044 template<int n, int m, bool posM = (m > 0)>
00045 struct NumPower {
00046 typedef Numerical<n * NumPower<n, m-1>::type::value> type;
00047 inline static type combine(const Numerical<n>&, const Numerical<m>&)
00048 { return type(); }
00049 };
00050
00051
00052 template<int m, bool posM>
00053 struct NumPower<1, m, posM> {
00054 typedef Numerical<1> type;
00055 inline static type combine(const Numerical<1>&, const Numerical<m>&)
00056 { return type(); }
00057 };
00058
00059
00060 template<int n>
00061 struct NumPower<n, 1, true> {
00062 typedef Numerical<n> type;
00063 inline static type combine(const Numerical<n>&, const Numerical<1>&)
00064 { return type(); }
00065 };
00066
00067
00068 template<int n>
00069 struct NumPower<n, 0, true> {
00070 typedef Numerical<1> type;
00071 inline static type combine(const Numerical<n>&, const Numerical<0>&)
00072 { return type(); }
00073 };
00074
00075
00076 template<int n, int m>
00077 struct NumPower<n, m, false> {
00078 typedef typename Fraction<1, NumPower<n, -m>::type::value>::type type;
00079 inline static type combine(const Numerical<n>&, const Numerical<m>&)
00080 { return type(); }
00081 };
00082
00083 template<int n, int m>
00084 struct Power<Numerical<n>, Numerical<m> > : public NumPower<n, m> {
00085 };
00086
00087
00088 }
00089
00090 #endif