]> www.ginac.de Git - ginac.git/blobdiff - ginac/pseries.cpp
Synced to HEAD
[ginac.git] / ginac / pseries.cpp
index eaef6388aa1d5143ec9787af3315309272f26bfc..993eacf119f7583903747f2a92577f59fa508841 100644 (file)
@@ -798,8 +798,7 @@ ex mul::series(const relational & r, int order, unsigned options) const
                int real_ldegree = 0;
                try {
                        real_ldegree = buf.expand().ldegree(sym-r.rhs());
-               }
-               catch (std::runtime_error) {}
+               } catch (std::runtime_error) {}
 
                if (real_ldegree == 0) {
                        int orderloop = 0;
@@ -814,7 +813,7 @@ ex mul::series(const relational & r, int order, unsigned options) const
 
        int degsum = std::accumulate(ldegrees.begin(), ldegrees.end(), 0);
 
-       if (degsum>order) {
+       if (degsum >= order) {
                epvector epv;
                epv.push_back(expair(Order(_ex1), order));
                return (new pseries(r, epv))->setflag(status_flags::dynallocated);
@@ -828,7 +827,7 @@ ex mul::series(const relational & r, int order, unsigned options) const
                ex op = recombine_pair_to_ex(*it).series(r, order-degsum+(*itd), options);
 
                // Series multiplication
-               if (it==itbeg)
+               if (it == itbeg)
                        acc = ex_to<pseries>(op);
                else
                        acc = ex_to<pseries>(acc.mul_series(ex_to<pseries>(op)));
@@ -972,7 +971,12 @@ ex power::series(const relational & r, int order, unsigned options) const
 
        // No, expand basis into series
 
-       numeric numexp = ex_to<numeric>(exponent);
+       numeric numexp;
+       if (is_a<numeric>(exponent)) {
+               numexp = ex_to<numeric>(exponent);
+       } else {
+               numexp = 0;
+       }
        const ex& sym = r.lhs();
        // find existing minimal degree
        int real_ldegree = basis.expand().ldegree(sym-r.rhs());