From 7c9b2a1c4c6d9ad8652edf4a5a54227c40003286 Mon Sep 17 00:00:00 2001 From: Sven Verdoolaege Date: Thu, 1 May 2008 13:46:13 +0200 Subject: [PATCH] evalue.c: evalue_shift_variables: allow shifting of only parameters --- barvinok/evalue.h | 2 +- bernoulli.c | 2 +- evalue.c | 12 +++++++----- laurent.cc | 2 +- summate.c | 2 +- 5 files changed, 11 insertions(+), 9 deletions(-) diff --git a/barvinok/evalue.h b/barvinok/evalue.h index ac385e4..73765c4 100644 --- a/barvinok/evalue.h +++ b/barvinok/evalue.h @@ -129,7 +129,7 @@ evalue *affine2evalue(Value *coeff, Value denom, int nvar); void evalue_substitute(evalue *e, evalue **subs); void evalue_backsubstitute(evalue *e, Matrix *CP, unsigned MaxRays); evalue *evalue_polynomial(Vector *c, const evalue* X); -void evalue_shift_variables(evalue *e, int n); +void evalue_shift_variables(evalue *e, int first, int n); struct evalue_section { Polyhedron *D; diff --git a/bernoulli.c b/bernoulli.c index c47c40a..77d3128 100644 --- a/bernoulli.c +++ b/bernoulli.c @@ -158,7 +158,7 @@ static evalue *shifted_copy(const evalue *src) evalue *e = ALLOC(evalue); value_init(e->d); evalue_copy(e, src); - evalue_shift_variables(e, -1); + evalue_shift_variables(e, 0, -1); return e; } diff --git a/evalue.c b/evalue.c index 36a125d..a2da890 100644 --- a/evalue.c +++ b/evalue.c @@ -4398,17 +4398,19 @@ evalue *evalue_from_section_array(struct evalue_section *s, int n) return res; } -/* shift variables in polynomial n up */ -void evalue_shift_variables(evalue *e, int n) +/* shift variables (>= first, 0-based) in polynomial n up (may be negative) */ +void evalue_shift_variables(evalue *e, int first, int n) { int i; if (value_notzero_p(e->d)) return; - assert(e->x.p->type == polynomial || e->x.p->type == fractional); - if (e->x.p->type == polynomial) { + assert(e->x.p->type == polynomial || + e->x.p->type == flooring || + e->x.p->type == fractional); + if (e->x.p->type == polynomial && e->x.p->pos >= first+1) { assert(e->x.p->pos + n >= 1); e->x.p->pos += n; } for (i = 0; i < e->x.p->size; ++i) - evalue_shift_variables(&e->x.p->arr[i], n); + evalue_shift_variables(&e->x.p->arr[i], first, n); } diff --git a/laurent.cc b/laurent.cc index 70b382a..9fa7e40 100644 --- a/laurent.cc +++ b/laurent.cc @@ -742,7 +742,7 @@ void laurent_summator::handle(const signed_cone& sc, barvinok_options *options) evalue_negate(f); for (int j = 0; j < dim; ++j) evalue_mul(f, *factorial(terms[i].powers[j])); - evalue_shift_variables(f, -dim); + evalue_shift_variables(f, 0, -dim); emul(c, f); emul(t, f); if (!result) diff --git a/summate.c b/summate.c index 13746b9..f52822b 100644 --- a/summate.c +++ b/summate.c @@ -50,7 +50,7 @@ static evalue *sum_over_polytope_with_equalities(Polyhedron *P, evalue *E, new_nparam); else subs[nvar+j] = evalue_var(j); - evalue_shift_variables(subs[nvar+j], new_dim-new_nparam); + evalue_shift_variables(subs[nvar+j], 0, new_dim-new_nparam); } E = evalue_dup(E); -- 2.11.4.GIT