From 7931172c6f308f1969edbb1166607026cad23337 Mon Sep 17 00:00:00 2001 From: Sven Verdoolaege Date: Fri, 3 Nov 2006 18:56:03 +0100 Subject: [PATCH] gen_fun::coefficient: new version returning ZZ --- barvinok/genfun.h | 1 + genfun.cc | 21 +++++++++++++-------- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/barvinok/genfun.h b/barvinok/genfun.h index f38260c..948bb90 100644 --- a/barvinok/genfun.h +++ b/barvinok/genfun.h @@ -52,6 +52,7 @@ struct gen_fun { void divide(const vec_ZZ& power); void print(std::ostream& os, unsigned int nparam, char **param_name) const; operator evalue *() const; + ZZ coefficient(Value* params, barvinok_options *options) const; void coefficient(Value* params, Value* c) const; gen_fun *summate(int nvar, barvinok_options *options) const; bool summate(Value *sum) const; diff --git a/genfun.cc b/genfun.cc index b4966d0..17fc872 100644 --- a/genfun.cc +++ b/genfun.cc @@ -759,14 +759,10 @@ gen_fun::operator evalue *() const return EP; } -void gen_fun::coefficient(Value* params, Value* c) const +ZZ gen_fun::coefficient(Value* params, barvinok_options *options) const { - if (context && !in_domain(context, params)) { - value_set_si(*c, 0); - return; - } - - barvinok_options *options = barvinok_options_new_with_defaults(); + if (context && !in_domain(context, params)) + return ZZ::zero(); QQ sum(0, 1); @@ -774,7 +770,16 @@ void gen_fun::coefficient(Value* params, Value* c) const sum += (*i)->coefficient(params, options); assert(sum.d == 1); - zz2value(sum.n, *c); + return sum.n; +} + +void gen_fun::coefficient(Value* params, Value* c) const +{ + barvinok_options *options = barvinok_options_new_with_defaults(); + + ZZ coeff = coefficient(params, options); + + zz2value(coeff, *c); free(options); } -- 2.11.4.GIT