From 36ffb97c48fbbd3acb2b1aa305872e00a4456dc4 Mon Sep 17 00:00:00 2001 From: Chris Dams Date: Thu, 10 Aug 2006 11:35:03 +0000 Subject: [PATCH] Fixed bug submitted by Warren Weckesser. --- ginac/expairseq.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) 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. */ -- 2.46.2