Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Commit

Permalink
inital commit for adding bdd_affine_perm method in permutation
Browse files Browse the repository at this point in the history
  • Loading branch information
rkarpman committed Jan 13, 2017
1 parent a0ef507 commit 5ff1792
Showing 1 changed file with 59 additions and 3 deletions.
62 changes: 59 additions & 3 deletions src/sage/combinat/permutation.py
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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"""
Expand Down Expand Up @@ -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):
"""
Expand Down

0 comments on commit 5ff1792

Please sign in to comment.