From: Sven Verdoolaege Date: Sat, 2 Feb 2013 07:45:52 +0000 (+0100) Subject: barvinok_sum_over_polytope: special case 0D polytopes X-Git-Tag: barvinok-0.37~74 X-Git-Url: https://repo.or.cz/w/barvinok.git/commitdiff_plain/19eb73e3abba2c4dc3e8c86a9bf611d5dc9fc9ea barvinok_sum_over_polytope: special case 0D polytopes Some of the summation method implementations, e.g., laurent_summate, cannot handle 0D polytopes. Since computing the sum over 0D polytopes is trivial, we might as well do it up front. Reported-by: Tomofumi Yuki Signed-off-by: Sven Verdoolaege --- diff --git a/summate.c b/summate.c index abbf22b..7b5ae2e 100644 --- a/summate.c +++ b/summate.c @@ -681,6 +681,9 @@ evalue *barvinok_sum_over_polytope(Polyhedron *P, evalue *E, unsigned nvar, if (P->NbEq) return sum_over_polytope_with_equalities(P, E, nvar, sections, options); + if (nvar == 0) + return sum_over_polytope_0D(Polyhedron_Copy(P), evalue_dup(E)); + if (options->summation == BV_SUM_BERNOULLI) return bernoulli_summate(P, E, nvar, sections, options); else if (options->summation == BV_SUM_BOX) diff --git a/tests/iscc/sum5 b/tests/iscc/sum5 new file mode 100644 index 0000000..8c475fc --- /dev/null +++ b/tests/iscc/sum5 @@ -0,0 +1,2 @@ +r := sum { [] -> 1 }; +assert(r == { 1 });