From 759d8ce224a89482c9b9785d1b86ba52f5b9cb4d Mon Sep 17 00:00:00 2001 From: Sven Verdoolaege Date: Wed, 26 Mar 2008 22:24:44 +0100 Subject: [PATCH] Bernoulli_sum: handle context constraints --- bernoulli.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/bernoulli.c b/bernoulli.c index af6e8b2..fd5948b 100644 --- a/bernoulli.c +++ b/bernoulli.c @@ -601,12 +601,25 @@ evalue *Bernoulli_sum_evalue(evalue *e, unsigned nvar, evalue *Bernoulli_sum(Polyhedron *P, Polyhedron *C, struct barvinok_options *options) { + Polyhedron *CA, *D; evalue e; evalue *sum; + if (emptyQ(P) || emptyQ(C)) + return evalue_zero(); + + CA = align_context(C, P->Dimension, options->MaxRays); + D = DomainIntersection(P, CA, options->MaxRays); + Domain_Free(CA); + + if (emptyQ(D)) { + Domain_Free(D); + return evalue_zero(); + } + value_init(e.d); e.x.p = new_enode(partition, 2, P->Dimension); - EVALUE_SET_DOMAIN(e.x.p->arr[0], Polyhedron_Copy(P)); + EVALUE_SET_DOMAIN(e.x.p->arr[0], D); evalue_set_si(&e.x.p->arr[1], 1, 1); sum = Bernoulli_sum_evalue(&e, P->Dimension - C->Dimension, options); free_evalue_refs(&e); -- 2.11.4.GIT