From ff18d7f21003a092361ab3428eb89b1414905e12 Mon Sep 17 00:00:00 2001 From: Sven Verdoolaege Date: Wed, 10 Oct 2007 16:56:05 +0200 Subject: [PATCH] icounter: don't bother "normalizing" the exponents in the denominator We used to make sure these exponents are positive, but there is no need to do that on full specialization. See also d566b49a2da75b61fb9a310dcdc1cbe41a7e1cad. --- dpoly.cc | 6 ++++++ reducer.cc | 24 ++---------------------- reducer.h | 2 -- 3 files changed, 8 insertions(+), 24 deletions(-) diff --git a/dpoly.cc b/dpoly.cc index 1249cee..22150dd 100644 --- a/dpoly.cc +++ b/dpoly.cc @@ -67,6 +67,12 @@ Vector *dpoly::div(const dpoly& d) Vector *denom = Vector_Alloc(len); Value tmp; value_init(tmp); + + /* Make sure denominators are positive */ + if (value_neg_p(d.coeff->p[0])) { + Vector_Oppose(d.coeff->p, d.coeff->p, d.coeff->Size); + Vector_Oppose(coeff->p, coeff->p, coeff->Size); + } value_assign(denom->p[0], d.coeff->p[0]); for (int i = 1; i < len; ++i) { value_multiply(denom->p[i], denom->p[i-1], denom->p[0]); diff --git a/reducer.cc b/reducer.cc index 51b0a31..7d8071a 100644 --- a/reducer.cc +++ b/reducer.cc @@ -423,24 +423,6 @@ void split_one(const mat_ZZ& num, vec_ZZ& num_s, mat_ZZ& num_p, } } -void normalize(ZZ& sign, ZZ& num, vec_ZZ& den) -{ - unsigned dim = den.length(); - - int change = 0; - - for (int j = 0; j < den.length(); ++j) { - if (den[j] > 0) - change ^= 1; - else { - den[j] = abs(den[j]); - num += den[j]; - } - } - if (change) - sign = -sign; -} - void icounter::base(const QQ& c, const vec_ZZ& num, const mat_ZZ& den_f) { int r; @@ -451,8 +433,7 @@ void icounter::base(const QQ& c, const vec_ZZ& num, const mat_ZZ& den_f) ZZ num_s = num[0]; for (r = 0; r < len; ++r) den_s[r] = den_f[r][0]; - ZZ sign = ZZ(INIT_VAL, 1); - normalize(sign, num_s, den_s); + int sign = (len % 2) ? -1 : 1; zz2value(num_s, tz); dpoly n(len, tz); @@ -486,8 +467,7 @@ void infinite_icounter::base(const QQ& c, const vec_ZZ& num, const mat_ZZ& den_f for (r = 0; r < len; ++r) den_s[r] = den_f[r][0]; - ZZ sign = ZZ(INIT_VAL, 1); - normalize(sign, num_s, den_s); + int sign = (len % 2) ? -1 : 1; zz2value(num_s, tz); dpoly n(len, tz); diff --git a/reducer.h b/reducer.h index ad70273..9e01bce 100644 --- a/reducer.h +++ b/reducer.h @@ -127,8 +127,6 @@ struct icounter : public ireducer { } }; -void normalize(ZZ& sign, ZZ& num, vec_ZZ& den); - /* An incremental counter for possibly infinite sets. * Rather than just keeping track of the constant term * of the Laurent expansions, we also keep track of the -- 2.11.4.GIT