From 4cbc8e8bdf06fd91ec652e9645965a5f1a808d76 Mon Sep 17 00:00:00 2001 From: Alexei Sheplyakov Date: Fri, 12 Sep 2008 19:55:36 +0400 Subject: [PATCH 1/1] [nitpick] power::expand_add(): don't use int instead of std::size_t. This shuts a few 'comparison between signed and unsigned integer expressions' warnings. --- ginac/power.cpp | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/ginac/power.cpp b/ginac/power.cpp index e4a044cb..a4a33c57 100644 --- a/ginac/power.cpp +++ b/ginac/power.cpp @@ -868,7 +868,6 @@ ex power::expand_add(const add & a, int n, unsigned options) const intvector k(m-1); intvector k_cum(m-1); // k_cum[l]:=sum(i=0,l,k[l]); intvector upper_limit(m-1); - int l; for (size_t l=0; l(b)); GINAC_ASSERT(!is_exactly_a(b) || @@ -894,7 +893,7 @@ ex power::expand_add(const add & a, int n, unsigned options) const term.push_back(power(b,k[l])); } - const ex & b = a.op(l); + const ex & b = a.op(m - 1); GINAC_ASSERT(!is_exactly_a(b)); GINAC_ASSERT(!is_exactly_a(b) || !is_exactly_a(ex_to(b).exponent) || @@ -908,7 +907,7 @@ ex power::expand_add(const add & a, int n, unsigned options) const term.push_back(power(b,n-k_cum[m-2])); numeric f = binomial(numeric(n),numeric(k[0])); - for (l=1; lsetflag(status_flags::dynallocated)).expand(options)); // increment k[] - l = m-2; - while ((l>=0) && ((++k[l])>upper_limit[l])) { + bool done = false; + std::size_t l = m - 2; + while ((++k[l]) > upper_limit[l]) { k[l] = 0; - --l; + if (l != 0) + --l; + else { + done = true; + break; + } } - if (l<0) break; + if (done) + break; // recalc k_cum[] and upper_limit[] k_cum[l] = (l==0 ? k[0] : k_cum[l-1]+k[l]); -- 2.44.0