* 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
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) {
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. */