@@ -479,7 +479,7 @@ def _coerce_map_from_(self, R):
479
479
EXAMPLES::
480
480
481
481
sage: k = KeyPolynomials(QQ)
482
- sage: m1 = k([3,2,4, 0]); m1
482
+ sage: m1 = k([3, 2, 4, 0]); m1
483
483
k[3, 2, 4]
484
484
sage: m2 = k(Composition([3, 2, 4])); m2
485
485
k[3, 2, 4]
@@ -490,10 +490,19 @@ def _coerce_map_from_(self, R):
490
490
sage: z = R.gen()
491
491
sage: z[0] * k([4, 3, 3, 2])
492
492
k[5, 3, 3, 2]
493
+
494
+ sage: X = SchubertPolynomialRing(QQ)
495
+ sage: k(X([4, 3, 2, 1]))
496
+ k[3, 2, 1]
493
497
"""
494
498
P = self ._polynomial_ring
495
499
if R is P :
496
500
return self .from_polynomial
501
+
502
+ from sage .combinat .schubert_polynomial import SchubertPolynomialRing_xbasis
503
+ if isinstance (R , SchubertPolynomialRing_xbasis ):
504
+ return CallableConvertMap (R , self , self .from_schubert_polynomial )
505
+
497
506
phi = P .coerce_map_from (R )
498
507
if phi is not None :
499
508
return self .coerce_map_from (P ) * phi
@@ -645,6 +654,52 @@ def from_polynomial(self, f):
645
654
646
655
return out
647
656
657
+ def from_schubert_polynomial (self , x ):
658
+ r"""
659
+ Expand a Schubert polynomial in the key basis.
660
+
661
+ EXAMPLES::
662
+
663
+ sage: from sage.combinat.key_polynomial import KeyPolynomialBasis
664
+ sage: k = KeyPolynomialBasis(ZZ)
665
+ sage: X = SchubertPolynomialRing(ZZ)
666
+ sage: f = X([2,1,5,4,3])
667
+ sage: k.from_schubert_polynomial(f)
668
+ k[1, 0, 2, 1] + k[2, 0, 2] + k[3, 0, 0, 1]
669
+ sage: k.from_schubert_polynomial(2)
670
+ 2*k[]
671
+ sage: k(f) #indirect doctest
672
+ k[1, 0, 2, 1] + k[2, 0, 2] + k[3, 0, 0, 1]
673
+
674
+ TESTS::
675
+
676
+ sage: from sage.combinat.key_polynomial import KeyPolynomialBasis
677
+ sage: k = KeyPolynomialBasis(ZZ)
678
+ sage: k.from_schubert_polynomial(k([3,2]))
679
+ Traceback (most recent call last):
680
+ ...
681
+ ValueError: Please provide a Schubert polynomial
682
+ """
683
+ if x in self .base_ring ():
684
+ return self (x )
685
+ from sage .combinat .schubert_polynomial import SchubertPolynomial_class
686
+ if not isinstance (x , SchubertPolynomial_class ):
687
+ raise ValueError ('Please provide a Schubert polynomial' )
688
+
689
+ from sage .combinat .diagram import RotheDiagram
690
+ R = KeyPolynomialBasis (self .base_ring ())
691
+ out = R .zero ()
692
+
693
+ for m , c in x .monomial_coefficients ().items ():
694
+ D = RotheDiagram (m )
695
+ a = R .zero ()
696
+ for d in D .peelable_tableaux ():
697
+ a += R (d .left_key_tableau ().weight ())
698
+ out += c * a
699
+
700
+ return out
701
+
702
+
648
703
def divided_difference (f , i ):
649
704
r"""
650
705
Apply the ``i``-th divided difference operator to the polynomial ``f``.
0 commit comments