From 5ff1792b2c070d5cdf996bced66afc4f1afcf33d Mon Sep 17 00:00:00 2001 From: Rachel Karpman Date: Fri, 13 Jan 2017 09:08:08 -0500 Subject: [PATCH 1/4] inital commit for adding bdd_affine_perm method in permutation --- src/sage/combinat/permutation.py | 62 ++++++++++++++++++++++++++++++-- 1 file changed, 59 insertions(+), 3 deletions(-) diff --git a/src/sage/combinat/permutation.py b/src/sage/combinat/permutation.py index 8789c6b8687..86275405b9c 100644 --- a/src/sage/combinat/permutation.py +++ b/src/sage/combinat/permutation.py @@ -182,13 +182,13 @@ :meth:`from_lehmer_code` | Returns the permutation with Lehmer code ``lehmer``. :meth:`from_reduced_word` | Returns the permutation corresponding to the reduced word ``rw``. :meth:`bistochastic_as_sum_of_permutations` | Returns a given bistochastic matrix as a nonnegative linear combination of permutations. + :meth:`bdd_affine_perm` | Returns a partial permutation representing the bounded affine permutation of a matrix :meth:`descents_composition_list` | Returns a list of all the permutations in a given descent class (i. e., having a given descents composition). :meth:`descents_composition_first` | Returns the smallest element of a descent class. :meth:`descents_composition_last` | Returns the largest element of a descent class. :meth:`bruhat_lequal` | Returns ``True`` if ``p1`` is less or equal to ``p2`` in the Bruhat order. :meth:`permutohedron_lequal` | Returns ``True`` if ``p1`` is less or equal to ``p2`` in the permutohedron order. - :meth:`to_standard` | Returns a standard permutation corresponding to the permutation ``self``. - + :meth:`to_standard` | Returns a standard permutation corresponding to the permutation ``self`` AUTHORS: - Mike Hansen @@ -242,7 +242,7 @@ from sage.structure.list_clone import ClonableArray from sage.structure.global_options import GlobalOptions from sage.interfaces.all import gap -from sage.rings.all import ZZ, Integer, PolynomialRing +from sage.rings.all import ZZ, Integer, PolynomialRing, CC from sage.arith.all import factorial from sage.matrix.all import matrix from sage.combinat.tools import transitive_ideal @@ -260,6 +260,8 @@ from sage.combinat.rsk import RSK, RSK_inverse from sage.combinat.permutation_cython import (left_action_product, right_action_product, left_action_same_n, right_action_same_n) +from sage.modules.free_module_element import zero_vector +from sage.modules.free_module import span class Permutation(CombinatorialElement): r""" @@ -6985,6 +6987,60 @@ def bistochastic_as_sum_of_permutations(M, check = True): value += minimum * CFM(P([x[1]-n+1 for x in matching])) return value + + +def bdd_affine_perm(A): + r""" + Return the bounded affine permutation of a matrix. + + + INPUT: + + -"A"--a matrix with complex entries. + + OUTPUT: + + A partial permutation of length n, where n is the number of columns of A. + The entry in position i is the smallest value j such that + column i is in the span of columns i+1,...,j, over the complex numbers, + where column indices are taken modulo n. + If column i is the zero vector, then the permutation has a fixed point at i. + + EXAMPLES:: + sage: from sage.combinat.permutation import bdd_affine_perm + sage: A = Matrix(CC,[[1,0,0,0],[0,1,0,0]]) + sage: bdd_affine_perm(A) + [5, 6, 3, 4] + + REFERENCES: + + For more on bounded affine permutations, see + + ..[KLS] Allen Knutson, Thomas Lam, and David Speyer. + Positroid Varieties: Juggling and Geometry + Compositio Mathematica, Volume 149, Issue 10, 2013 + arXiv:1111.3660 [math.AG] + """ + n = A.ncols() + z = zero_vector(CC, A.nrows()) + v = A.columns() + perm = [] + for j in range(0,n): + if v[j] == z: + perm.append(j+1) + continue + V = span([z],CC) + for i in range(j+1,j+n+1): + index = i % n + V = V + span([v[index]],CC) + if V == span([z],CC): + continue + if v[j] in V: + perm.append(i+1) + break + S = Permutations(range(1, 2 * n+1),n) + return S(perm) + class StandardPermutations_descents(StandardPermutations_n_abstract): """ From 80381a4d7d319c39f290965f225581bbe31dd44c Mon Sep 17 00:00:00 2001 From: Rachel Karpman Date: Fri, 13 Jan 2017 10:43:41 -0500 Subject: [PATCH 2/4] Added citation for KLS2013 to index, updated reference in permutation --- src/doc/en/reference/references/index.rst | 5 +++++ src/sage/combinat/permutation.py | 5 +---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/doc/en/reference/references/index.rst b/src/doc/en/reference/references/index.rst index b81043df27b..30f2edbf147 100644 --- a/src/doc/en/reference/references/index.rst +++ b/src/doc/en/reference/references/index.rst @@ -866,6 +866,11 @@ REFERENCES: Sci. Publ., Hackensack, NJ, 2008. Preprint version: :arxiv:`0710.1835` +.. [KLS2013] Allen Knutson, Thomas Lam, and David Speyer, + *Positroid Varieties: Juggling and Geometry* + Compositio Mathematica, Volume 149, Issue 10, 2013 + :arXiv:`1111.3660` + .. [KMM2004] Tomasz Kaczynski, Konstantin Mischaikow, and Marian Mrozek, "Computational Homology", Springer-Verlag (2004). diff --git a/src/sage/combinat/permutation.py b/src/sage/combinat/permutation.py index 86275405b9c..bbd5d78b25e 100644 --- a/src/sage/combinat/permutation.py +++ b/src/sage/combinat/permutation.py @@ -7016,10 +7016,7 @@ def bdd_affine_perm(A): For more on bounded affine permutations, see - ..[KLS] Allen Knutson, Thomas Lam, and David Speyer. - Positroid Varieties: Juggling and Geometry - Compositio Mathematica, Volume 149, Issue 10, 2013 - arXiv:1111.3660 [math.AG] + - [KLS2013]_ """ n = A.ncols() z = zero_vector(CC, A.nrows()) From dd59939cc4b1a8bc986665499fc2c11f86f468a0 Mon Sep 17 00:00:00 2001 From: Rachel Karpman Date: Fri, 13 Jan 2017 11:02:19 -0500 Subject: [PATCH 3/4] "fixed white space in documentation" --- src/sage/combinat/permutation.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sage/combinat/permutation.py b/src/sage/combinat/permutation.py index bbd5d78b25e..84673f94e7d 100644 --- a/src/sage/combinat/permutation.py +++ b/src/sage/combinat/permutation.py @@ -6993,7 +6993,6 @@ def bdd_affine_perm(A): r""" Return the bounded affine permutation of a matrix. - INPUT: -"A"--a matrix with complex entries. @@ -7007,6 +7006,7 @@ def bdd_affine_perm(A): If column i is the zero vector, then the permutation has a fixed point at i. EXAMPLES:: + sage: from sage.combinat.permutation import bdd_affine_perm sage: A = Matrix(CC,[[1,0,0,0],[0,1,0,0]]) sage: bdd_affine_perm(A) From 6b8ada7d3daaae384a48e5870e564288b377ffba Mon Sep 17 00:00:00 2001 From: Travis Scrimshaw Date: Sat, 20 May 2017 22:12:51 -0500 Subject: [PATCH 4/4] Some reviewer changes. --- src/doc/en/reference/references/index.rst | 8 ++-- src/sage/combinat/permutation.py | 57 +++++++++++------------ 2 files changed, 32 insertions(+), 33 deletions(-) diff --git a/src/doc/en/reference/references/index.rst b/src/doc/en/reference/references/index.rst index 65e599ee836..badeea30ff9 100644 --- a/src/doc/en/reference/references/index.rst +++ b/src/doc/en/reference/references/index.rst @@ -993,10 +993,10 @@ REFERENCES: Sci. Publ., Hackensack, NJ, 2008. Preprint version: :arxiv:`0710.1835` -.. [KLS2013] Allen Knutson, Thomas Lam, and David Speyer, - *Positroid Varieties: Juggling and Geometry* - Compositio Mathematica, Volume 149, Issue 10, 2013 - :arXiv:`1111.3660` +.. [KLS2013] Allen Knutson, Thomas Lam, and David Speyer. + *Positroid Varieties: Juggling and Geometry* + Compositio Mathematica, **149** (2013), no. 10. + :arXiv:`1111.3660`. .. [KMM2004] Tomasz Kaczynski, Konstantin Mischaikow, and Marian Mrozek, "Computational Homology", Springer-Verlag (2004). diff --git a/src/sage/combinat/permutation.py b/src/sage/combinat/permutation.py index fddbdf12bbd..7d116cf4419 100644 --- a/src/sage/combinat/permutation.py +++ b/src/sage/combinat/permutation.py @@ -182,13 +182,14 @@ :meth:`from_lehmer_code` | Returns the permutation with Lehmer code ``lehmer``. :meth:`from_reduced_word` | Returns the permutation corresponding to the reduced word ``rw``. :meth:`bistochastic_as_sum_of_permutations` | Returns a given bistochastic matrix as a nonnegative linear combination of permutations. - :meth:`bdd_affine_perm` | Returns a partial permutation representing the bounded affine permutation of a matrix + :meth:`bounded_affine_permutation` | Return a partial permutation representing the bounded affine permutation of a matrix. :meth:`descents_composition_list` | Returns a list of all the permutations in a given descent class (i. e., having a given descents composition). :meth:`descents_composition_first` | Returns the smallest element of a descent class. :meth:`descents_composition_last` | Returns the largest element of a descent class. :meth:`bruhat_lequal` | Returns ``True`` if ``p1`` is less or equal to ``p2`` in the Bruhat order. :meth:`permutohedron_lequal` | Returns ``True`` if ``p1`` is less or equal to ``p2`` in the permutohedron order. - :meth:`to_standard` | Returns a standard permutation corresponding to the permutation ``self`` + :meth:`to_standard` | Returns a standard permutation corresponding to the permutation ``self``. + AUTHORS: - Mike Hansen @@ -242,7 +243,7 @@ from sage.structure.list_clone import ClonableArray from sage.structure.global_options import GlobalOptions from sage.interfaces.all import gap -from sage.rings.all import ZZ, Integer, PolynomialRing, CC +from sage.rings.all import ZZ, Integer, PolynomialRing from sage.arith.all import factorial from sage.matrix.all import matrix from sage.combinat.tools import transitive_ideal @@ -260,8 +261,6 @@ from sage.combinat.rsk import RSK, RSK_inverse from sage.combinat.permutation_cython import (left_action_product, right_action_product, left_action_same_n, right_action_same_n) -from sage.modules.free_module_element import zero_vector -from sage.modules.free_module import span class Permutation(CombinatorialElement): r""" @@ -6987,55 +6986,55 @@ def bistochastic_as_sum_of_permutations(M, check = True): value += minimum * CFM(P([x[1]-n+1 for x in matching])) return value - - -def bdd_affine_perm(A): + +def bounded_affine_permutation(A): r""" Return the bounded affine permutation of a matrix. - INPUT: - - -"A"--a matrix with complex entries. + The *bounded affine permutation* of a matrix `A` with entries in `R` + is a partial permutation of length `n`, where `n` is the number of + columns of `A`. The entry in position `i` is the smallest value `j` + such that column `i` is in the span of columns `i+1, \ldots, j`, + over `R`, where column indices are taken modulo `n`. + If column `i` is the zero vector, then the permutation has a + fixed point at `i`. - OUTPUT: + INPUT: - A partial permutation of length n, where n is the number of columns of A. - The entry in position i is the smallest value j such that - column i is in the span of columns i+1,...,j, over the complex numbers, - where column indices are taken modulo n. - If column i is the zero vector, then the permutation has a fixed point at i. + - ``A`` -- matrix with complex entries EXAMPLES:: - sage: from sage.combinat.permutation import bdd_affine_perm - sage: A = Matrix(CC,[[1,0,0,0],[0,1,0,0]]) - sage: bdd_affine_perm(A) + sage: from sage.combinat.permutation import bounded_affine_permutation + sage: A = Matrix(QQ, [[1,0,0,0], [0,1,0,0]]) + sage: bounded_affine_permutation(A) [5, 6, 3, 4] REFERENCES: - For more on bounded affine permutations, see - - [KLS2013]_ """ n = A.ncols() - z = zero_vector(CC, A.nrows()) + R = A.base_ring() + from sage.modules.free_module import FreeModule + from sage.modules.free_module import span + z = FreeModule(R, A.nrows()).zero() v = A.columns() perm = [] - for j in range(0,n): + for j in range(n): if v[j] == z: perm.append(j+1) continue - V = span([z],CC) - for i in range(j+1,j+n+1): + V = span([z], R) + for i in range(j+1, j+n+1): index = i % n - V = V + span([v[index]],CC) - if V == span([z],CC): + V = V + span([v[index]], R) + if V == span([z], R): continue if v[j] in V: perm.append(i+1) break - S = Permutations(range(1, 2 * n+1),n) + S = Permutations(2*n, n) return S(perm)