From: Christian Bauer Date: Thu, 24 Oct 2002 20:37:52 +0000 (+0000) Subject: under certain conditions, power::expand_add_2() could produce non-canonical X-Git-Tag: release_1-0-12~9 X-Git-Url: https://www.ginac.de/ginac.git//ginac.git?p=ginac.git;a=commitdiff_plain;h=e14a5df66cc2b30e31e58418079704f4dcd52616;ds=sidebyside under certain conditions, power::expand_add_2() could produce non-canonical numeric expairs (see exam_paranoia15()) --- diff --git a/ginac/add.cpp b/ginac/add.cpp index d9da9fba..1c995aa7 100644 --- a/ginac/add.cpp +++ b/ginac/add.cpp @@ -524,7 +524,7 @@ ex add::expand(unsigned options) const // the terms have not changed, so it is safe to declare this expanded return (options == 0) ? setflag(status_flags::expanded) : *this; } - + return (new add(vp, overall_coeff))->setflag(status_flags::dynallocated | (options == 0 ? status_flags::expanded : 0)); } diff --git a/ginac/power.cpp b/ginac/power.cpp index be7c2d37..85e5bd6c 100644 --- a/ginac/power.cpp +++ b/ginac/power.cpp @@ -764,10 +764,10 @@ ex power::expand_add_2(const add & a) const } } else { if (is_ex_exactly_of_type(r,mul)) { - sum.push_back(expair(expand_mul(ex_to(r),_num2), + sum.push_back(a.combine_ex_with_coeff_to_pair(expand_mul(ex_to(r),_num2), ex_to(c).power_dyn(_num2))); } else { - sum.push_back(expair((new power(r,_ex2))->setflag(status_flags::dynallocated), + sum.push_back(a.combine_ex_with_coeff_to_pair((new power(r,_ex2))->setflag(status_flags::dynallocated), ex_to(c).power_dyn(_num2))); } } @@ -811,16 +811,16 @@ ex power::expand_mul(const mul & m, const numeric & n) const epvector::const_iterator last = m.seq.end(); epvector::const_iterator cit = m.seq.begin(); while (cit!=last) { - if (is_ex_exactly_of_type((*cit).rest,numeric)) { - distrseq.push_back(m.combine_pair_with_coeff_to_pair(*cit,n)); + if (is_ex_exactly_of_type(cit->rest,numeric)) { + distrseq.push_back(m.combine_pair_with_coeff_to_pair(*cit, n)); } else { // it is safe not to call mul::combine_pair_with_coeff_to_pair() // since n is an integer - distrseq.push_back(expair((*cit).rest, ex_to((*cit).coeff).mul(n))); + distrseq.push_back(expair(cit->rest, ex_to(cit->coeff).mul(n))); } ++cit; } - return (new mul(distrseq,ex_to(m.overall_coeff).power_dyn(n)))->setflag(status_flags::dynallocated); + return (new mul(distrseq, ex_to(m.overall_coeff).power_dyn(n)))->setflag(status_flags::dynallocated); } } // namespace GiNaC