Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Commit

Permalink
Trac #19532: Merge #19946
Browse files Browse the repository at this point in the history
in order to avoid work-arounds, #19946 is merged
  • Loading branch information
cheuberg committed Jan 26, 2016
2 parents 2dff051 + 7918417 commit bfb72dc
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 4 deletions.
20 changes: 20 additions & 0 deletions src/sage/rings/asymptotic/asymptotic_ring.py
Original file line number Diff line number Diff line change
Expand Up @@ -1416,6 +1416,18 @@ def __pow__(self, exponent, precision=None):
ValueError: Cannot take s + t to the exponent s.
> *previous* ValueError: log(s + t) cannot be constructed since
there are several maximal elements s, t.
Check that :trac:`19946` is fixed::
sage: A.<n> = AsymptoticRing('QQ^n * n^QQ', SR)
sage: e = 2^n; e
2^n
sage: e.parent()
Asymptotic Ring <SR^n * n^SR> over Symbolic Ring
sage: e = A(e); e
2^n
sage: e.parent()
Asymptotic Ring <QQ^n * n^QQ> over Symbolic Ring
"""
if not self.summands:
if exponent == 0:
Expand Down Expand Up @@ -1674,6 +1686,14 @@ def rpow(self, base, precision=None):
ArithmeticError: Cannot construct y^x in Growth Group x^ZZ
> *previous* TypeError: unsupported operand parent(s) for '*':
'Growth Group x^ZZ' and 'Growth Group SR^x'
Check that :trac:`19946` is fixed::
sage: A.<n> = AsymptoticRing('QQ^n * n^QQ', SR)
sage: n.rpow(2)
2^n
sage: _.parent()
Asymptotic Ring <QQ^n * n^SR> over Symbolic Ring
"""
if isinstance(base, AsymptoticExpansion):
return base.__pow__(self, precision=precision)
Expand Down
8 changes: 8 additions & 0 deletions src/sage/rings/asymptotic/growth_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -873,6 +873,14 @@ def _rpow_(self, base):
sage: x = G('x')
sage: (x * log(x)).rpow(2) # indirect doctest
2^(x*log(x))
::
sage: n = GrowthGroup('QQ^n * n^QQ')('n')
sage: n.rpow(2)
2^n
sage: _.parent()
Growth Group QQ^n * n^QQ
"""
if base == 0:
raise ValueError('%s is not an allowed base for calculating the '
Expand Down
14 changes: 10 additions & 4 deletions src/sage/rings/asymptotic/growth_group_cartesian.py
Original file line number Diff line number Diff line change
Expand Up @@ -692,11 +692,17 @@ def _pushout_(self, other):
Growth Group QQ^x * x^QQ
sage: cm.common_parent(GrowthGroup('QQ^x * x^ZZ'), GrowthGroup('ZZ^x * x^QQ'))
Growth Group QQ^x * x^QQ
::
sage: pushout(GrowthGroup('QQ^n * n^QQ'), GrowthGroup('SR^n'))
Growth Group SR^n * n^QQ
"""
from growth_group import GenericGrowthGroup, AbstractGrowthGroupFunctor
from misc import merge_overlapping
from misc import underlying_class

Sfactors = self.cartesian_factors()
if isinstance(other, GenericProduct):
Ofactors = other.cartesian_factors()
elif isinstance(other, GenericGrowthGroup):
Expand Down Expand Up @@ -759,7 +765,7 @@ def next(self):
self.factors = tuple()

from itertools import groupby
S = it(groupby(self.cartesian_factors(), key=lambda k: k.variable_names()))
S = it(groupby(Sfactors, key=lambda k: k.variable_names()))
O = it(groupby(Ofactors, key=lambda k: k.variable_names()))

newS = []
Expand All @@ -786,9 +792,9 @@ def next(self):

assert(len(newS) == len(newO))

if (len(self.cartesian_factors()) == len(newS) and
len(other.cartesian_factors()) == len(newO)):
# We had already all factors in each of the self and
if (len(Sfactors) == len(newS) and
len(Ofactors) == len(newO)):
# We had already all factors in each of self and
# other, thus splitting it in subproblems (one for
# each factor) is the strategy to use. If a pushout is
# possible :func:`sage.categories.pushout.pushout`
Expand Down
20 changes: 20 additions & 0 deletions src/sage/rings/asymptotic/term_monoid.py
Original file line number Diff line number Diff line change
Expand Up @@ -3368,6 +3368,26 @@ def rpow(self, base):
Growth Group QQ^x * x^ZZ * log(x)^ZZ
> *previous* TypeError: unsupported operand parent(s) for '*':
'Growth Group QQ^x * x^ZZ * log(x)^ZZ' and 'Growth Group ZZ^(x^2)'
::
sage: T = TermMonoid('exact', GrowthGroup('QQ^n * n^QQ'), SR)
sage: n = T('n')
sage: n.rpow(2)
2^n
sage: _.parent()
Exact Term Monoid QQ^n * n^SR with coefficients in Symbolic Ring
Above, we get ``QQ^n * n^SR`` since
::
sage: (n^SR(1)).parent()
Exact Term Monoid QQ^n * n^SR with coefficients in Symbolic Ring
and that is because of ::
sage: (QQ(2)^SR(1)).parent(), (QQ(1)*SR(1)).parent()
(Rational Field, Symbolic Ring)
"""
P = self.parent()

Expand Down

0 comments on commit bfb72dc

Please sign in to comment.