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

Commit

Permalink
Adding a completion of graded algebras by formal series.
Browse files Browse the repository at this point in the history
  • Loading branch information
tscrim committed Aug 22, 2022
1 parent e780472 commit dff4fc4
Show file tree
Hide file tree
Showing 4 changed files with 223 additions and 114 deletions.
17 changes: 17 additions & 0 deletions src/sage/categories/graded_algebras_with_basis.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,23 @@ def free_graded_module(self, generator_degrees, names=None):
from sage.modules.fp_graded.free_module import FreeGradedModule
return FreeGradedModule(self, generator_degrees, names=names)

def formal_series_ring(self):
r"""
Return the completion of all formal linear combinations of
``self`` with finite linear combinations in each homogeneous
degree (computed lazily).
EXAMPLES::
sage: NCSF = NonCommutativeSymmetricFunctions(QQ)
sage: S = NCSF.Complete()
sage: L = S.formal_series_ring()
sage: L
Lazy completion of Non-Commutative Symmetric Functions over
the Rational Field in the Complete basis
"""
from sage.rings.lazy_series_ring import LazyCompletionGradedAlgebra
return LazyCompletionGradedAlgebra(self)

class ElementMethods:
pass
Expand Down
21 changes: 21 additions & 0 deletions src/sage/combinat/sf/sfa.py
Original file line number Diff line number Diff line change
Expand Up @@ -1449,6 +1449,27 @@ def coeff_of_m_mu_in_result(mu):
distinct=True)
return self(r)

def formal_series_ring(self):
r"""
Return the completion of all formal linear combinations of
``self`` with finite linear combinations in each homogeneous
degree (computed lazily).
EXAMPLES::
sage: s = SymmetricFunctions(ZZ).s()
sage: L = s.formal_series_ring()
sage: L
Lazy completion of Symmetric Functions over Integer Ring in the Schur basis
TESTS::
sage: type(L)
<class 'sage.rings.lazy_series_ring.LazySymmetricFunctions_with_category'>
"""
from sage.rings.lazy_series_ring import LazySymmetricFunctions
return LazySymmetricFunctions(self)

