From: Alexei Sheplyakov Date: Mon, 26 Feb 2007 14:08:48 +0000 (+0300) Subject: Improve mul::degree so that degree(c*x^(-1), x^(-1)) gives correct result X-Git-Url: https://www.ginac.de/ginac.git//ginac.git?a=commitdiff_plain;h=6d9c698cd0d56178bb28f7c6ae92b2e516ce26c1;p=ginac.git Improve mul::degree so that degree(c*x^(-1), x^(-1)) gives correct result In ginsh: degree(x^(-1), x^(-1)); 1 degree(c*x^(-1), x^(-1)); 0 Now degree (and ldegree) should work correct with such arguments. Note: degree() is still inconsistent, i.e. degree(c*x^(-2), x^(-1)); 0 --- diff --git a/ginac/mul.cpp b/ginac/mul.cpp index ab1a042b..e1d5e02e 100644 --- a/ginac/mul.cpp +++ b/ginac/mul.cpp @@ -317,7 +317,7 @@ int mul::degree(const ex & s) const epvector::const_iterator i = seq.begin(), end = seq.end(); while (i != end) { if (ex_to(i->coeff).is_integer()) - deg_sum += i->rest.degree(s) * ex_to(i->coeff).to_int(); + deg_sum += recombine_pair_to_ex(*i).degree(s); ++i; } return deg_sum; @@ -330,7 +330,7 @@ int mul::ldegree(const ex & s) const epvector::const_iterator i = seq.begin(), end = seq.end(); while (i != end) { if (ex_to(i->coeff).is_integer()) - deg_sum += i->rest.ldegree(s) * ex_to(i->coeff).to_int(); + deg_sum += recombine_pair_to_ex(*i).ldegree(s); ++i; } return deg_sum;