Ticket #11563: trac_11563-lrcalc_standard_package-nt.patch

File trac_11563-lrcalc_standard_package-nt.patch, 13.2 KB (added by nthiery, 11 years ago)
  • doc/en/reference/libs.rst

    # HG changeset patch
    # User Nicolas M. Thiery <nthiery@users.sf.net>
    # Date 1340950155 -7200
    # Node ID 4af12a5acbb3948b933d4e5b64ddbf4f043a523c
    # Parent  5bea4a65d7d91816a8d94ceb325b4e9ba694de59
    #11563: lrcalc as a standard spkg
    
    diff --git a/doc/en/reference/libs.rst b/doc/en/reference/libs.rst
    a b to be aware of the modules described in  
    2727   
    2828   sage/libs/flint/fmpz_poly
    2929   sage/libs/libecm
     30   sage/libs/lrcalc/lrcalc
    3031   sage/libs/pari/gen
    3132   sage/libs/ntl/all
    3233   sage/libs/mwrank/all
  • sage/libs/lrcalc/lrcalc.pyx

    diff --git a/sage/libs/lrcalc/lrcalc.pyx b/sage/libs/lrcalc/lrcalc.pyx
    a b The following describes the Sage interfa 
    1616
    1717EXAMPLES::
    1818
    19     sage: import sage.libs.lrcalc.lrcalc as lrcalc        #optional - lrcalc
     19    sage: import sage.libs.lrcalc.lrcalc as lrcalc
    2020
    2121Compute a single Littlewood-Richardson coefficient::
    2222
    23     sage: lrcalc.lrcoef([3,2,1],[2,1],[2,1])              #optional - lrcalc
     23    sage: lrcalc.lrcoef([3,2,1],[2,1],[2,1])
    2424    2
    2525
    2626Compute a product of Schur functions; return the coefficients in the
    2727Schur expansion::
    2828
    29     sage: lrcalc.mult([2,1], [2,1])                       #optional - lrcalc
     29    sage: lrcalc.mult([2,1], [2,1])
    3030    {[3, 3]: 1, [4, 2]: 1, [3, 1, 1, 1]: 1, [4, 1, 1]: 1, [2, 2, 2]: 1, [3, 2, 1]: 2, [2, 2, 1, 1]: 1}
    3131
    3232Same product, but include only partitions with at most 3 rows.  This
    3333corresponds to computing in the representation ring of gl(3)::
    3434
    35     sage: lrcalc.mult([2,1], [2,1], 3)                    #optional - lrcalc
     35    sage: lrcalc.mult([2,1], [2,1], 3)
    3636    {[3, 3]: 1, [4, 2]: 1, [3, 2, 1]: 2, [2, 2, 2]: 1, [4, 1, 1]: 1}
    3737
    3838We can also compute the fusion product, here for sl(3) and level 2::
    3939
    40     sage: lrcalc.mult([3,2,1], [3,2,1], 3,2)              #optional - lrcalc
     40    sage: lrcalc.mult([3,2,1], [3,2,1], 3,2)
    4141    {[4, 4, 4]: 1, [5, 4, 3]: 1}
    4242
    4343Compute the expansion of a skew Schur function::
    4444
    45     sage: lrcalc.skew([3,2,1],[2,1])                      #optional - lrcalc
     45    sage: lrcalc.skew([3,2,1],[2,1])
    4646    {[3]: 1, [1, 1, 1]: 1, [2, 1]: 2}
    4747
    4848Compute the coproduct of a Schur function::
    4949
    50     sage: lrcalc.coprod([3,2,1])                          #optional - lrcalc
     50    sage: lrcalc.coprod([3,2,1])
    5151    {([2, 1, 1], [1, 1]): 1, ([3, 1, 1], [1]): 1, ([2, 1], [3]): 1, ([2, 1, 1], [2]): 1, ([3, 2, 1], []): 1,
    5252    ([3, 1], [2]): 1, ([3, 2], [1]): 1, ([2, 1], [2, 1]): 2, ([1, 1, 1], [2, 1]): 1, ([2, 2], [2]): 1, ([2, 2, 1], [1]): 1,
    5353    ([2, 2], [1, 1]): 1, ([3, 1], [1, 1]): 1}
    5454
    5555Multiply two Schubert polynomials::
    5656
    57     sage: lrcalc.mult_schubert([4,2,1,3], [1,4,2,5,3])    #optional - lrcalc
     57    sage: lrcalc.mult_schubert([4,2,1,3], [1,4,2,5,3])
    5858    {[5, 4, 1, 2, 3]: 1, [5, 3, 1, 4, 2]: 1, [4, 5, 1, 3, 2]: 1, [6, 2, 1, 4, 3, 5]: 1}
    5959
    6060Same product, but include only permutations of 5 elements in the result.
    6161This corresponds to computing in the cohomology ring of Fl(5)::
    6262
    63     sage: lrcalc.mult_schubert([4,2,1,3], [1,4,2,5,3], 5) #optional - lrcalc
     63    sage: lrcalc.mult_schubert([4,2,1,3], [1,4,2,5,3], 5)
    6464    {[5, 4, 1, 2, 3]: 1, [5, 3, 1, 4, 2]: 1, [4, 5, 1, 3, 2]: 1}
    6565
    6666List all Littlewood-Richardson tableaux of skew shape `\mu/\nu`; in
    6767this example `\mu=[3,2,1]` and `\nu=[2,1]`. Specifying a third entry
    6868`maxrows` restricts the alphabet to `\{1,2,\ldots,maxrows\}`::
    6969
    70     sage: list(lrcalc.lrskew([3,2,1],[2,1]))              #optional - lrcalc
     70    sage: list(lrcalc.lrskew([3,2,1],[2,1]))
    7171    [[[None, None, 1], [None, 1], [1]], [[None, None, 1], [None, 1], [2]],
    7272    [[None, None, 1], [None, 2], [1]], [[None, None, 1], [None, 2], [3]]]
    7373
    74     sage: list(lrcalc.lrskew([3,2,1],[2,1],maxrows=2))            #optional - lrcalc
     74    sage: list(lrcalc.lrskew([3,2,1],[2,1],maxrows=2))
    7575    [[[None, None, 1], [None, 1], [1]], [[None, None, 1], [None, 1], [2]], [[None, None, 1], [None, 2], [1]]]
    7676
    7777.. todo:: use this library in the :class:`SymmetricFunctions` code, to
    cdef vector* iterable_to_vector(it): 
    170170
    171171    TESTS::
    172172
    173         sage: from sage.libs.lrcalc.lrcalc import test_iterable_to_vector           #optional -lrcalc
    174         sage: x = test_iterable_to_vector(Partition([3,2,1])); x   #indirect doctest optional -lrcalc
     173        sage: from sage.libs.lrcalc.lrcalc import test_iterable_to_vector
     174        sage: x = test_iterable_to_vector(Partition([3,2,1])); x   #indirect doctest
    175175        [3, 2, 1]
    176176    """
    177177    cdef vector* v
    cdef vector_to_list(vector *v): 
    188188
    189189    TESTS::
    190190
    191         sage: from sage.libs.lrcalc.lrcalc import test_iterable_to_vector #optional -lrcalc
    192         sage: x = test_iterable_to_vector([]); x         #indirect doctest optional -lrcalc
     191        sage: from sage.libs.lrcalc.lrcalc import test_iterable_to_vector
     192        sage: x = test_iterable_to_vector([]); x         #indirect doctest
    193193        []
    194194    """
    195195    cdef int i, n
    def test_iterable_to_vector(it): 
    206206
    207207    EXAMPLES::
    208208
    209         sage: from sage.libs.lrcalc.lrcalc import test_iterable_to_vector #optional -lrcalc
    210         sage: x = test_iterable_to_vector([3,2,1]); x                     #optional -lrcalc
     209        sage: from sage.libs.lrcalc.lrcalc import test_iterable_to_vector
     210        sage: x = test_iterable_to_vector([3,2,1]); x
    211211        [3, 2, 1]
    212212    """
    213213    cdef vector *v = iterable_to_vector(it)
    cdef skewtab_to_SkewTableau(skewtab *st) 
    222222
    223223    TESTS::
    224224
    225         sage: from sage.libs.lrcalc.lrcalc import test_skewtab_to_SkewTableau #optional -lrcalc
    226         sage: test_skewtab_to_SkewTableau([],[])                              #optional -lrcalc
     225        sage: from sage.libs.lrcalc.lrcalc import test_skewtab_to_SkewTableau
     226        sage: test_skewtab_to_SkewTableau([],[])
    227227        []
    228228    """
    229229    inner = vector_to_list(st.inner)
    def test_skewtab_to_SkewTableau(outer, i 
    241241
    242242    EXAMPLES::
    243243
    244         sage: from sage.libs.lrcalc.lrcalc import test_skewtab_to_SkewTableau #optional -lrcalc
    245         sage: test_skewtab_to_SkewTableau([3,2,1],[])                         #optional -lrcalc
     244        sage: from sage.libs.lrcalc.lrcalc import test_skewtab_to_SkewTableau
     245        sage: test_skewtab_to_SkewTableau([3,2,1],[])
    246246        [[1, 1, 1], [2, 2], [3]]
    247         sage: test_skewtab_to_SkewTableau([4,3,2,1],[1,1]).pp()               #optional -lrcalc
     247        sage: test_skewtab_to_SkewTableau([4,3,2,1],[1,1]).pp()
    248248        .  1  1  1
    249249        .  2  2
    250250        1  3
    cdef sf_hashtab_to_dict(hashtab *ht): 
    262262
    263263    EXAMPLES::
    264264
    265         sage: from sage.libs.lrcalc.lrcalc import mult              #optional - lrcalc
    266         sage: sorted(mult([1],[1]).items())        #indirect doctest optional - lrcalc
     265        sage: from sage.libs.lrcalc.lrcalc import mult
     266        sage: sorted(mult([1],[1]).items())        #indirect doctest
    267267        [([1, 1], 1), ([2], 1)]
    268         sage: assert isinstance(mult([1],[1]),dict)#indirect doctest optional - lrcalc
     268        sage: assert isinstance(mult([1],[1]),dict)#indirect doctest
    269269    """
    270270    cdef hash_itr itr
    271271    result = {}
    cdef schubert_hashtab_to_dict(hashtab *h 
    283283
    284284    EXAMPLES::
    285285
    286         sage: from sage.libs.lrcalc.lrcalc import mult_schubert     #optional - lrcalc
    287         sage: mult_schubert([3,2,1], [1,2,3])      #indirect doctest optional - lrcalc
     286        sage: from sage.libs.lrcalc.lrcalc import mult_schubert
     287        sage: mult_schubert([3,2,1], [1,2,3])      #indirect doctest
    288288        {[3, 2, 1]: 1}
    289289    """
    290290    cdef hash_itr itr
    cdef vp_hashtab_to_dict(hashtab *ht): 
    304304
    305305    EXAMPLES::
    306306
    307         sage: from sage.libs.lrcalc.lrcalc import coprod           #optional - lrcalc
    308         sage: coprod([1])      #indirect doctest optional - lrcalc
     307        sage: from sage.libs.lrcalc.lrcalc import coprod
     308        sage: coprod([1])      #indirect doctest
    309309        {([1], []): 1}
    310310    """
    311311    cdef hash_itr itr
    def lrcoef_unsafe(outer, inner1, inner2) 
    343343
    344344    EXAMPLES::
    345345
    346         sage: from sage.libs.lrcalc.lrcalc import lrcoef_unsafe #optional - lrcalc
    347         sage: lrcoef_unsafe([3,2,1], [2,1], [2,1])              #optional - lrcalc
     346        sage: from sage.libs.lrcalc.lrcalc import lrcoef_unsafe
     347        sage: lrcoef_unsafe([3,2,1], [2,1], [2,1])
    348348        2
    349         sage: lrcoef_unsafe([3,3], [2,1], [2,1])                #optional - lrcalc
     349        sage: lrcoef_unsafe([3,3], [2,1], [2,1])
    350350        1
    351         sage: lrcoef_unsafe([2,1,1,1,1], [2,1], [2,1])          #optional - lrcalc
     351        sage: lrcoef_unsafe([2,1,1,1,1], [2,1], [2,1])
    352352        0
    353353    """
    354354    cdef long long result
    def lrcoef(outer, inner1, inner2): 
    383383
    384384    EXAMPLES::
    385385
    386         sage: from sage.libs.lrcalc.lrcalc import lrcoef   #optional - lrcalc
    387         sage: lrcoef([3,2,1], [2,1], [2,1])                #optional - lrcalc
     386        sage: from sage.libs.lrcalc.lrcalc import lrcoef
     387        sage: lrcoef([3,2,1], [2,1], [2,1])
    388388        2
    389         sage: lrcoef([3,3], [2,1], [2,1])                  #optional - lrcalc
     389        sage: lrcoef([3,3], [2,1], [2,1])
    390390        1
    391         sage: lrcoef([2,1,1,1,1], [2,1], [2,1])            #optional - lrcalc
     391        sage: lrcoef([2,1,1,1,1], [2,1], [2,1])
    392392        0
    393393
    394394    """
    def mult(part1, part2, maxrows=None, lev 
    420420
    421421    EXAMPLES::
    422422
    423         sage: from sage.libs.lrcalc.lrcalc import mult    #optional - lrcalc
    424         sage: mult([2],[])                                #optional - lrcalc
     423        sage: from sage.libs.lrcalc.lrcalc import mult
     424        sage: mult([2],[])
    425425        {[2]: 1}
    426         sage: sorted(mult([2],[2]).items())               #optional - lrcalc
     426        sage: sorted(mult([2],[2]).items())
    427427        [([2, 2], 1), ([3, 1], 1), ([4], 1)]
    428         sage: sorted(mult([2,1],[2,1]).items())           #optional - lrcalc
     428        sage: sorted(mult([2,1],[2,1]).items())
    429429        [([2, 2, 1, 1], 1), ([2, 2, 2], 1), ([3, 1, 1, 1], 1), ([3, 2, 1], 2), ([3, 3], 1), ([4, 1, 1], 1), ([4, 2], 1)]
    430         sage: sorted(mult([2,1],[2,1],maxrows=2).items()) #optional - lrcalc
     430        sage: sorted(mult([2,1],[2,1],maxrows=2).items())
    431431        [([3, 3], 1), ([4, 2], 1)]
    432         sage: mult([2,1],[3,2,1],3)                       #optional - lrcalc
     432        sage: mult([2,1],[3,2,1],3)
    433433        {[3, 3, 3]: 1, [5, 2, 2]: 1, [5, 3, 1]: 1, [4, 4, 1]: 1, [4, 3, 2]: 2}
    434         sage: mult([2,1],[2,1],3,3)                       #optional - lrcalc
     434        sage: mult([2,1],[2,1],3,3)
    435435        {[3, 3]: 1, [3, 2, 1]: 2, [2, 2, 2]: 1, [4, 1, 1]: 1}
    436         sage: mult([2,1],[2,1],None,3)                    #optional - lrcalc
     436        sage: mult([2,1],[2,1],None,3)
    437437        Traceback (most recent call last):
    438438        ...
    439439        ValueError: maxrows needs to be specified if you specify the level
    def skew(outer, inner, maxrows=0): 
    473473
    474474    EXAMPLES::
    475475
    476         sage: from sage.libs.lrcalc.lrcalc import skew  #optional - lrcalc
    477         sage: sorted(skew([2,1],[1]).items())           #optional - lrcalc
     476        sage: from sage.libs.lrcalc.lrcalc import skew
     477        sage: sorted(skew([2,1],[1]).items())
    478478        [([1, 1], 1), ([2], 1)]
    479479    """
    480480    cdef vector* v1 = iterable_to_vector(outer)
    def coprod(part, all=0): 
    507507
    508508    EXAMPLES::
    509509
    510         sage: from sage.libs.lrcalc.lrcalc import coprod  #optional - lrcalc
    511         sage: sorted(coprod([2,1]).items())               #optional - lrcalc
     510        sage: from sage.libs.lrcalc.lrcalc import coprod
     511        sage: sorted(coprod([2,1]).items())
    512512        [(([1, 1], [1]), 1), (([2], [1]), 1), (([2, 1], []), 1)]
    513513    """
    514514    cdef vector* v1 = iterable_to_vector(part)
    def mult_schubert(w1, w2, rank=0): 
    539539
    540540    EXAMPLES::
    541541
    542         sage: from sage.libs.lrcalc.lrcalc import mult_schubert          #optional - lrcalc
    543         sage: result = mult_schubert([3, 1, 5, 2, 4], [3, 5, 2, 1, 4])   #optional - lrcalc
    544         sage: sorted(result.items())                                     #optional - lrcalc
     542        sage: from sage.libs.lrcalc.lrcalc import mult_schubert
     543        sage: result = mult_schubert([3, 1, 5, 2, 4], [3, 5, 2, 1, 4])
     544        sage: sorted(result.items())
    545545        [([5, 4, 6, 1, 2, 3], 1), ([5, 6, 3, 1, 2, 4], 1),
    546546         ([5, 7, 2, 1, 3, 4, 6], 1), ([6, 3, 5, 1, 2, 4], 1),
    547547         ([6, 4, 3, 1, 2, 5], 1), ([6, 5, 2, 1, 3, 4], 1),
    def lrskew(outer, inner, weight=None, ma 
    576576
    577577    EXAMPLES::
    578578
    579         sage: from sage.libs.lrcalc.lrcalc import lrskew  #optional - lrcalc
    580         sage: for st in lrskew([3,2,1],[2]):              #optional - lrcalc
     579        sage: from sage.libs.lrcalc.lrcalc import lrskew
     580        sage: for st in lrskew([3,2,1],[2]):
    581581        ...       st.pp()
    582582        .  .  1
    583583        1  1
    def lrskew(outer, inner, weight=None, ma 
    589589        1  2
    590590        3
    591591
    592         sage: for st in lrskew([3,2,1],[2], maxrows=2):   #optional - lrcalc
     592        sage: for st in lrskew([3,2,1],[2], maxrows=2):
    593593        ...       st.pp()
    594594        .  .  1
    595595        1  1
    def lrskew(outer, inner, weight=None, ma 
    598598        1  2
    599599        2
    600600
    601         sage: lrskew([3,2,1],[2], weight=[3,1])           #optional - lrcalc
     601        sage: lrskew([3,2,1],[2], weight=[3,1])
    602602        [[[None, None, 1], [1, 1], [2]]]
    603603    """
    604604    cdef vector* o = iterable_to_vector(outer)