]> www.ginac.de Git - ginac.git/commitdiff
under certain conditions, power::expand_add_2() could produce non-canonical
authorChristian Bauer <Christian.Bauer@uni-mainz.de>
Thu, 24 Oct 2002 20:37:52 +0000 (20:37 +0000)
committerChristian Bauer <Christian.Bauer@uni-mainz.de>
Thu, 24 Oct 2002 20:37:52 +0000 (20:37 +0000)
numeric expairs (see exam_paranoia15())

ginac/add.cpp
ginac/power.cpp

index d9da9fba87ca556e167af92ee9858ffe812c54d0..1c995aa7f74d9f36f0b98bba4d9173789aa6b1d8 100644 (file)
@@ -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;
        }
                // 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));
 }
 
        return (new add(vp, overall_coeff))->setflag(status_flags::dynallocated | (options == 0 ? status_flags::expanded : 0));
 }
 
index be7c2d371f61a12f1ec72697bd21f7d0ff41fa3b..85e5bd6c9a92e76c470dc83c527a4d6eaa85a0d0 100644 (file)
@@ -764,10 +764,10 @@ ex power::expand_add_2(const add & a) const
                        }
                } else {
                        if (is_ex_exactly_of_type(r,mul)) {
                        }
                } else {
                        if (is_ex_exactly_of_type(r,mul)) {
-                               sum.push_back(expair(expand_mul(ex_to<mul>(r),_num2),
+                               sum.push_back(a.combine_ex_with_coeff_to_pair(expand_mul(ex_to<mul>(r),_num2),
                                                     ex_to<numeric>(c).power_dyn(_num2)));
                        } else {
                                                     ex_to<numeric>(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<numeric>(c).power_dyn(_num2)));
                        }
                }
                                                     ex_to<numeric>(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) {
        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
                } 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<numeric>((*cit).coeff).mul(n)));
+                       distrseq.push_back(expair(cit->rest, ex_to<numeric>(cit->coeff).mul(n)));
                }
                ++cit;
        }
                }
                ++cit;
        }
-       return (new mul(distrseq,ex_to<numeric>(m.overall_coeff).power_dyn(n)))->setflag(status_flags::dynallocated);
+       return (new mul(distrseq, ex_to<numeric>(m.overall_coeff).power_dyn(n)))->setflag(status_flags::dynallocated);
 }
 
 } // namespace GiNaC
 }
 
 } // namespace GiNaC