Fixed bug in series expansion
authorJens Vollinga <vollinga@thep.physik.uni-mainz.de>
Sat, 27 Mar 2004 14:29:52 +0000 (14:29 +0000)
committerJens Vollinga <vollinga@thep.physik.uni-mainz.de>
Sat, 27 Mar 2004 14:29:52 +0000 (14:29 +0000)
ginac/pseries.cpp

index d799e62b132a576b23430298a2237b09b0b5eef7..1efbb65d98640db836b2ca5d5a40969d5370e8c4 100644 (file)
@@ -784,10 +784,15 @@ ex mul::series(const relational & r, int order, unsigned options) const
        const epvector::const_iterator itbeg = seq.begin();
        const epvector::const_iterator itend = seq.end();
        for (epvector::const_iterator it=itbeg; it!=itend; ++it) {
-               
+
                ex buf = recombine_pair_to_ex(*it);
-               
-               int real_ldegree = buf.expand().ldegree(sym-r.rhs());
+
+               int real_ldegree = 0;
+               try {
+                       real_ldegree = buf.expand().ldegree(sym-r.rhs());
+               }
+               catch (std::runtime_error) {}
+
                if (real_ldegree == 0) {
                        int orderloop = 0;
                        do {
@@ -800,7 +805,13 @@ ex mul::series(const relational & r, int order, unsigned options) const
        }
 
        int degsum = std::accumulate(ldegrees.begin(), ldegrees.end(), 0);
-               
+
+       if (degsum>order) {
+               epvector epv;
+               epv.push_back(expair(Order(_ex1), order));
+               return (new pseries(r, epv))->setflag(status_flags::dynallocated);
+       }
+
        // Multiply with remaining terms
        std::vector<int>::const_iterator itd = ldegrees.begin();
        for (epvector::const_iterator it=itbeg; it!=itend; ++it, ++itd) {