Ticket #11563: trac_11563-lrcalc_standard_package-nt.patch
File trac_11563-lrcalc_standard_package-nt.patch, 13.2 KB (added by , 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 27 27 28 28 sage/libs/flint/fmpz_poly 29 29 sage/libs/libecm 30 sage/libs/lrcalc/lrcalc 30 31 sage/libs/pari/gen 31 32 sage/libs/ntl/all 32 33 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 16 16 17 17 EXAMPLES:: 18 18 19 sage: import sage.libs.lrcalc.lrcalc as lrcalc #optional - lrcalc19 sage: import sage.libs.lrcalc.lrcalc as lrcalc 20 20 21 21 Compute a single Littlewood-Richardson coefficient:: 22 22 23 sage: lrcalc.lrcoef([3,2,1],[2,1],[2,1]) #optional - lrcalc23 sage: lrcalc.lrcoef([3,2,1],[2,1],[2,1]) 24 24 2 25 25 26 26 Compute a product of Schur functions; return the coefficients in the 27 27 Schur expansion:: 28 28 29 sage: lrcalc.mult([2,1], [2,1]) #optional - lrcalc29 sage: lrcalc.mult([2,1], [2,1]) 30 30 {[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} 31 31 32 32 Same product, but include only partitions with at most 3 rows. This 33 33 corresponds to computing in the representation ring of gl(3):: 34 34 35 sage: lrcalc.mult([2,1], [2,1], 3) #optional - lrcalc35 sage: lrcalc.mult([2,1], [2,1], 3) 36 36 {[3, 3]: 1, [4, 2]: 1, [3, 2, 1]: 2, [2, 2, 2]: 1, [4, 1, 1]: 1} 37 37 38 38 We can also compute the fusion product, here for sl(3) and level 2:: 39 39 40 sage: lrcalc.mult([3,2,1], [3,2,1], 3,2) #optional - lrcalc40 sage: lrcalc.mult([3,2,1], [3,2,1], 3,2) 41 41 {[4, 4, 4]: 1, [5, 4, 3]: 1} 42 42 43 43 Compute the expansion of a skew Schur function:: 44 44 45 sage: lrcalc.skew([3,2,1],[2,1]) #optional - lrcalc45 sage: lrcalc.skew([3,2,1],[2,1]) 46 46 {[3]: 1, [1, 1, 1]: 1, [2, 1]: 2} 47 47 48 48 Compute the coproduct of a Schur function:: 49 49 50 sage: lrcalc.coprod([3,2,1]) #optional - lrcalc50 sage: lrcalc.coprod([3,2,1]) 51 51 {([2, 1, 1], [1, 1]): 1, ([3, 1, 1], [1]): 1, ([2, 1], [3]): 1, ([2, 1, 1], [2]): 1, ([3, 2, 1], []): 1, 52 52 ([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, 53 53 ([2, 2], [1, 1]): 1, ([3, 1], [1, 1]): 1} 54 54 55 55 Multiply two Schubert polynomials:: 56 56 57 sage: lrcalc.mult_schubert([4,2,1,3], [1,4,2,5,3]) #optional - lrcalc57 sage: lrcalc.mult_schubert([4,2,1,3], [1,4,2,5,3]) 58 58 {[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} 59 59 60 60 Same product, but include only permutations of 5 elements in the result. 61 61 This corresponds to computing in the cohomology ring of Fl(5):: 62 62 63 sage: lrcalc.mult_schubert([4,2,1,3], [1,4,2,5,3], 5) #optional - lrcalc63 sage: lrcalc.mult_schubert([4,2,1,3], [1,4,2,5,3], 5) 64 64 {[5, 4, 1, 2, 3]: 1, [5, 3, 1, 4, 2]: 1, [4, 5, 1, 3, 2]: 1} 65 65 66 66 List all Littlewood-Richardson tableaux of skew shape `\mu/\nu`; in 67 67 this example `\mu=[3,2,1]` and `\nu=[2,1]`. Specifying a third entry 68 68 `maxrows` restricts the alphabet to `\{1,2,\ldots,maxrows\}`:: 69 69 70 sage: list(lrcalc.lrskew([3,2,1],[2,1])) #optional - lrcalc70 sage: list(lrcalc.lrskew([3,2,1],[2,1])) 71 71 [[[None, None, 1], [None, 1], [1]], [[None, None, 1], [None, 1], [2]], 72 72 [[None, None, 1], [None, 2], [1]], [[None, None, 1], [None, 2], [3]]] 73 73 74 sage: list(lrcalc.lrskew([3,2,1],[2,1],maxrows=2)) #optional - lrcalc74 sage: list(lrcalc.lrskew([3,2,1],[2,1],maxrows=2)) 75 75 [[[None, None, 1], [None, 1], [1]], [[None, None, 1], [None, 1], [2]], [[None, None, 1], [None, 2], [1]]] 76 76 77 77 .. todo:: use this library in the :class:`SymmetricFunctions` code, to … … cdef vector* iterable_to_vector(it): 170 170 171 171 TESTS:: 172 172 173 sage: from sage.libs.lrcalc.lrcalc import test_iterable_to_vector #optional -lrcalc174 sage: x = test_iterable_to_vector(Partition([3,2,1])); x #indirect doctest optional -lrcalc173 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 175 175 [3, 2, 1] 176 176 """ 177 177 cdef vector* v … … cdef vector_to_list(vector *v): 188 188 189 189 TESTS:: 190 190 191 sage: from sage.libs.lrcalc.lrcalc import test_iterable_to_vector #optional -lrcalc192 sage: x = test_iterable_to_vector([]); x #indirect doctest optional -lrcalc191 sage: from sage.libs.lrcalc.lrcalc import test_iterable_to_vector 192 sage: x = test_iterable_to_vector([]); x #indirect doctest 193 193 [] 194 194 """ 195 195 cdef int i, n … … def test_iterable_to_vector(it): 206 206 207 207 EXAMPLES:: 208 208 209 sage: from sage.libs.lrcalc.lrcalc import test_iterable_to_vector #optional -lrcalc210 sage: x = test_iterable_to_vector([3,2,1]); x #optional -lrcalc209 sage: from sage.libs.lrcalc.lrcalc import test_iterable_to_vector 210 sage: x = test_iterable_to_vector([3,2,1]); x 211 211 [3, 2, 1] 212 212 """ 213 213 cdef vector *v = iterable_to_vector(it) … … cdef skewtab_to_SkewTableau(skewtab *st) 222 222 223 223 TESTS:: 224 224 225 sage: from sage.libs.lrcalc.lrcalc import test_skewtab_to_SkewTableau #optional -lrcalc226 sage: test_skewtab_to_SkewTableau([],[]) #optional -lrcalc225 sage: from sage.libs.lrcalc.lrcalc import test_skewtab_to_SkewTableau 226 sage: test_skewtab_to_SkewTableau([],[]) 227 227 [] 228 228 """ 229 229 inner = vector_to_list(st.inner) … … def test_skewtab_to_SkewTableau(outer, i 241 241 242 242 EXAMPLES:: 243 243 244 sage: from sage.libs.lrcalc.lrcalc import test_skewtab_to_SkewTableau #optional -lrcalc245 sage: test_skewtab_to_SkewTableau([3,2,1],[]) #optional -lrcalc244 sage: from sage.libs.lrcalc.lrcalc import test_skewtab_to_SkewTableau 245 sage: test_skewtab_to_SkewTableau([3,2,1],[]) 246 246 [[1, 1, 1], [2, 2], [3]] 247 sage: test_skewtab_to_SkewTableau([4,3,2,1],[1,1]).pp() #optional -lrcalc247 sage: test_skewtab_to_SkewTableau([4,3,2,1],[1,1]).pp() 248 248 . 1 1 1 249 249 . 2 2 250 250 1 3 … … cdef sf_hashtab_to_dict(hashtab *ht): 262 262 263 263 EXAMPLES:: 264 264 265 sage: from sage.libs.lrcalc.lrcalc import mult #optional - lrcalc266 sage: sorted(mult([1],[1]).items()) #indirect doctest optional - lrcalc265 sage: from sage.libs.lrcalc.lrcalc import mult 266 sage: sorted(mult([1],[1]).items()) #indirect doctest 267 267 [([1, 1], 1), ([2], 1)] 268 sage: assert isinstance(mult([1],[1]),dict)#indirect doctest optional - lrcalc268 sage: assert isinstance(mult([1],[1]),dict)#indirect doctest 269 269 """ 270 270 cdef hash_itr itr 271 271 result = {} … … cdef schubert_hashtab_to_dict(hashtab *h 283 283 284 284 EXAMPLES:: 285 285 286 sage: from sage.libs.lrcalc.lrcalc import mult_schubert #optional - lrcalc287 sage: mult_schubert([3,2,1], [1,2,3]) #indirect doctest optional - lrcalc286 sage: from sage.libs.lrcalc.lrcalc import mult_schubert 287 sage: mult_schubert([3,2,1], [1,2,3]) #indirect doctest 288 288 {[3, 2, 1]: 1} 289 289 """ 290 290 cdef hash_itr itr … … cdef vp_hashtab_to_dict(hashtab *ht): 304 304 305 305 EXAMPLES:: 306 306 307 sage: from sage.libs.lrcalc.lrcalc import coprod #optional - lrcalc308 sage: coprod([1]) #indirect doctest optional - lrcalc307 sage: from sage.libs.lrcalc.lrcalc import coprod 308 sage: coprod([1]) #indirect doctest 309 309 {([1], []): 1} 310 310 """ 311 311 cdef hash_itr itr … … def lrcoef_unsafe(outer, inner1, inner2) 343 343 344 344 EXAMPLES:: 345 345 346 sage: from sage.libs.lrcalc.lrcalc import lrcoef_unsafe #optional - lrcalc347 sage: lrcoef_unsafe([3,2,1], [2,1], [2,1]) #optional - lrcalc346 sage: from sage.libs.lrcalc.lrcalc import lrcoef_unsafe 347 sage: lrcoef_unsafe([3,2,1], [2,1], [2,1]) 348 348 2 349 sage: lrcoef_unsafe([3,3], [2,1], [2,1]) #optional - lrcalc349 sage: lrcoef_unsafe([3,3], [2,1], [2,1]) 350 350 1 351 sage: lrcoef_unsafe([2,1,1,1,1], [2,1], [2,1]) #optional - lrcalc351 sage: lrcoef_unsafe([2,1,1,1,1], [2,1], [2,1]) 352 352 0 353 353 """ 354 354 cdef long long result … … def lrcoef(outer, inner1, inner2): 383 383 384 384 EXAMPLES:: 385 385 386 sage: from sage.libs.lrcalc.lrcalc import lrcoef #optional - lrcalc387 sage: lrcoef([3,2,1], [2,1], [2,1]) #optional - lrcalc386 sage: from sage.libs.lrcalc.lrcalc import lrcoef 387 sage: lrcoef([3,2,1], [2,1], [2,1]) 388 388 2 389 sage: lrcoef([3,3], [2,1], [2,1]) #optional - lrcalc389 sage: lrcoef([3,3], [2,1], [2,1]) 390 390 1 391 sage: lrcoef([2,1,1,1,1], [2,1], [2,1]) #optional - lrcalc391 sage: lrcoef([2,1,1,1,1], [2,1], [2,1]) 392 392 0 393 393 394 394 """ … … def mult(part1, part2, maxrows=None, lev 420 420 421 421 EXAMPLES:: 422 422 423 sage: from sage.libs.lrcalc.lrcalc import mult #optional - lrcalc424 sage: mult([2],[]) #optional - lrcalc423 sage: from sage.libs.lrcalc.lrcalc import mult 424 sage: mult([2],[]) 425 425 {[2]: 1} 426 sage: sorted(mult([2],[2]).items()) #optional - lrcalc426 sage: sorted(mult([2],[2]).items()) 427 427 [([2, 2], 1), ([3, 1], 1), ([4], 1)] 428 sage: sorted(mult([2,1],[2,1]).items()) #optional - lrcalc428 sage: sorted(mult([2,1],[2,1]).items()) 429 429 [([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 - lrcalc430 sage: sorted(mult([2,1],[2,1],maxrows=2).items()) 431 431 [([3, 3], 1), ([4, 2], 1)] 432 sage: mult([2,1],[3,2,1],3) #optional - lrcalc432 sage: mult([2,1],[3,2,1],3) 433 433 {[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 - lrcalc434 sage: mult([2,1],[2,1],3,3) 435 435 {[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 - lrcalc436 sage: mult([2,1],[2,1],None,3) 437 437 Traceback (most recent call last): 438 438 ... 439 439 ValueError: maxrows needs to be specified if you specify the level … … def skew(outer, inner, maxrows=0): 473 473 474 474 EXAMPLES:: 475 475 476 sage: from sage.libs.lrcalc.lrcalc import skew #optional - lrcalc477 sage: sorted(skew([2,1],[1]).items()) #optional - lrcalc476 sage: from sage.libs.lrcalc.lrcalc import skew 477 sage: sorted(skew([2,1],[1]).items()) 478 478 [([1, 1], 1), ([2], 1)] 479 479 """ 480 480 cdef vector* v1 = iterable_to_vector(outer) … … def coprod(part, all=0): 507 507 508 508 EXAMPLES:: 509 509 510 sage: from sage.libs.lrcalc.lrcalc import coprod #optional - lrcalc511 sage: sorted(coprod([2,1]).items()) #optional - lrcalc510 sage: from sage.libs.lrcalc.lrcalc import coprod 511 sage: sorted(coprod([2,1]).items()) 512 512 [(([1, 1], [1]), 1), (([2], [1]), 1), (([2, 1], []), 1)] 513 513 """ 514 514 cdef vector* v1 = iterable_to_vector(part) … … def mult_schubert(w1, w2, rank=0): 539 539 540 540 EXAMPLES:: 541 541 542 sage: from sage.libs.lrcalc.lrcalc import mult_schubert #optional - lrcalc543 sage: result = mult_schubert([3, 1, 5, 2, 4], [3, 5, 2, 1, 4]) #optional - lrcalc544 sage: sorted(result.items()) #optional - lrcalc542 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()) 545 545 [([5, 4, 6, 1, 2, 3], 1), ([5, 6, 3, 1, 2, 4], 1), 546 546 ([5, 7, 2, 1, 3, 4, 6], 1), ([6, 3, 5, 1, 2, 4], 1), 547 547 ([6, 4, 3, 1, 2, 5], 1), ([6, 5, 2, 1, 3, 4], 1), … … def lrskew(outer, inner, weight=None, ma 576 576 577 577 EXAMPLES:: 578 578 579 sage: from sage.libs.lrcalc.lrcalc import lrskew #optional - lrcalc580 sage: for st in lrskew([3,2,1],[2]): #optional - lrcalc579 sage: from sage.libs.lrcalc.lrcalc import lrskew 580 sage: for st in lrskew([3,2,1],[2]): 581 581 ... st.pp() 582 582 . . 1 583 583 1 1 … … def lrskew(outer, inner, weight=None, ma 589 589 1 2 590 590 3 591 591 592 sage: for st in lrskew([3,2,1],[2], maxrows=2): #optional - lrcalc592 sage: for st in lrskew([3,2,1],[2], maxrows=2): 593 593 ... st.pp() 594 594 . . 1 595 595 1 1 … … def lrskew(outer, inner, weight=None, ma 598 598 1 2 599 599 2 600 600 601 sage: lrskew([3,2,1],[2], weight=[3,1]) #optional - lrcalc601 sage: lrskew([3,2,1],[2], weight=[3,1]) 602 602 [[[None, None, 1], [1, 1], [2]]] 603 603 """ 604 604 cdef vector* o = iterable_to_vector(outer)