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

Commit

Permalink
Rewrite to pass to Permutations
Browse files Browse the repository at this point in the history
  • Loading branch information
trevorkarn committed Oct 15, 2022
1 parent 822906d commit da18880
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 13 deletions.
27 changes: 14 additions & 13 deletions src/sage/categories/weyl_groups.py
Original file line number Diff line number Diff line change
Expand Up @@ -521,6 +521,10 @@ def stanley_symmetric_function(self):
EXAMPLES::
sage: W = WeylGroup(['A', 3])
sage: W.from_reduced_word([3,2,3,1]).stanley_symmetric_function()
3*m[1, 1, 1, 1] + 2*m[2, 1, 1] + m[2, 2] + m[3, 1]
sage: W = WeylGroup(['A', 3, 1])
sage: W.from_reduced_word([3,1,2,0,3,1,0]).stanley_symmetric_function()
8*m[1, 1, 1, 1, 1, 1, 1] + 4*m[2, 1, 1, 1, 1, 1] + 2*m[2, 2, 1, 1, 1] + m[2, 2, 2, 1]
Expand Down Expand Up @@ -571,22 +575,19 @@ def stanley_symmetric_function(self):
In type-A, utilize the peelable tableaux algorithm of [RS1995]_.
In other types, use induction on left Pieri factors.
"""
import sage.combinat.sf
from sage.rings.rational_field import QQ
m = sage.combinat.sf.sf.SymmetricFunctions(QQ).monomial()
cartan_type = self.parent().cartan_type()

# the setting for [RS1995]_
if cartan_type[0] == 'A' and not cartan_type.is_affine():
is_affine = cartan_type.is_affine()
if cartan_type == 'A' and not is_affine:
from sage.combinat.permutation import Permutation
from sage.combinat.diagram import RotheDiagram
s = sage.combinat.sf.sf.SymmetricFunctions(QQ).schur()
try:
p = Permutation(self.to_permutation())
except AttributeError: # to handle SymmetricGroupElements
p = Permutation(self.domain())
return m.sum(s[T.shape()] for T in RotheDiagram(p).peelable_tableaux())
try: # handle WeylGroupElements
return Permutation(list(self.to_permutation())).stanley_symmetric_function()
except AttributeError: # handle SymmetricGroupElements
return Permutation(self.domain).stanley_symmetric_function()

# handle other types
import sage.combinat.sf
from sage.rings.rational_field import QQ
m = sage.combinat.sf.sf.SymmetricFunctions(QQ).monomial()
return m.from_polynomial_exp(self.stanley_symmetric_function_as_polynomial())

@cached_in_parent_method
Expand Down
13 changes: 13 additions & 0 deletions src/sage/combinat/permutation.py
Original file line number Diff line number Diff line change
Expand Up @@ -3010,6 +3010,19 @@ def n_reduced_words(self):
def stanley_symmetric_function(self):
r"""
Return the Stanley symmetric function associated to ``self``.
EXAMPLES::
sage: p = Permutation([4,5,2,3,1])
sage: p.stanley_symmetric_function()
56*m[1, 1, 1, 1, 1, 1, 1, 1] + 26*m[2, 1, 1, 1, 1, 1, 1]
+ 12*m[2, 2, 1, 1, 1, 1] + 5*m[2, 2, 2, 1, 1] + 2*m[2, 2, 2, 2]
+ 6*m[3, 1, 1, 1, 1, 1] + 3*m[3, 2, 1, 1, 1] + m[3, 2, 2, 1]
+ m[3, 3, 1, 1]
.. ALGORITHM:
Uses the peelable tableaux algorithm of [RS1995]_.
"""

from sage.combinat.sf.sf import SymmetricFunctions
Expand Down

0 comments on commit da18880

Please sign in to comment.