]> www.ginac.de Git - ginac.git/blobdiff - ginac/expairseq.cpp
Make pseries also work for non-rational functions. Patch by Alexei.
[ginac.git] / ginac / expairseq.cpp
index 549d1f845779e173f7466387cb038aa90937d9b6..f7a54bc04f11a217746dcb2b815a35cb2aef02d1 100644 (file)
@@ -3,7 +3,7 @@
  *  Implementation of sequences of expression pairs. */
 
 /*
- *  GiNaC Copyright (C) 1999-2005 Johannes Gutenberg University Mainz, Germany
+ *  GiNaC Copyright (C) 1999-2007 Johannes Gutenberg University Mainz, Germany
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -283,7 +283,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) {
@@ -293,8 +293,15 @@ ex expairseq::map(map_function &f) const
 
        if (overall_coeff.is_equal(default_overall_coeff()))
                return thisexpairseq(v, default_overall_coeff());
-       else
-               return thisexpairseq(v, f(overall_coeff));
+       else {
+      ex newcoeff = f(overall_coeff);
+      if(is_a<numeric>(newcoeff))
+         return thisexpairseq(v, newcoeff);
+      else {
+         v->push_back(split_ex_to_pair(newcoeff));
+         return thisexpairseq(v, default_overall_coeff());
+      }
+   }
 }
 
 /** Perform coefficient-wise automatic term rewriting rules in this class. */