barvinok_sum_over_polytope: special case 0D polytopes
authorSven Verdoolaege <skimo@kotnet.org>
Sat, 2 Feb 2013 07:45:52 +0000 (2 08:45 +0100)
committerSven Verdoolaege <skimo@kotnet.org>
Sat, 2 Feb 2013 12:25:01 +0000 (2 13:25 +0100)
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 <tomofumi.yuki@gmail.com>
Signed-off-by: Sven Verdoolaege <skimo@kotnet.org>
summate.c
tests/iscc/sum5 [new file with mode: 0644]

index abbf22b..7b5ae2e 100644 (file)
--- 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 (file)
index 0000000..8c475fc
--- /dev/null
@@ -0,0 +1,2 @@
+r := sum { [] -> 1 };
+assert(r == { 1 });