Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
sagemath
GitHub Repository: sagemath/sagelib
Path: blob/master/sage/libs/lrcalc/lrcalc.pyx
4107 views
1
r"""
2
An interface to Anders Buch's Littlewood-Richardson Calculator ``lrcalc``
3
4
The "Littlewood-Richardson Calculator" is a C library for fast
5
computation of Littlewood-Richardson (LR) coefficients and products of
6
Schubert polynomials. It handles single LR coefficients, products of
7
and coproducts of Schur functions, skew Schur functions, and
8
fusion products. All of the above are achieved by counting LR
9
(skew)-tableaux (also called Yamanouchi (skew)-tableaux) of
10
appropriate shape and content by iterating through them.
11
Additionally, ``lrcalc`` handles products of Schubert polynomials.
12
13
The web page of ``lrcalc`` is `<http://math.rutgers.edu/~asbuch/lrcalc/>`_.
14
15
The following describes the Sage interface to this library.
16
17
EXAMPLES::
18
19
sage: import sage.libs.lrcalc.lrcalc as lrcalc #optional - lrcalc
20
21
Compute a single Littlewood-Richardson coefficient::
22
23
sage: lrcalc.lrcoef([3,2,1],[2,1],[2,1]) #optional - lrcalc
24
2
25
26
Compute a product of Schur functions; return the coefficients in the
27
Schur expansion::
28
29
sage: lrcalc.mult([2,1], [2,1]) #optional - lrcalc
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
32
Same product, but include only partitions with at most 3 rows. This
33
corresponds to computing in the representation ring of gl(3)::
34
35
sage: lrcalc.mult([2,1], [2,1], 3) #optional - lrcalc
36
{[3, 3]: 1, [4, 2]: 1, [3, 2, 1]: 2, [2, 2, 2]: 1, [4, 1, 1]: 1}
37
38
We can also compute the fusion product, here for sl(3) and level 2::
39
40
sage: lrcalc.mult([3,2,1], [3,2,1], 3,2) #optional - lrcalc
41
{[4, 4, 4]: 1, [5, 4, 3]: 1}
42
43
Compute the expansion of a skew Schur function::
44
45
sage: lrcalc.skew([3,2,1],[2,1]) #optional - lrcalc
46
{[3]: 1, [1, 1, 1]: 1, [2, 1]: 2}
47
48
Compute the coproduct of a Schur function::
49
50
sage: lrcalc.coprod([3,2,1]) #optional - lrcalc
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
([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
([2, 2], [1, 1]): 1, ([3, 1], [1, 1]): 1}
54
55
Multiply two Schubert polynomials::
56
57
sage: lrcalc.mult_schubert([4,2,1,3], [1,4,2,5,3]) #optional - lrcalc
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
60
Same product, but include only permutations of 5 elements in the result.
61
This corresponds to computing in the cohomology ring of Fl(5)::
62
63
sage: lrcalc.mult_schubert([4,2,1,3], [1,4,2,5,3], 5) #optional - lrcalc
64
{[5, 4, 1, 2, 3]: 1, [5, 3, 1, 4, 2]: 1, [4, 5, 1, 3, 2]: 1}
65
66
List all Littlewood-Richardson tableaux of skew shape `\mu/\nu`; in
67
this example `\mu=[3,2,1]` and `\nu=[2,1]`. Specifying a third entry
68
`maxrows` restricts the alphabet to `\{1,2,\ldots,maxrows\}`::
69
70
sage: list(lrcalc.lrskew([3,2,1],[2,1])) #optional - lrcalc
71
[[[None, None, 1], [None, 1], [1]], [[None, None, 1], [None, 1], [2]],
72
[[None, None, 1], [None, 2], [1]], [[None, None, 1], [None, 2], [3]]]
73
74
sage: list(lrcalc.lrskew([3,2,1],[2,1],maxrows=2)) #optional - lrcalc
75
[[[None, None, 1], [None, 1], [1]], [[None, None, 1], [None, 1], [2]], [[None, None, 1], [None, 2], [1]]]
76
77
.. todo:: use this library in the :class:`SymmetricFunctions` code, to
78
make it easy to apply it to linear combinations of Schur functions.
79
80
.. seealso::
81
82
- :func:`lrcoef`
83
- :func:`mult`
84
- :func:`coprod`
85
- :func:`skew`
86
- :func:`lrskew`
87
- :func:`mult_schubert`
88
89
.. rubric:: Underlying algorithmic in lrcalc
90
91
Here is some additional information regarding the main low-level
92
C-functions in `lrcalc`. Given two partitions ``outer`` and ``inner``
93
with ``inner`` contained in ``outer``, the function::
94
95
skewtab *st_new(vector *outer, vector *inner, vector *conts, int maxrows)
96
97
constructs and returns the (lexicographically) first LR skew tableau
98
of shape ``outer / inner``. Further restrictions can be imposed using
99
``conts`` and ``maxrows``.
100
101
Namely, the integer ``maxrows`` is a bound on the integers that can be
102
put in the tableau. The name is chosen because this will limit the
103
partitions in the output of :func:`skew` or :func:`mult` to partitions
104
with at most this number of rows.
105
106
The vector ``conts`` is the content of an empty tableau(!!). More
107
precisely, this vector is added to the usual content of a tableau
108
whenever the content is needed. This affects which tableaux are
109
considered LR tableaux (see :func:`mult` below). ``conts`` may also
110
be the ``NULL`` pointer, in which case nothing is added.
111
112
The other function::
113
114
int *st_next(skewtab *st)
115
116
computes in place the (lexicographically) next skew tableau with the
117
same constraints, or returns 0 if ``st`` is the last one.
118
119
For a first example, see the :func:`skew` function code in the
120
``lrcalc`` source code. We want to compute a skew schur function, so
121
create a skew LR tableau of the appropriate shape with ``st_new``
122
(with ``conts = NULL``), then iterate through all the LR tableaux with
123
``st_next()``. For each skew tableau, we use that ``st->conts`` is the
124
content of the skew tableau, find this shape in the ``res`` hash table
125
and add one to the value.
126
127
For a second example, see ``mult(vector *sh1, vector *sh2, maxrows)``.
128
Here we call ``st_new()`` with the shape ``sh1 / (0)`` and use ``sh2``
129
as the ``conts`` argument. The effect of using ``sh2`` in this way is
130
that ``st_next`` will iterate through semistandard tableaux `T` of
131
shape ``sh1`` such that the following tableau::
132
133
111111
134
22222 <--- minimal tableau of shape sh2
135
333
136
*****
137
**T**
138
****
139
**
140
141
is a LR skew tableau, and ``st->conts`` contains the content of the
142
combined tableaux.
143
144
More generally, ``st_new(outer, inner, conts, maxrows)`` and
145
``st_next`` can be used to compute the Schur expansion of the product
146
``S_{outer/inner} * S_conts``, restricted to partitions with at most
147
``maxrows`` rows.
148
149
AUTHORS:
150
151
- Mike Hansen (2010): core of the interface
152
153
- Anne Schilling, Nicolas M. ThiƩry, and Anders Buch (2011): fusion
154
product, iterating through LR tableaux, finalization, documentation
155
156
"""
157
#*****************************************************************************
158
# Copyright (C) 2010 Mike Hansen <[email protected]>
159
#
160
# Distributed under the terms of the GNU General Public License (GPL)
161
# http://www.gnu.org/licenses/
162
#*****************************************************************************
163
164
from sage.rings.all import Integer
165
from sage.combinat.all import Partition, Permutation, SkewTableau
166
167
cdef vector* iterable_to_vector(it):
168
"""
169
Return an lrcalc vector (which is a list of integers) from a Python iterable.
170
171
TESTS::
172
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
175
[3, 2, 1]
176
"""
177
cdef vector* v
178
it = list(it)
179
cdef int n = len(it)
180
v = v_new(n)
181
for i from 0 <= i < n:
182
v.array[i] = int(it[i])
183
return v
184
185
cdef vector_to_list(vector *v):
186
"""
187
Converts a lrcalc vector to Python list.
188
189
TESTS::
190
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
193
[]
194
"""
195
cdef int i, n
196
n = v_length(v)
197
result = [None]*n
198
for i from 0 <= i < n:
199
result[i] = Integer(v_elem(v, i))
200
return result
201
202
def test_iterable_to_vector(it):
203
"""
204
A wrapper function for the cdef function ``iterable_to_vector``
205
and ``vector_to_list``, to test that they are working correctly.
206
207
EXAMPLES::
208
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
211
[3, 2, 1]
212
"""
213
cdef vector *v = iterable_to_vector(it)
214
result = vector_to_list(v)
215
v_free(v)
216
return result
217
218
cdef skewtab_to_SkewTableau(skewtab *st):
219
"""
220
A wrapper function which transforms the data set ``st`` used in
221
``lrcalc`` to a ``SkewTableau`` in Sage.
222
223
TESTS::
224
225
sage: from sage.libs.lrcalc.lrcalc import test_skewtab_to_SkewTableau #optional -lrcalc
226
sage: test_skewtab_to_SkewTableau([],[]) #optional -lrcalc
227
[]
228
"""
229
inner = vector_to_list(st.inner)
230
outer = vector_to_list(st.outer)
231
return SkewTableau(expr=[[ inner[y] for y in range(len(outer))],
232
[[ st.matrix[x + y * st.cols]+1 for x in range(inner[y], outer[y]) ] for y in range(len(outer)-1,-1,-1) ]])
233
234
def test_skewtab_to_SkewTableau(outer, inner):
235
"""
236
A wrapper function for the cdef function ``skewtab_to_SkewTableau`` for testing purposes.
237
238
It constructs the first LR skew tableau of shape ``outer/inner``
239
as an ``lrcalc`` ``skewtab``, and converts it to a
240
:class:`SkewTableau`.
241
242
EXAMPLES::
243
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
246
[[1, 1, 1], [2, 2], [3]]
247
sage: test_skewtab_to_SkewTableau([4,3,2,1],[1,1]).pp() #optional -lrcalc
248
. 1 1 1
249
. 2 2
250
1 3
251
2
252
"""
253
cdef vector* o = iterable_to_vector(outer)
254
cdef vector* i = iterable_to_vector(inner+[0]*(len(outer)-len(inner)))
255
cdef skewtab* st = st_new(o, i, NULL, 0)
256
return skewtab_to_SkewTableau(st)
257
258
cdef sf_hashtab_to_dict(hashtab *ht):
259
"""
260
Return a dictionary representing a Schur function. The keys are
261
partitions and the values are integers <type 'sage.rings.integer.Integer'>.
262
263
EXAMPLES::
264
265
sage: from sage.libs.lrcalc.lrcalc import mult #optional - lrcalc
266
sage: sorted(mult([1],[1]).items()) #indirect doctest optional - lrcalc
267
[([1, 1], 1), ([2], 1)]
268
sage: assert isinstance(mult([1],[1]),dict)#indirect doctest optional - lrcalc
269
"""
270
cdef hash_itr itr
271
result = {}
272
hash_first(ht, itr)
273
while hash_good(itr):
274
p = vector_to_list(<vector*> hash_key(itr))
275
result[Partition(p)] = Integer(hash_intvalue(itr))
276
hash_next(itr)
277
return result
278
279
cdef schubert_hashtab_to_dict(hashtab *ht):
280
"""
281
Return a dictionary corresponding to a Schubert polynomial whose keys
282
are permutations and whose values are integers <type 'sage.rings.integer.Integer'>.
283
284
EXAMPLES::
285
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
288
{[3, 2, 1]: 1}
289
"""
290
cdef hash_itr itr
291
result = {}
292
hash_first(ht, itr)
293
while hash_good(itr):
294
p = vector_to_list(<vector*> hash_key(itr))
295
result[Permutation(p)] = Integer(hash_intvalue(itr))
296
hash_next(itr)
297
return result
298
299
300
cdef vp_hashtab_to_dict(hashtab *ht):
301
"""
302
Return a dictionary corresponding to the coproduct of a Schur function whose keys are
303
pairs of partitions and whose values are integers <type 'sage.rings.integer.Integer'>.
304
305
EXAMPLES::
306
307
sage: from sage.libs.lrcalc.lrcalc import coprod #optional - lrcalc
308
sage: coprod([1]) #indirect doctest optional - lrcalc
309
{([1], []): 1}
310
"""
311
cdef hash_itr itr
312
cdef vecpair* vp
313
result = {}
314
hash_first(ht, itr)
315
while hash_good(itr):
316
vp = <vecpair*> hash_key(itr)
317
p1 = Partition(vector_to_list(vp_first(vp)))
318
p2 = Partition(vector_to_list(vp_second(vp)))
319
result[(p1, p2)] = Integer(hash_intvalue(itr))
320
hash_next(itr)
321
return result
322
323
324
def lrcoef_unsafe(outer, inner1, inner2):
325
r"""
326
Compute a single Littlewood-Richardson coefficient.
327
328
Return the coefficient of ``outer`` in the product of the Schur
329
functions indexed by ``inner1`` and ``inner2``.
330
331
INPUT:
332
333
- ``outer`` -- a partition (weakly decreasing list of non-negative integers).
334
335
- ``inner1`` -- a partition.
336
337
- ``inner2`` -- a partition.
338
339
.. warning::
340
341
This function does not do any check on its input. If you want
342
to use a safer version, use :func:`lrcoef`.
343
344
EXAMPLES::
345
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
348
2
349
sage: lrcoef_unsafe([3,3], [2,1], [2,1]) #optional - lrcalc
350
1
351
sage: lrcoef_unsafe([2,1,1,1,1], [2,1], [2,1]) #optional - lrcalc
352
0
353
"""
354
cdef long long result
355
cdef vector *o, *i1, *i2
356
o = iterable_to_vector(outer)
357
i1 = iterable_to_vector(inner1)
358
i2 = iterable_to_vector(inner2)
359
result = lrcoef_c(o, i1, i2)
360
v_free(o); v_free(i1); v_free(i2)
361
return Integer(result)
362
363
def lrcoef(outer, inner1, inner2):
364
"""
365
Compute a single Littlewood-Richardson coefficient.
366
367
Return the coefficient of ``outer`` in the product of the Schur
368
functions indexed by ``inner1`` and ``inner2``.
369
370
INPUT:
371
372
- ``outer`` -- a partition (weakly decreasing list of non-negative integers).
373
374
- ``inner1`` -- a partition.
375
376
- ``inner2`` -- a partition.
377
378
.. note::
379
380
This function converts its inputs into :func:`Partition`'s. If
381
you don't need these checks and your inputs are valid, then you
382
can use :func:`lrcoef_unsafe`.
383
384
EXAMPLES::
385
386
sage: from sage.libs.lrcalc.lrcalc import lrcoef #optional - lrcalc
387
sage: lrcoef([3,2,1], [2,1], [2,1]) #optional - lrcalc
388
2
389
sage: lrcoef([3,3], [2,1], [2,1]) #optional - lrcalc
390
1
391
sage: lrcoef([2,1,1,1,1], [2,1], [2,1]) #optional - lrcalc
392
0
393
394
"""
395
return lrcoef_unsafe(Partition(outer), Partition(inner1), Partition(inner2))
396
397
def mult(part1, part2, maxrows=None, level=None):
398
r"""
399
Compute a product of two Schur functions.
400
401
Return the product of the Schur functions indexed by the
402
partitions ``part1`` and ``part2``.
403
404
INPUT:
405
406
- ``part1`` -- a partition.
407
408
- ``part2`` -- a partition.
409
410
- ``maxrows`` -- an integer or None.
411
412
- ``level`` -- an integer or None.
413
414
If ``maxrows`` is specified, then only partitions with at most
415
this number of rows is included in the result.
416
417
If both ``maxrows`` and ``level`` are specified, then the function
418
calculates the fusion product for `sl(\mathrm{maxrows})` of the
419
given level.
420
421
EXAMPLES::
422
423
sage: from sage.libs.lrcalc.lrcalc import mult #optional - lrcalc
424
sage: mult([2],[]) #optional - lrcalc
425
{[2]: 1}
426
sage: sorted(mult([2],[2]).items()) #optional - lrcalc
427
[([2, 2], 1), ([3, 1], 1), ([4], 1)]
428
sage: sorted(mult([2,1],[2,1]).items()) #optional - lrcalc
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 - lrcalc
431
[([3, 3], 1), ([4, 2], 1)]
432
sage: mult([2,1],[3,2,1],3) #optional - lrcalc
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 - lrcalc
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 - lrcalc
437
Traceback (most recent call last):
438
...
439
ValueError: maxrows needs to be specified if you specify the level
440
441
"""
442
if maxrows is None and not(level is None):
443
raise ValueError, 'maxrows needs to be specified if you specify the level'
444
cdef vector* v1 = iterable_to_vector(part1)
445
cdef vector* v2 = iterable_to_vector(part2)
446
if maxrows is None:
447
maxrows = 0
448
cdef hashtab* ht = mult_c(v1, v2, int(maxrows))
449
if not(level is None):
450
fusion_reduce_c(ht, int(maxrows), int(level), int(0))
451
result = sf_hashtab_to_dict(ht)
452
v_free(v1); v_free(v2); hash_free(ht)
453
return result
454
455
def skew(outer, inner, maxrows=0):
456
"""
457
Compute the Schur expansion of a skew Schur function.
458
459
Return a linear combination of partitions representing the Schur
460
function of the skew Young diagram ``outer / inner``, consisting
461
of boxes in the partition ``outer`` that are not in ``inner``.
462
463
INPUT:
464
465
- ``outer`` -- a partition.
466
467
- ``inner`` -- a partition.
468
469
- ``maxrows`` -- an integer or None.
470
471
If ``maxrows`` is specified, then only partitions with at most
472
this number of rows are included in the result.
473
474
EXAMPLES::
475
476
sage: from sage.libs.lrcalc.lrcalc import skew #optional - lrcalc
477
sage: sorted(skew([2,1],[1]).items()) #optional - lrcalc
478
[([1, 1], 1), ([2], 1)]
479
"""
480
cdef vector* v1 = iterable_to_vector(outer)
481
cdef vector* v2 = iterable_to_vector(inner)
482
cdef hashtab* ht = skew_c(v1, v2, int(maxrows))
483
result = sf_hashtab_to_dict(ht)
484
v_free(v1); v_free(v2); hash_free(ht)
485
return result
486
487
def coprod(part, all=0):
488
"""
489
Compute the coproduct of a Schur function.
490
491
Return a linear combination of pairs of partitions representing
492
the coproduct of the Schur function given by the partition
493
``part``.
494
495
INPUT:
496
497
- ``part`` -- a partition.
498
499
- ``all`` -- an integer.
500
501
If ``all`` is non-zero then all terms are included in the result.
502
If ``all`` is zero, then only pairs of partitions ``(part1,
503
part2)`` for which the weight of ``part1`` is greater than or
504
equal to the weight of ``part2`` are included; the rest of the
505
coefficients are redundant because Littlewood-Richardson
506
coefficients are symmetric.
507
508
EXAMPLES::
509
510
sage: from sage.libs.lrcalc.lrcalc import coprod #optional - lrcalc
511
sage: sorted(coprod([2,1]).items()) #optional - lrcalc
512
[(([1, 1], [1]), 1), (([2], [1]), 1), (([2, 1], []), 1)]
513
"""
514
cdef vector* v1 = iterable_to_vector(part)
515
cdef hashtab* ht = coprod_c(v1, int(all))
516
result = vp_hashtab_to_dict(ht)
517
v_free(v1); hash_free(ht)
518
return result
519
520
521
def mult_schubert(w1, w2, rank=0):
522
r"""
523
Compute a product of two Schubert polynomials.
524
525
Return a linear combination of permutations representing the
526
product of the Schubert polynomials indexed by the permutations
527
``w1`` and ``w2``.
528
529
INPUT:
530
531
- ``w1`` -- a permutation.
532
533
- ``w2`` -- a permutation.
534
535
- ``rank`` -- an integer.
536
537
If ``rank`` is non-zero, then only permutations from the symmetric
538
group `S(\mathrm{rank})` are included in the result.
539
540
EXAMPLES::
541
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
545
[([5, 4, 6, 1, 2, 3], 1), ([5, 6, 3, 1, 2, 4], 1),
546
([5, 7, 2, 1, 3, 4, 6], 1), ([6, 3, 5, 1, 2, 4], 1),
547
([6, 4, 3, 1, 2, 5], 1), ([6, 5, 2, 1, 3, 4], 1),
548
([7, 3, 4, 1, 2, 5, 6], 1), ([7, 4, 2, 1, 3, 5, 6], 1)]
549
"""
550
cdef vector* v1 = iterable_to_vector(w1)
551
cdef vector* v2 = iterable_to_vector(w2)
552
cdef hashtab* ht = mult_schubert_c(v1, v2, int(rank))
553
result = schubert_hashtab_to_dict(ht)
554
v_free(v1); v_free(v2); hash_free(ht)
555
return result
556
557
def lrskew(outer, inner, weight=None, maxrows=0):
558
"""
559
Return the skew LR tableaux of shape ``outer / inner``.
560
561
INPUT:
562
563
- ``outer`` -- a partition.
564
565
- ``inner`` -- a partition.
566
567
- ``weight`` -- a partition (optional).
568
569
- ``maxrows`` -- an integer (optional).
570
571
OUTPUT: a list of :class:`SkewTableau`x. This will change to an
572
iterator over such skew tableaux once Cython will support the
573
``yield`` statement. Specifying a third entry `maxrows` restricts
574
the alphabet to `\{1,2,\ldots,maxrows\}`. Specifying `weight`
575
returns only those tableaux of given content/weight.
576
577
EXAMPLES::
578
579
sage: from sage.libs.lrcalc.lrcalc import lrskew #optional - lrcalc
580
sage: for st in lrskew([3,2,1],[2]): #optional - lrcalc
581
... st.pp()
582
. . 1
583
1 1
584
2
585
. . 1
586
1 2
587
2
588
. . 1
589
1 2
590
3
591
592
sage: for st in lrskew([3,2,1],[2], maxrows=2): #optional - lrcalc
593
... st.pp()
594
. . 1
595
1 1
596
2
597
. . 1
598
1 2
599
2
600
601
sage: lrskew([3,2,1],[2], weight=[3,1]) #optional - lrcalc
602
[[[None, None, 1], [1, 1], [2]]]
603
"""
604
cdef vector* o = iterable_to_vector(outer)
605
cdef vector* i = iterable_to_vector(inner+[0]*(len(outer)-len(inner)))
606
cdef skewtab* st = st_new(o, i, NULL, int(maxrows))
607
result = [skewtab_to_SkewTableau(st)] # todo: replace by the following line
608
#yield skewtab_to_SkewTableau(st)
609
while st_next(st):
610
result.append(skewtab_to_SkewTableau(st)) # todo: replace by the following line
611
#yield skewtab_to_SkewTableau(st)
612
st_free(st)
613
if weight is not None:
614
result = [r for r in result if r.weight() == Partition(weight) ]
615
return result # todo: remove
616
617