From 2170577246bf46ae2b11f3bf058581191f466ea9 Mon Sep 17 00:00:00 2001 From: skimo Date: Thu, 30 Sep 2004 12:12:39 +0000 Subject: [PATCH] use provided parameter names --- barvinok_series.cc | 2 +- genfun.cc | 16 +++++++++++----- genfun.h | 2 +- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/barvinok_series.cc b/barvinok_series.cc index 6d3b48d..df715df 100644 --- a/barvinok_series.cc +++ b/barvinok_series.cc @@ -42,7 +42,7 @@ int main(int argc, char **argv) Polyhedron_Print(stdout, P_VALUE_FMT, C); param_name = Read_ParamNames(stdin, C->Dimension); gf = barvinok_series(A, C, MAXRAYS); - gf->print(); + gf->print(C->Dimension, param_name); Free_ParamNames(param_name, C->Dimension); Polyhedron_Free(A); Polyhedron_Free(C); diff --git a/genfun.cc b/genfun.cc index 265c139..4df57e3 100644 --- a/genfun.cc +++ b/genfun.cc @@ -69,7 +69,8 @@ void gen_fun::add(ZZ& cn, ZZ& cd, vec_ZZ& num, mat_ZZ& den) term.push_back(r); } -static void print_power(vec_ZZ& c, vec_ZZ& p) +static void print_power(vec_ZZ& c, vec_ZZ& p, + unsigned int nparam, char **param_name) { bool first = true; @@ -88,7 +89,10 @@ static void print_power(vec_ZZ& c, vec_ZZ& p) first = false; } else cout << " * "; - cout << "x" << i; + if (i < nparam) + cout << param_name[i]; + else + cout << "x" << i; if (p[i] == 1) continue; if (p[i] < 0) @@ -103,7 +107,7 @@ static void print_power(vec_ZZ& c, vec_ZZ& p) } } -void gen_fun::print(void) +void gen_fun::print(unsigned int nparam, char **param_name) { vec_ZZ mone; mone.SetLength(1); @@ -116,14 +120,16 @@ void gen_fun::print(void) for (int j = 0; j < term[i]->n.coeff.NumRows(); ++j) { if (j != 0 && term[i]->n.coeff[j][0] > 0) cout << "+"; - print_power(term[i]->n.coeff[j], term[i]->n.power[j]); + print_power(term[i]->n.coeff[j], term[i]->n.power[j], + nparam, param_name); } cout << ")/("; for (int j = 0; j < term[i]->d.power.NumRows(); ++j) { if (j != 0) cout << " * "; cout << "(1"; - print_power(mone, term[i]->d.power[j]); + print_power(mone, term[i]->d.power[j], + nparam, param_name); cout << ")"; } cout << ")"; diff --git a/genfun.h b/genfun.h index ead4f76..3c913c0 100644 --- a/genfun.h +++ b/genfun.h @@ -26,7 +26,7 @@ struct gen_fun { std::vector< short_rat * > term; void add(ZZ& cn, ZZ& cd, vec_ZZ& num, mat_ZZ& den); - void print(void); + void print(unsigned int nparam, char **param_name); }; #endif -- 2.11.4.GIT