summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Krenn <git@danielkrenn.at>2016-01-31 13:33:23 +0100
committerDaniel Krenn <git@danielkrenn.at>2016-01-31 13:33:23 +0100
commit34845ffb2e92ab2e9060566d665a6809b73f1283 (patch)
treebb1b7f9914fb07a114c024b9291f1b532276bcc6
parentTrac #10519: fix doctests (diff)
Trac #10519: speed up for univariate_decomposition
-rw-r--r--src/sage/rings/asymptotic/asymptotics_multivariate_generating_functions.py21
1 files changed, 16 insertions, 5 deletions
diff --git a/src/sage/rings/asymptotic/asymptotics_multivariate_generating_functions.py b/src/sage/rings/asymptotic/asymptotics_multivariate_generating_functions.py
index 0750b05..1246fb3 100644
--- a/src/sage/rings/asymptotic/asymptotics_multivariate_generating_functions.py
+++ b/src/sage/rings/asymptotic/asymptotics_multivariate_generating_functions.py
@@ -794,7 +794,7 @@ class FractionWithFactoredDenominator(sage.structure.element.RingElement):
def univariate_decomposition(self):
r"""
Return the usual univariate partial fraction decomposition
- of ``self``.
+ if this element.
INPUT:
@@ -820,6 +820,15 @@ class FractionWithFactoredDenominator(sage.structure.element.RingElement):
for some `p_j \in R`.
We call `(*)` the *usual partial fraction decomposition* of `f`.
+ .. NOTE::
+
+ This partial fraction decomposition can be computed using
+ - :meth:`sage.symbolic.expression.Expression.partial_fraction` or
+ - :meth:`sage.categories.quotient_fields.QuotientFields.ElementMethods.partial_fraction_decomposition`
+ as well. However, here we use the already obtained/cached
+ factorization of the denominator. This gives a speed up for
+ non-small instances.
+
EXAMPLES::
sage: from sage.rings.asymptotic.asymptotics_multivariate_generating_functions import FractionWithFactoredDenominatorRing
@@ -922,10 +931,12 @@ class FractionWithFactoredDenominator(sage.structure.element.RingElement):
p = R.one()
df = self.denominator_factored()
decomp = [self.parent()(whole, [])]
- for (a, m) in df:
- numer = p * prod([b ** n
- for (b, n) in df
- if b != a]).inverse_mod(a ** m) % (a ** m)
+ denominator = prod(b**n for b, n in df)
+ for a, m in df:
+ am = a**m
+ q, r = denominator.quo_rem(am)
+ assert r==0
+ numer = p * q.inverse_mod(am) % am
# The inverse exists because the product and a**m
# are relatively prime.
decomp.append(self.parent()(mn * numer, [(a, m)]))