CMS 3D CMS Logo

SimplifyLogExp.h
Go to the documentation of this file.
1 #ifndef PhysicsTools_Utilities_SimplifyLogExp_h
2 #define PhysicsTools_Utilities_SimplifyLogExp_h
3 
11 
13 
14 namespace funct {
15  // log(exp(a)) = a
16  LOG_RULE(TYPT1, EXP_S(A), A, _._);
17 
18  // exp(log(a)) = a
19  EXP_RULE(TYPT1, LOG_S(A), A, _._);
20 
21  // log(a ^ b) = b * log(a)
22  LOG_RULE(TYPT2, POWER_S(A, B), PROD(B, LOG(A)), _._2 * log(_._1));
23 
24  // exp(a) * exp(b) = exp(a + b)
25  PROD_RULE(TYPT2, EXP_S(A), EXP_S(B), EXP(SUM(A, B)), exp(_1._ + _2._));
26 
27  // log(a * b) = log(a) + log (b)
28  LOG_RULE(TYPT2, PROD_S(A, B), SUM(LOG(A), LOG(B)), log(_._1) + log(_._2));
29 
30  // log(a / b) = log(a) - log (b)
31  LOG_RULE(TYPT2, RATIO_S(A, B), DIFF(LOG(A), LOG(B)), log(_._1) - log(_._2));
32 
33  // exp(x) * x = x * exp(x)
34  PROD_RULE(TYPT1, EXP_S(A), A, PROD(A, EXP(A)), _2 * _1 );
35 
36  // log(x) * x = x * log(x)
37  PROD_RULE(TYPT1, LOG_S(A), A, PROD(A, LOG(A)), _2 * _1 );
38 
39 }
40 
42 
43 #endif
#define LOG_RULE(TMPL, T, RES, COMB)
#define EXP(A)
Definition: Abs.h:5
#define TYPT2
Definition: Simplify_begin.h:7
PROD_S(A, B)>
Definition: Factorize.h:45
POWER_S(A, NUM(n))>
Definition: Factorize.h:49
#define LOG(A)
Exp< T >::type exp(const T &t)
Definition: Exp.h:22
#define RATIO_S(A, B)
#define EXP_RULE(TMPL, T, RES, COMB)
#define LOG_S(A)
#define PROD_RULE(TMPL, T1, T2, RES, COMB)
Log< T >::type log(const T &t)
Definition: Log.h:22
#define SUM(A, B)
#define EXP_S(A)
typedef PROD(F, SUM(RATIO(A, F), RATIO(B, F))) type
typedef DIFF(PROD(A, B1), PRIMIT(X, PROD(A1, B1))) type
#define TYPT1
Definition: Simplify_begin.h:6