From 42fa5519133f7121be2fbde36cc643934474fcb7 Mon Sep 17 00:00:00 2001 From: Christian Bauer Date: Tue, 8 Feb 2000 18:18:39 +0000 Subject: [PATCH] - series expansion of pseries objects should now work as expected --- ginac/pseries.cpp | 25 +++++++++++++++++++++++++ ginac/pseries.h | 1 + 2 files changed, 26 insertions(+) diff --git a/ginac/pseries.cpp b/ginac/pseries.cpp index 7fbf7311..9b6f64a9 100644 --- a/ginac/pseries.cpp +++ b/ginac/pseries.cpp @@ -689,6 +689,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 diff --git a/ginac/pseries.h b/ginac/pseries.h index 046c838e..ff575bbe 100644 --- a/ginac/pseries.h +++ b/ginac/pseries.h @@ -65,6 +65,7 @@ public: ex coeff(const symbol &s, int n=1) const; ex eval(int level=0) const; ex evalf(int level=0) const; + ex series(const symbol & s, const ex & p, int order) const; ex normal(lst &sym_lst, lst &repl_lst, int level=0) const; ex subs(const lst & ls, const lst & lr) const; protected: -- 2.44.0