1 #ifndef PhysicsTools_Utilities_Factorize_h
2 #define PhysicsTools_Utilities_Factorize_h
8 #include <boost/type_traits.hpp>
9 #include <boost/mpl/and.hpp>
10 #include <boost/mpl/not.hpp>
11 #include <boost/mpl/int.hpp>
19 static const bool value =
false;
26 public Divides0<
A> { };
29 public Divides0<
PROD_S(A, B)> { };
32 public Divides<A, void> { };
35 static const bool value =
true;
41 TEMPL(T1) struct Divides<
A, A> :
52 public Divides<POWER(A, NUM(n)), void> { };
55 static const bool value =
true;
57 static const int p = ::boost::mpl::if_c<(n <
m),
58 ::boost::mpl::int_<n>, ::boost::mpl::int_<m> >::
type::value;
69 public ParametricDivN<1, n, A> { };
76 template<
int n,
bool positive = (n>= 0)>
77 struct abs {
enum { value = n }; };
80 struct abs<n, false> {
enum { value = -n }; };
86 static const bool value = (gcd != 1);
93 static const bool value =
true;
100 public Divides<A,
B> { };
103 public Divides<
PROD_S(A, B),
C> { };
106 typedef Divides<A, B>
Div;
114 typedef Divides<A, B>
Div;
122 typedef Divides<A, PROD_S(B, C)>
Div;
131 typedef Divides<arg, void>
D0;
132 typedef Divides<arg, B>
D1;
133 typedef Divides<arg, C>
D2;
134 typedef typename ::boost::mpl::if_<
D1,
D1,
143 typedef Divides<arg, void>
D0;
144 typedef Divides<A, C>
D1;
145 typedef Divides<B, C>
D2;
146 typedef typename ::boost::mpl::if_<
D1,
D1,
156 typedef Divides<arg, void>
D0;
157 typedef Divides<arg, C>
D1;
158 typedef Divides<arg, D>
D2;
159 typedef typename ::boost::mpl::if_<
D1,
D1,
186 inline static type
combine(
const A& _1,
const B& _2) {
188 return f * ((_1 /
f) + (_2 / f));
196 public FactorizeSum<A,
PROD_S(B, C)> { };
214 public FactorizeSum<
PROD_S(A, B),
223 public FactorizeSum<
PROD_S(A, B),
NUM(n)> { };
226 public FactorizeSum<
NUM(n),
PROD_S(A, B)> { };
const Numerical< n > & num()
typedef POWER(A, NUM(n)) arg
typedef SUM(SUM(PROD(NUM(n-p), SIN2(A)), PROD(NUM(m-p), COS2(A))), NUM(p)) type
static type combine(const A &_1, const B &_2)
typedef PROD(F, SUM(RATIO(A, F), RATIO(B, F))) type
COMBINE(A, B, type(_1, _2))
static uInt32 F(BLOWFISH_CTX *ctx, uInt32 x)
static type get(const PROD_S(A, B)&_)
DecomposeProduct< arg, typename Div::arg > D
Power< A, B >::type pow(const A &a, const B &b)
T get(const Candidate &c)
::boost::mpl::if_< D1, D1, typename::boost::mpl::if_< D2, D2, D0 >::type >::type Div