@@ -440,7 +440,7 @@ def _coerce_map_from_(self, R):
440
440
441
441
sage: from sage.combinat.key_polynomial import KeyPolynomialBasis
442
442
sage: k = KeyPolynomialBasis(QQ)
443
- sage: m1 = k([3,2,4, 0]); m1
443
+ sage: m1 = k([3, 2, 4, 0]); m1
444
444
k[3, 2, 4]
445
445
sage: m2 = k(Composition([3, 2, 4])); m2
446
446
k[3, 2, 4]
@@ -451,11 +451,21 @@ def _coerce_map_from_(self, R):
451
451
sage: z = R.gen()
452
452
sage: z[0] * k([4, 3, 3, 2])
453
453
k[5, 3, 3, 2]
454
+
455
+ sage: X = SchubertPolynomialRing(QQ)
456
+ sage: k(X([4, 3, 2, 1]))
457
+ k[3, 2, 1]
454
458
"""
455
- P = self ._polynomial_ring
456
459
from sage .structure .coerce_maps import CallableConvertMap
460
+
461
+ P = self ._polynomial_ring
457
462
if R is P :
458
463
return CallableConvertMap (R , self , self .from_polynomial )
464
+
465
+ from sage .combinat .schubert_polynomial import SchubertPolynomialRing_xbasis
466
+ if isinstance (R , SchubertPolynomialRing_xbasis ):
467
+ return CallableConvertMap (R , self , self .from_schubert_polynomial )
468
+
459
469
phi = P .coerce_map_from (R )
460
470
if phi is not None :
461
471
return self .coerce_map_from (P ) * phi
@@ -578,6 +588,51 @@ def from_polynomial(self, f):
578
588
579
589
return out
580
590
591
+ def from_schubert_polynomial (self , x ):
592
+ r"""
593
+ Expand a Schubert polynomial in the key basis.
594
+
595
+ EXAMPLES::
596
+
597
+ sage: from sage.combinat.key_polynomial import KeyPolynomialBasis
598
+ sage: k = KeyPolynomialBasis(ZZ)
599
+ sage: X = SchubertPolynomialRing(ZZ)
600
+ sage: f = X([2,1,5,4,3])
601
+ sage: k.from_schubert_polynomial(f)
602
+ k[1, 0, 2, 1] + k[2, 0, 2] + k[3, 0, 0, 1]
603
+ sage: k.from_schubert_polynomial(2)
604
+ 2*k[]
605
+ sage: k(f) #indirect doctest
606
+ k[1, 0, 2, 1] + k[2, 0, 2] + k[3, 0, 0, 1]
607
+
608
+ TESTS::
609
+
610
+ sage: from sage.combinat.key_polynomial import KeyPolynomialBasis
611
+ sage: k = KeyPolynomialBasis(ZZ)
612
+ sage: k.from_schubert_polynomial(k([3,2]))
613
+ Traceback (most recent call last):
614
+ ...
615
+ ValueError: Please provide a Schubert polynomial
616
+ """
617
+ if x in self .base_ring ():
618
+ return self (x )
619
+ from sage .combinat .schubert_polynomial import SchubertPolynomial_class
620
+ if not isinstance (x , SchubertPolynomial_class ):
621
+ raise ValueError ('Please provide a Schubert polynomial' )
622
+
623
+ from sage .combinat .diagram import RotheDiagram
624
+ R = KeyPolynomialBasis (self .base_ring ())
625
+ out = R .zero ()
626
+
627
+ for m , c in x .monomial_coefficients ().items ():
628
+ D = RotheDiagram (m )
629
+ a = R .zero ()
630
+ for d in D .peelable_tableaux ():
631
+ a += R (d .left_key_tableau ().weight ())
632
+ out += c * a
633
+
634
+ return out
635
+
581
636
582
637
def _divided_difference (P , i , f ):
583
638
r"""
0 commit comments