@@ -207,6 +207,7 @@ def divided_difference(self, w):
207
207
f = _divided_difference (P , wi , f )
208
208
return P .from_polynomial (f )
209
209
210
+
210
211
class KeyPolynomialBasis (CombinatorialFreeModule ):
211
212
r"""
212
213
The key polynomial basis for a polynomial ring.
@@ -289,14 +290,14 @@ class KeyPolynomialBasis(CombinatorialFreeModule):
289
290
sage: f = T.demazure_character([3,2,1])
290
291
sage: k.from_polynomial(f)
291
292
k[1, 0, 0, 2]
292
-
293
+
293
294
The default behavior is to work in a polynomial ring with infinitely many
294
295
variables. One can work in a specicfied number of variables::
295
296
296
297
sage: from sage.combinat.key_polynomial import KeyPolynomialBasis
297
298
sage: k = KeyPolynomialBasis(QQ, 4)
298
299
sage: k([3,0,1,2]).expand()
299
- z_0^3*z_1^2*z_2 + z_0^3*z_1*z_2^2 + z_0^3*z_1^2*z_3
300
+ z_0^3*z_1^2*z_2 + z_0^3*z_1*z_2^2 + z_0^3*z_1^2*z_3
300
301
+ 2*z_0^3*z_1*z_2*z_3 + z_0^3*z_2^2*z_3 + z_0^3*z_1*z_3^2 + z_0^3*z_2*z_3^2
301
302
302
303
sage: k([0,0,2,0]).expand()
@@ -352,10 +353,10 @@ def __classcall_private__(cls, R=None, k=None, poly_ring=None, poly_coeffs=False
352
353
353
354
sage: KeyPolynomialBasis(QQ['t0','t1','t2','t3'])
354
355
Key polynomial basis over Rational Field
355
-
356
+
356
357
sage: KeyPolynomialBasis(QQ['t'])
357
358
Key polynomial basis over Rational Field
358
-
359
+
359
360
sage: KeyPolynomialBasis(InfinitePolynomialRing(QQ['t'], 'z'))
360
361
Key polynomial basis over Univariate Polynomial Ring in t over Rational Field
361
362
@@ -366,7 +367,7 @@ def __classcall_private__(cls, R=None, k=None, poly_ring=None, poly_coeffs=False
366
367
Key polynomial basis over Rational Field
367
368
"""
368
369
369
- poly_type = (PolynomialRing_commutative ,
370
+ poly_type = (PolynomialRing_commutative ,
370
371
MPolynomialRing_base ,
371
372
InfinitePolynomialRing_sparse )
372
373
@@ -440,9 +441,9 @@ def build_index(m):
440
441
def _coerce_map_from_ (self , R ):
441
442
r"""
442
443
EXAMPLES::
443
-
444
+
444
445
sage: from sage.combinat.key_polynomial import KeyPolynomialBasis
445
- sage: k = KeyPolynomialBasis(QQ)
446
+ sage: k = KeyPolynomialBasis(QQ)
446
447
sage: m1 = k([3,2,4,0]); m1
447
448
k[3, 2, 4]
448
449
sage: m2 = k(Composition([3, 2, 4])); m2
@@ -460,7 +461,7 @@ def _coerce_map_from_(self, R):
460
461
if R is P :
461
462
return CallableConvertMap (R , self , self .from_polynomial )
462
463
phi = P .coerce_map_from (R )
463
- if phi is not None :
464
+ if phi is not None :
464
465
return self .coerce_map_from (P ) * phi
465
466
return None
466
467
@@ -494,7 +495,7 @@ def one_basis(self):
494
495
sage: from sage.combinat.key_polynomial import KeyPolynomialBasis
495
496
sage: k = KeyPolynomialBasis(QQ, 4)
496
497
sage: k.one_basis()
497
- [0, 0, 0, 0]
498
+ [0, 0, 0, 0]
498
499
"""
499
500
if self ._k :
500
501
return self ._indices ([0 ] * self ._k )
@@ -629,10 +630,11 @@ def _divided_difference(P, i, f):
629
630
R = P .polynomial_ring ()
630
631
z = P .poly_gens ()
631
632
632
- si_f = f .subs ({z [i + 1 ]:z [i ], z [i ]:z [i + 1 ]})
633
+ si_f = f .subs ({z [i + 1 ]: z [i ], z [i ]: z [i + 1 ]})
633
634
634
635
return (si_f - f )// (z [i + 1 ] - z [i ])
635
636
637
+
636
638
def _pi (P , w , f ):
637
639
r"""
638
640
Apply the operator `\pi_w` to the polynomial `f`.
@@ -641,7 +643,7 @@ def _pi(P, w, f):
641
643
642
644
.. WARNING::
643
645
644
- The simple transpositions should be applied from left to right.
646
+ The simple transpositions should be applied from left to right.
645
647
646
648
EXAMPLES::
647
649
@@ -667,6 +669,7 @@ def _pi(P, w, f):
667
669
f = _pi_i (P , i , f )
668
670
return f
669
671
672
+
670
673
def _pi_i (P , i , f ):
671
674
r"""
672
675
Apply `\pi_i` for a single simple transposition `s_i = (i, i+1)`.
@@ -686,10 +689,11 @@ def _pi_i(P, i, f):
686
689
z = P .poly_gens ()
687
690
return _divided_difference (P , i , z [i ] * f )
688
691
692
+
689
693
def _sorting_word (alpha ):
690
694
r"""
691
695
Get a reduced word for the permutation which sorts ``alpha``
692
- into a partition.
696
+ into a partition.
693
697
694
698
The result is a list ``l = [i0, i1, i2, ...]`` where each ``ij``
695
699
is a nonnegative integer such that it applies the simple
0 commit comments