From d77d2fae89262d58b9300f01e4a60725948b5014 Mon Sep 17 00:00:00 2001 From: Sven Verdoolaege Date: Thu, 7 May 2009 11:09:01 +0200 Subject: [PATCH] Line_Length: handle 0D polytope in 1D space Line_Length is usually only called on full-dimensional polytopes since equalities are removed in the very beginning. However, it may happen that the original polytope is a product of polytopes and that an equality among the integer points in the polytope is only discovered after the factorization. We could choose to check for equalities again (as we do for polytopes living in non-1D space), but we can just as easily handle the equality inside Line_Length. --- tests/product5 | 10 ++++++++++ util.c | 8 ++++++++ 2 files changed, 18 insertions(+) create mode 100644 tests/product5 diff --git a/tests/product5 b/tests/product5 new file mode 100644 index 0000000..a45ebf1 --- /dev/null +++ b/tests/product5 @@ -0,0 +1,10 @@ +D 1 +6 6 + 0 1 1 0 0 -1 + 0 0 0 2 1 -1 + 1 0 1 0 0 0 + 1 0 -1 0 0 1 + 1 0 0 0 1 0 + 1 0 0 0 -1 1 +F 0 +2 diff --git a/util.c b/util.c index 8eb5b24..05391c9 100644 --- a/util.c +++ b/util.c @@ -629,6 +629,14 @@ void Line_Length(Polyhedron *P, Value *len) assert(P->Dimension == 1); + if (P->NbEq > 0) { + if (mpz_divisible_p(P->Constraint[0][2], P->Constraint[0][1])) + value_set_si(*len, 1); + else + value_set_si(*len, 0); + return; + } + value_init(tmp); value_init(pos); value_init(neg); -- 2.11.4.GIT