]> www.ginac.de Git - ginac.git/blobdiff - ginac/pseries.cpp
fixed another power::series() bug [Alexei Sheplyakov]
[ginac.git] / ginac / pseries.cpp
index 443969c1d766176d6a330cd60c481332f84bfd9a..4ec5bcefca4e1f559a7b326f9b9c400fc5f55f4f 100644 (file)
@@ -952,11 +952,13 @@ ex power::series(const relational & r, int order, unsigned options) const
        }
 
        // Is the expression of type something^(-int)?
-       if (!must_expand_basis && !exponent.info(info_flags::negint) && !is_a<add>(basis))
+       if (!must_expand_basis && !exponent.info(info_flags::negint)
+        && (!is_a<add>(basis) || !is_a<numeric>(exponent)))
                return basic::series(r, order, options);
 
        // Is the expression of type 0^something?
-       if (!must_expand_basis && !basis.subs(r, subs_options::no_pattern).is_zero() && !is_a<add>(basis))
+       if (!must_expand_basis && !basis.subs(r, subs_options::no_pattern).is_zero()
+        && (!is_a<add>(basis) || !is_a<numeric>(exponent)))
                return basic::series(r, order, options);
 
        // Singularity encountered, is the basis equal to (var - point)?
@@ -971,7 +973,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());