Ticket #7412: trac_7412-lehmer.patch

File trac_7412-lehmer.patch, 1.1 KB (added by ylchapuy, 12 years ago)

need #7011

  • sage/combinat/permutation.py

    # HG changeset patch
    # User Yann Laigle-Chapuy <yannlaiglechapuy@gmail.com>
    # Date 1257701931 -3600
    # Node ID c2c63ff6690c9665494129a1b83f4982617b12ad
    # Parent  ae8ee6fb3b129d52117358037c6f19bf07842d25
    bug in from_lehmer_code
    
    diff -r ae8ee6fb3b12 -r c2c63ff6690c sage/combinat/permutation.py
    a b  
    30553055    n = len(lehmer)
    30563056    if n==0:
    30573057        return Permutation([])
    3058     perm = [None] * n
    3059    
    3060     #Convert the factoradic to a permutation
    3061     temp = [None] * n
    3062     for i in range(n):
    3063         lehmer[i] += 1
    3064         temp[i] = lehmer[i]
    3065 
     3058
     3059    perm = map(lambda x:x+1, lehmer)
    30663060    perm[n-1] = 1
    30673061    for i in reversed(range(n-1)):
    3068         perm[i] = temp[i]
     3062        pi = perm[i]
    30693063        for j in range(i+1, n):
    3070             if perm[j] >= perm[i]:
     3064            if perm[j] >= pi:
    30713065                perm[j] += 1
    30723066
    3073     return Permutation([ p for p in perm ])
     3067    return Permutation(perm)
    30743068
    30753069def from_reduced_word(rw):
    30763070    r"""