class FilteredSymmetricFunctionsBases(Category_realization_of_parent):
r"""
The category of filtered bases of the ring of symmetric functions.
Expand Down
155 changes: 80 additions & 75 deletions src/sage/rings/lazy_series.py
Original file line number Diff line number Diff line change
Expand Up @@ -3615,7 +3615,86 @@ def polynomial(self, degree=None, names=None):
return R.sum(self[:m])


class LazySymmetricFunction(LazyCauchyProductSeries):
class LazyCompletionGradedAlgebraElement(LazyCauchyProductSeries):
"""
An element of a completion of a graded algebra that is computed lazily.
"""
def _format_series(self, formatter, format_strings=False):
r"""
Return nonzero ``self`` formatted by ``formatter``.
TESTS::
sage: h = SymmetricFunctions(ZZ).h()
sage: e = SymmetricFunctions(ZZ).e()
sage: L = LazySymmetricFunctions(tensor([h, e]))
sage: f = L(lambda n: sum(tensor([h[k], e[n-k]]) for k in range(n+1)))
sage: f._format_series(repr)
'(h[]#e[])
+ (h[]#e[1]+h[1]#e[])
+ (h[]#e[2]+h[1]#e[1]+h[2]#e[])
+ (h[]#e[3]+h[1]#e[2]+h[2]#e[1]+h[3]#e[])
+ (h[]#e[4]+h[1]#e[3]+h[2]#e[2]+h[3]#e[1]+h[4]#e[])
+ (h[]#e[5]+h[1]#e[4]+h[2]#e[3]+h[3]#e[2]+h[4]#e[1]+h[5]#e[])
+ (h[]#e[6]+h[1]#e[5]+h[2]#e[4]+h[3]#e[3]+h[4]#e[2]+h[5]#e[1]+h[6]#e[])
+ O^7'
"""
P = self.parent()
cs = self._coeff_stream
v = cs._approximate_order
if isinstance(cs, Stream_exact):
if not cs._constant:
m = cs._degree
else:
m = cs._degree + P.options.constant_length
else:
m = v + P.options.display_length

atomic_repr = P._internal_poly_ring.base_ring()._repr_option('element_is_atomic')
mons = [P._monomial(self[i], i) for i in range(v, m) if self[i]]
if not isinstance(cs, Stream_exact) or cs._constant:
if P._internal_poly_ring.base_ring() is P.base_ring():
bigO = ["O(%s)" % P._monomial(1, m)]
else:
bigO = ["O^%s" % m]
else:
bigO = []

from sage.misc.latex import latex
from sage.typeset.unicode_art import unicode_art
from sage.typeset.ascii_art import ascii_art
from sage.misc.repr import repr_lincomb
from sage.typeset.symbols import ascii_left_parenthesis, ascii_right_parenthesis
from sage.typeset.symbols import unicode_left_parenthesis, unicode_right_parenthesis
if formatter == repr:
poly = repr_lincomb([(1, m) for m in mons + bigO], strip_one=True)
elif formatter == latex:
poly = repr_lincomb([(1, m) for m in mons + bigO], is_latex=True, strip_one=True)
elif formatter == ascii_art:
if atomic_repr:
poly = ascii_art(*(mons + bigO), sep = " + ")
else:
def parenthesize(m):
a = ascii_art(m)
h = a.height()
return ascii_art(ascii_left_parenthesis.character_art(h),
a, ascii_right_parenthesis.character_art(h))
poly = ascii_art(*([parenthesize(m) for m in mons] + bigO), sep = " + ")
elif formatter == unicode_art:
if atomic_repr:
poly = unicode_art(*(mons + bigO), sep = " + ")
else:
def parenthesize(m):
a = unicode_art(m)
h = a.height()
return unicode_art(unicode_left_parenthesis.character_art(h),
a, unicode_right_parenthesis.character_art(h))
poly = unicode_art(*([parenthesize(m) for m in mons] + bigO), sep = " + ")

return poly


class LazySymmetricFunction(LazyCompletionGradedAlgebraElement):
r"""
A symmetric function where each degree is computed lazily.
Expand Down Expand Up @@ -3752,80 +3831,6 @@ def __call__(self, *args, check=True):

plethysm = __call__

def _format_series(self, formatter, format_strings=False):
r"""
Return nonzero ``self`` formatted by ``formatter``.
TESTS::
sage: h = SymmetricFunctions(ZZ).h()
sage: e = SymmetricFunctions(ZZ).e()
sage: L = LazySymmetricFunctions(tensor([h, e]))
sage: f = L(lambda n: sum(tensor([h[k], e[n-k]]) for k in range(n+1)))
sage: f._format_series(repr)
'(h[]#e[])
+ (h[]#e[1]+h[1]#e[])
+ (h[]#e[2]+h[1]#e[1]+h[2]#e[])
+ (h[]#e[3]+h[1]#e[2]+h[2]#e[1]+h[3]#e[])
+ (h[]#e[4]+h[1]#e[3]+h[2]#e[2]+h[3]#e[1]+h[4]#e[])
+ (h[]#e[5]+h[1]#e[4]+h[2]#e[3]+h[3]#e[2]+h[4]#e[1]+h[5]#e[])
+ (h[]#e[6]+h[1]#e[5]+h[2]#e[4]+h[3]#e[3]+h[4]#e[2]+h[5]#e[1]+h[6]#e[])
+ O^7'
"""
P = self.parent()
cs = self._coeff_stream
v = cs._approximate_order
if isinstance(cs, Stream_exact):
if not cs._constant:
m = cs._degree
else:
m = cs._degree + P.options.constant_length
else:
m = v + P.options.display_length

atomic_repr = P._internal_poly_ring.base_ring()._repr_option('element_is_atomic')
mons = [P._monomial(self[i], i) for i in range(v, m) if self[i]]
if not isinstance(cs, Stream_exact) or cs._constant:
if P._internal_poly_ring.base_ring() is P.base_ring():
bigO = ["O(%s)" % P._monomial(1, m)]
else:
bigO = ["O^%s" % m]
else:
bigO = []

from sage.misc.latex import latex
from sage.typeset.unicode_art import unicode_art
from sage.typeset.ascii_art import ascii_art
from sage.misc.repr import repr_lincomb
from sage.typeset.symbols import ascii_left_parenthesis, ascii_right_parenthesis
from sage.typeset.symbols import unicode_left_parenthesis, unicode_right_parenthesis
if formatter == repr:
poly = repr_lincomb([(1, m) for m in mons + bigO], strip_one=True)
elif formatter == latex:
poly = repr_lincomb([(1, m) for m in mons + bigO], is_latex=True, strip_one=True)
elif formatter == ascii_art:
if atomic_repr:
poly = ascii_art(*(mons + bigO), sep = " + ")
else:
def parenthesize(m):
a = ascii_art(m)
h = a.height()
return ascii_art(ascii_left_parenthesis.character_art(h),
a, ascii_right_parenthesis.character_art(h))
poly = ascii_art(*([parenthesize(m) for m in mons] + bigO), sep = " + ")
elif formatter == unicode_art:
if atomic_repr:
poly = unicode_art(*(mons + bigO), sep = " + ")
else:
def parenthesize(m):
a = unicode_art(m)
h = a.height()
return unicode_art(unicode_left_parenthesis.character_art(h),
a, unicode_right_parenthesis.character_art(h))
poly = unicode_art(*([parenthesize(m) for m in mons] + bigO), sep = " + ")

return poly

def symmetric_function(self, degree=None):
r"""
Return ``self`` as a symmetric function if ``self`` is actually so.
Expand Down
Loading

0 comments on commit dff4fc4

Please sign in to comment.