1 /**
2  *  Inline functions for computing the volume of even simplex (used in
3  *  pruner_prob.cpp and pruner_cost.cpp.
4  */
eval_poly(const int ld,const poly & p,const FT x)5 template <class FT> inline FT Pruner<FT>::eval_poly(const int ld, /*i*/ const poly &p, const FT x)
6 {
7   FT acc;
8   acc = 0.0;
9   for (int i = ld; i >= 0; --i)
10   {
11     acc = acc * x;
12     acc = acc + p[i];
13   }
14   return acc;
15 }
16 
integrate_poly(const int ld,poly & p)17 template <class FT> inline void Pruner<FT>::integrate_poly(const int ld, /*io*/ poly &p)
18 {
19   for (int i = ld; i >= 0; --i)
20   {
21     FT tmp;
22     tmp      = i + 1.;
23     p[i + 1] = p[i] / tmp;
24   }
25   p[0] = 0.0;
26 }
27 
28 /**
29  * volume of even simplex
30  */
31 template <class FT>
relative_volume(const int rd,const evec & b)32 inline FT Pruner<FT>::relative_volume(const int rd,
33                                       /*i*/ const evec &b)
34 {
35   poly P(rd + 1);
36   P[0]   = 1;
37   int ld = 0;
38   for (int i = rd - 1; i >= 0; --i)
39   {
40     integrate_poly(ld, P);
41     ld++;
42     P[0] = -1.0 * eval_poly(ld, P, b[i] / b[rd - 1]);
43   }
44   FT res = P[0] * tabulated_factorial[rd];
45   return (rd % 2) ? -res : res;
46 }
47