From 19eb73e3abba2c4dc3e8c86a9bf611d5dc9fc9ea Mon Sep 17 00:00:00 2001 From: Sven Verdoolaege Date: Sat, 2 Feb 2013 08:45:52 +0100 Subject: [PATCH] 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 --- summate.c | 3 +++ tests/iscc/sum5 | 2 ++ 2 files changed, 5 insertions(+) create mode 100644 tests/iscc/sum5 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 }); -- 2.11.4.GIT