X-Git-Url: https://www.ginac.de/ginac.git//ginac.git?p=ginac.git;a=blobdiff_plain;f=ginac%2Fexpairseq.cpp;h=bff206f9b42c5f2c4329f704d2a4400da010658c;hp=8e9594b6e312b640775ad59fd8d0cb8e66b8592a;hb=36ffb97c48fbbd3acb2b1aa305872e00a4456dc4;hpb=f8cd4812fd1a238d85c183ac7c01a2ee9e7fd00b diff --git a/ginac/expairseq.cpp b/ginac/expairseq.cpp index 8e9594b6..bff206f9 100644 --- a/ginac/expairseq.cpp +++ b/ginac/expairseq.cpp @@ -285,7 +285,7 @@ ex expairseq::op(size_t i) const ex expairseq::map(map_function &f) const { std::auto_ptr v(new epvector); - v->reserve(seq.size()); + v->reserve(seq.size()+1); epvector::const_iterator cit = seq.begin(), last = seq.end(); while (cit != last) { @@ -295,8 +295,15 @@ ex expairseq::map(map_function &f) const if (overall_coeff.is_equal(default_overall_coeff())) return thisexpairseq(v, default_overall_coeff(), true); - else - return thisexpairseq(v, f(overall_coeff), true); + else { + ex newcoeff = f(overall_coeff); + if(is_a(newcoeff)) + return thisexpairseq(v, newcoeff, true); + else { + v->push_back(split_ex_to_pair(newcoeff)); + return thisexpairseq(v, default_overall_coeff(), true); + } + } } /** Perform coefficient-wise automatic term rewriting rules in this class. */