11r"""
22Schubert Polynomials
33"""
4- #* ****************************************************************************
4+ # ****************************************************************************
55# Copyright (C) 2007 Mike Hansen <[email protected] >, 66#
77# Distributed under the terms of the GNU General Public License (GPL)
1313#
1414# The full text of the GPL is available at:
1515#
16- # http://www.gnu.org/licenses/
17- #*****************************************************************************
18- from __future__ import absolute_import
19-
16+ # https://www.gnu.org/licenses/
17+ # ****************************************************************************
2018from sage .combinat .free_module import CombinatorialFreeModule
21- from sage .combinat .combinatorial_algebra import CombinatorialAlgebra
2219from sage .categories .all import GradedAlgebrasWithBasis
2320from sage .rings .all import Integer , PolynomialRing , ZZ
2421from sage .rings .polynomial .multi_polynomial import is_MPolynomial
2825
2926def SchubertPolynomialRing (R ):
3027 """
31- Returns the Schubert polynomial ring over ``R`` on the X basis
32- (i.e., the basis of the Schubert polynomials).
28+ Return the Schubert polynomial ring over ``R`` on the X basis.
29+
30+ This is the basis made of the Schubert polynomials.
3331
3432 EXAMPLES::
3533
3634 sage: X = SchubertPolynomialRing(ZZ); X
3735 Schubert polynomial ring with X basis over Integer Ring
36+ sage: TestSuite(X).run()
3837 sage: X(1)
3938 X[1]
4039 sage: X([1,2,3])*X([2,1,3])
@@ -49,26 +48,6 @@ def SchubertPolynomialRing(R):
4948 """
5049 return SchubertPolynomialRing_xbasis (R )
5150
52- def is_SchubertPolynomial (x ):
53- """
54- Returns ``True`` if ``x`` is a Schubert polynomial, and
55- ``False`` otherwise.
56-
57- EXAMPLES::
58-
59- sage: from sage.combinat.schubert_polynomial import is_SchubertPolynomial
60- sage: X = SchubertPolynomialRing(ZZ)
61- sage: a = 1
62- sage: is_SchubertPolynomial(a)
63- False
64- sage: b = X(1)
65- sage: is_SchubertPolynomial(b)
66- True
67- sage: c = X([2,1,3])
68- sage: is_SchubertPolynomial(c)
69- True
70- """
71- return isinstance (x , SchubertPolynomial_class )
7251
7352class SchubertPolynomial_class (CombinatorialFreeModule .Element ):
7453 def expand (self ):
@@ -112,10 +91,11 @@ def divided_difference(self, i, algorithm="sage"):
11291 r"""
11392 Return the ``i``-th divided difference operator, applied to
11493 ``self``.
94+
11595 Here, ``i`` can be either a permutation or a positive integer.
11696
11797 INPUT:
118-
98+
11999 - ``i`` -- permutation or positive integer
120100
121101 - ``algorithm`` -- (default: ``'sage'``) either ``'sage'``
@@ -126,7 +106,7 @@ def divided_difference(self, i, algorithm="sage"):
126106
127107 The result of applying the ``i``-th divided difference
128108 operator to ``self``.
129-
109+
130110 If `i` is a positive integer, then the `i`-th divided
131111 difference operator `\delta_i` is the linear operator sending
132112 each polynomial `f = f(x_1, x_2, \ldots, x_n)` (in
@@ -215,7 +195,7 @@ def divided_difference(self, i, algorithm="sage"):
215195 ...
216196 ValueError: cannot apply \delta_{0} to a (= X[3, 2, 4, 1])
217197 """
218- if not self : # if self is 0
198+ if not self : # if self is 0
219199 return self
220200 Perms = Permutations ()
221201 if i in ZZ :
@@ -237,13 +217,13 @@ def divided_difference(self, i, algorithm="sage"):
237217 n = len (pi )
238218 if n <= i :
239219 continue
240- if pi [i - 1 ] < pi [i ]:
220+ if pi [i - 1 ] < pi [i ]:
241221 continue
242- pi [i - 1 ], pi [i ] = pi [i ], pi [i - 1 ]
222+ pi [i - 1 ], pi [i ] = pi [i ], pi [i - 1 ]
243223 pi = Perms (pi ).remove_extra_fixed_points ()
244224 res_dict [pi ] = coeff
245225 return self .parent ()._from_dict (res_dict )
246- else : # if algorithm == "symmetrica":
226+ else : # if algorithm == "symmetrica":
247227 return symmetrica .divdiff_schubert (i , self )
248228 elif i in Perms :
249229 if algorithm == "sage" :
@@ -258,23 +238,23 @@ def divided_difference(self, i, algorithm="sage"):
258238 if n <= j :
259239 next_pi = True
260240 break
261- if pi [j - 1 ] < pi [j ]:
241+ if pi [j - 1 ] < pi [j ]:
262242 next_pi = True
263243 break
264- pi [j - 1 ], pi [j ] = pi [j ], pi [j - 1 ]
244+ pi [j - 1 ], pi [j ] = pi [j ], pi [j - 1 ]
265245 if next_pi :
266246 continue
267247 pi = Perms (pi ).remove_extra_fixed_points ()
268248 res_dict [pi ] = coeff
269249 return self .parent ()._from_dict (res_dict )
270- else : # if algorithm == "symmetrica":
250+ else : # if algorithm == "symmetrica":
271251 return symmetrica .divdiff_perm_schubert (i , self )
272252 else :
273253 raise TypeError ("i must either be an integer or permutation" )
274254
275255 def scalar_product (self , x ):
276256 """
277- Returns the standard scalar product of ``self`` and ``x``.
257+ Return the standard scalar product of ``self`` and ``x``.
278258
279259 EXAMPLES::
280260
@@ -294,14 +274,14 @@ def scalar_product(self, x):
294274 sage: c.expand(4)
295275 x0^2*x1*x2 + x0*x1^2*x2 + x0*x1*x2^2 + x0^2*x1*x3 + x0*x1^2*x3 + x0^2*x2*x3 + 3*x0*x1*x2*x3 + x1^2*x2*x3 + x0*x2^2*x3 + x1*x2^2*x3 + x0*x1*x3^2 + x0*x2*x3^2 + x1*x2*x3^2
296276 """
297- if is_SchubertPolynomial ( x ):
277+ if isinstance ( x , SchubertPolynomial_class ):
298278 return symmetrica .scalarproduct_schubert (self , x )
299279 else :
300280 raise TypeError ("x must be a Schubert polynomial" )
301281
302282 def multiply_variable (self , i ):
303283 """
304- Returns the Schubert polynomial obtained by multiplying ``self``
284+ Return the Schubert polynomial obtained by multiplying ``self``
305285 by the variable `x_i`.
306286
307287 EXAMPLES::
@@ -322,9 +302,8 @@ def multiply_variable(self, i):
322302 else :
323303 raise TypeError ("i must be an integer" )
324304
325- # FIXME: inherit from CombinatorialFreeModule once the
326- # coercion from ground ring is implemented in the category
327- class SchubertPolynomialRing_xbasis (CombinatorialAlgebra ):
305+
306+ class SchubertPolynomialRing_xbasis (CombinatorialFreeModule ):
328307
329308 Element = SchubertPolynomial_class
330309
@@ -338,13 +317,25 @@ def __init__(self, R):
338317 """
339318 self ._name = "Schubert polynomial ring with X basis"
340319 self ._repr_option_bracket = False
341- self ._one = Permutations ()([1 ])
342- CombinatorialAlgebra .__init__ (self , R , cc = Permutations (), category = GradedAlgebrasWithBasis (R ))
343- self .print_options (prefix = 'X' )
320+ CombinatorialFreeModule .__init__ (self , R , Permutations (),
321+ category = GradedAlgebrasWithBasis (R ),
322+ prefix = 'X' )
323+
324+ def one_basis (self ):
325+ """
326+ Return the index of the unit of this algebra.
327+
328+ EXAMPLES::
329+
330+ sage: X = SchubertPolynomialRing(QQ)
331+ sage: X.one() # indirect doctest
332+ X[1]
333+ """
334+ return Permutations ()([1 ])
344335
345336 def _element_constructor_ (self , x ):
346337 """
347- Coerce x into self.
338+ Coerce x into `` self`` .
348339
349340 EXAMPLES::
350341
@@ -369,21 +360,32 @@ def _element_constructor_(self, x):
369360 ValueError: The input [1, 2, 1] is not a valid permutation
370361 """
371362 if isinstance (x , list ):
372- #checking the input to avoid symmetrica crashing Sage, see trac 12924
373- if not x in Permutations ():
374- raise ValueError ("The input %s is not a valid permutation" % ( x ) )
363+ # checking the input to avoid symmetrica crashing Sage, see trac 12924
364+ if x not in Permutations ():
365+ raise ValueError ("The input %s is not a valid permutation" % x )
375366 perm = Permutation (x ).remove_extra_fixed_points ()
376- return self ._from_dict ({ perm : self .base_ring ().one () })
367+ return self ._from_dict ({perm : self .base_ring ().one ()})
377368 elif isinstance (x , Permutation ):
378- if not list (x ) in Permutations ():
379- raise ValueError ("The input %s is not a valid permutation" % (x ))
380369 perm = x .remove_extra_fixed_points ()
381- return self ._from_dict ({ perm : self .base_ring ().one () })
370+ return self ._from_dict ({perm : self .base_ring ().one ()})
382371 elif is_MPolynomial (x ):
383372 return symmetrica .t_POLYNOM_SCHUBERT (x )
384373 else :
385374 raise TypeError
386375
376+ def some_elements (self ):
377+ """
378+ Return some elements.
379+
380+ EXAMPLES::
381+
382+ sage: X = SchubertPolynomialRing(QQ)
383+ sage: X.some_elements()
384+ [X[1], X[1] + 2*X[2, 1], -X[3, 2, 1] + X[4, 2, 1, 3]]
385+ """
386+ return [self .one (), self ([1 ]) + 2 * self ([2 , 1 ]),
387+ self ([4 , 2 , 1 , 3 ]) - self ([3 , 2 , 1 ])]
388+
387389 def _multiply_basis (self , left , right ):
388390 """
389391 EXAMPLES::
0 commit comments