X-Git-Url: https://www.ginac.de/ginac.git//ginac.git?p=ginac.git;a=blobdiff_plain;f=ginac%2Fpseries.cpp;h=4491915841b1cd746d32cde71c8effc395257d4c;hp=7fbf73113a74f293c3cca3b151083ff29dfa2bb9;hb=21ebb806befcb3873d58074454fcf8dcba138fa9;hpb=97af29c12bb3074cfb4e674d71000f0712c51ba2;ds=inline diff --git a/ginac/pseries.cpp b/ginac/pseries.cpp index 7fbf7311..44919158 100644 --- a/ginac/pseries.cpp +++ b/ginac/pseries.cpp @@ -256,6 +256,14 @@ ex pseries::coeff(const symbol &s, int n) const return convert_to_poly().coeff(s, n); } +ex pseries::collect(const symbol &s) const +{ + if (var.is_equal(s)) + return convert_to_poly(); + else + return inherited::collect(s); +} + ex pseries::eval(int level) const { if (level == 1) @@ -689,6 +697,31 @@ ex power::series(const symbol & s, const ex & point, int order) const } +/** Re-expansion of a pseries object. */ +ex pseries::series(const symbol & s, const ex & p, int order) const +{ + if (var.is_equal(s) && point.is_equal(p)) { + if (order > degree(s)) + return *this; + else { + epvector new_seq; + epvector::const_iterator it = seq.begin(), itend = seq.end(); + while (it != itend) { + int o = ex_to_numeric(it->coeff).to_int(); + if (o >= order) { + new_seq.push_back(expair(Order(_ex1()), o)); + break; + } + new_seq.push_back(*it); + it++; + } + return pseries(var, point, new_seq); + } + } else + return convert_to_poly().series(s, p, order); +} + + /** Compute the truncated series expansion of an expression. * This function returns an expression containing an object of class pseries to * represent the series. If the series does not terminate within the given