Fixed bug submitted by Warren Weckesser.
authorChris Dams <Chris.Dams@mi.infn.it>
Thu, 10 Aug 2006 11:35:03 +0000 (11:35 +0000)
committerChris Dams <Chris.Dams@mi.infn.it>
Thu, 10 Aug 2006 11:35:03 +0000 (11:35 +0000)
ginac/expairseq.cpp

index 8e9594b6e312b640775ad59fd8d0cb8e66b8592a..bff206f9b42c5f2c4329f704d2a4400da010658c 100644 (file)
@@ -285,7 +285,7 @@ ex expairseq::op(size_t i) const
 ex expairseq::map(map_function &f) const
 {
        std::auto_ptr<epvector> 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<numeric>(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. */