]> www.ginac.de Git - ginac.git/commitdiff
Created pseries::evalm. Patch by Alexei.
authorChris Dams <Chris.Dams@mi.infn.it>
Tue, 13 Feb 2007 14:44:39 +0000 (14:44 +0000)
committerChris Dams <Chris.Dams@mi.infn.it>
Tue, 13 Feb 2007 14:44:39 +0000 (14:44 +0000)
ginac/pseries.cpp
ginac/pseries.h

index db7cef30d8bfe44234658770726822c578271385..0e1f183322c47114404c1c4c7b502f6cc44d68f4 100644 (file)
@@ -489,6 +489,34 @@ ex pseries::eval_integ() const
        return *this;
 }
 
+ex pseries::evalm() const
+{
+       // evalm each coefficient
+       epvector newseq;
+       bool something_changed = false;
+       for (epvector::const_iterator i=seq.begin(); i!=seq.end(); ++i) {
+               if (something_changed) {
+                       ex newcoeff = i->rest.evalm();
+                       if (!newcoeff.is_zero())
+                               newseq.push_back(expair(newcoeff, i->coeff));
+               }
+               else {
+                       ex newcoeff = i->rest.evalm();
+                       if (!are_ex_trivially_equal(newcoeff, i->rest)) {
+                               something_changed = true;
+                               newseq.reserve(seq.size());
+                               std::copy(seq.begin(), i, std::back_inserter<epvector>(newseq));
+                               if (!newcoeff.is_zero())
+                                       newseq.push_back(expair(newcoeff, i->coeff));
+                       }
+               }
+       }
+       if (something_changed)
+               return (new pseries(var==point, newseq))->setflag(status_flags::dynallocated);
+       else
+               return *this;
+}
+
 ex pseries::subs(const exmap & m, unsigned options) const
 {
        // If expansion variable is being substituted, convert the series to a
index ed266c498072ffe36e6fe684f7689302ebde23dd..e53baf6e28e682bb79428e639b00907a567dc04a 100644 (file)
@@ -59,6 +59,7 @@ public:
        ex real_part() const;
        ex imag_part() const;
        ex eval_integ() const;
+       ex evalm() const;
 protected:
        ex derivative(const symbol & s) const;