[arch-commits] Commit in sagemath/trunk (PKGBUILD sagemath-lrcalc2.patch)

Antonio Rojas arojas at archlinux.org
Sun Feb 21 12:52:25 UTC 2021


    Date: Sunday, February 21, 2021 @ 12:52:24
  Author: arojas
Revision: 867634

Replace lrcalc.pyx module with a wrapper over lrcalc's python bindings

Added:
  sagemath/trunk/sagemath-lrcalc2.patch
Modified:
  sagemath/trunk/PKGBUILD

------------------------+
 PKGBUILD               |   12 -
 sagemath-lrcalc2.patch |  559 +++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 567 insertions(+), 4 deletions(-)

Modified: PKGBUILD
===================================================================
--- PKGBUILD	2021-02-21 12:19:55 UTC (rev 867633)
+++ PKGBUILD	2021-02-21 12:52:24 UTC (rev 867634)
@@ -8,7 +8,7 @@
 pkgbase=sagemath
 pkgname=(sagemath sagemath-jupyter)
 pkgver=9.2
-pkgrel=10
+pkgrel=11
 pkgdesc="Open Source Mathematics Software, free alternative to Magma, Maple, Mathematica, and Matlab"
 arch=(x86_64)
 url="http://www.sagemath.org"
@@ -15,7 +15,7 @@
 license=(GPL)
 depends=(ipython palp brial cliquer maxima-ecl gfan sympow nauty python-rpy2 python-fpylll python-psutil python-cypari2
   python-matplotlib python-scipy python-sympy python-networkx python-pillow python-pplpy python-sphinx
-  gap flintqs lcalc lrcalc1 arb eclib zn_poly gd python-cvxopt pynac linbox m4rie pari-galdata pari-seadata-small planarity rankwidth tachyon
+  gap flintqs lcalc lrcalc arb eclib zn_poly gd python-cvxopt pynac linbox m4rie pari-galdata pari-seadata-small planarity rankwidth tachyon
   sage-data-combinatorial_designs sage-data-elliptic_curves sage-data-graphs sage-data-polytopes_db sage-data-conway_polynomials
   iml libgiac libhomfly libbraiding symmetrica threejs-sage)
 optdepends=('cython: to compile cython code' 'python-pkgconfig: to compile cython code'
@@ -44,7 +44,8 @@
         sagemath-flint-2.6.patch
         sagemath-cypari-2.1.2.patch
         sagemath-pari-2.13.patch
-        sagemath-threejs-sage.patch::"https://github.com/sagemath/sage/commit/f4909e1c.patch")
+        sagemath-threejs-sage.patch::"https://github.com/sagemath/sage/commit/f4909e1c.patch"
+        sagemath-lrcalc2.patch)
 sha256sums=('edc89776461247cf74a16473851378e70a2de867309978ca2346ef6f93af0f90'
             '00cf73534c10bb8694c77639670aa041b4b8c897babb01751a5f65648bcfdcf6'
             'af922e1f978821a9a1f6c9a56130d71e5011c84a7aee7bf66a591bee658af30b'
@@ -55,7 +56,8 @@
             '5d00b24c1d36b41b8ea3f07b93fc0e00b42dd84d9bc4e9b3d26e5f2cfeba6405'
             'dc507eeb75eae1109273879771b4eb56172b7417e87a0693381106afd7554e04'
             '84875c90268436cb6a740a4e1bffd70b4895458ef9e1ee268a3c4aa0564e893f'
-            'c27f7697a94cfe9d0581819fcd9dabcec5fb8471ea761ad2db91399355249a06')
+            'c27f7697a94cfe9d0581819fcd9dabcec5fb8471ea761ad2db91399355249a06'
+            '03e62ed02a9de2062a1a1bf4cc921e48cc9644ce30b46efeb8d200fecc8285dc')
 
 prepare(){
   cd sage-$pkgver
@@ -77,6 +79,8 @@
   patch -p1 -i ../sagemath-pari-2.13.patch
 # Use sage's threejs fork
   patch -p1 -i ../sagemath-threejs-sage.patch
+# Replace lrcalc.pyx with a wrapper over lrcalc's python bindings https://trac.sagemath.org/ticket/31355
+  patch -p1 -i ../sagemath-lrcalc2.patch
 
 # Arch-specific patches
 # assume all optional packages are installed

Added: sagemath-lrcalc2.patch
===================================================================
--- sagemath-lrcalc2.patch	                        (rev 0)
+++ sagemath-lrcalc2.patch	2021-02-21 12:52:24 UTC (rev 867634)
@@ -0,0 +1,559 @@
+diff --git a/build/pkgs/lrcalc/checksums.ini b/build/pkgs/lrcalc/checksums.ini
+index 7a0e6a1b96..60fa8705dd 100644
+--- a/build/pkgs/lrcalc/checksums.ini
++++ b/build/pkgs/lrcalc/checksums.ini
+@@ -1,4 +1,5 @@
+ tarball=lrcalc-VERSION.tar.gz
+-sha1=89c288875bc3e3e2919876cb645bdfd7316b5965
+-md5=6bba16c0cca9debccd0af847bd3d4a23
+-cksum=3738483656
++sha1=1fc72c3ba8608e1393b6f75f2edad65225849067
++md5=166404839402290cec165c63c1fd24d8
++cksum=438483389
++upstream_url=https://sites.math.rutgers.edu/~asbuch/lrcalc/lrcalc-VERSION.tar.gz
+diff --git a/build/pkgs/lrcalc/package-version.txt b/build/pkgs/lrcalc/package-version.txt
+index 92ab3427e8..cd5ac039d6 100644
+--- a/build/pkgs/lrcalc/package-version.txt
++++ b/build/pkgs/lrcalc/package-version.txt
+@@ -1 +1 @@
+-1.2.p1
++2.0
+diff --git a/build/pkgs/lrcalc/patches/includes.patch b/build/pkgs/lrcalc/patches/includes.patch
+deleted file mode 100644
+index 707da176a6..0000000000
+--- a/build/pkgs/lrcalc/patches/includes.patch
++++ /dev/null
+@@ -1,90 +0,0 @@
+-From 4a5e1c8c3c11efdb1cbb4239825a6bf4bf1c52f8 Mon Sep 17 00:00:00 2001
+-From: Anders Skovsted Buch <asbuch at math.rutgers.edu>
+-Date: Sun, 29 Nov 2015 16:25:56 -0500
+-Subject: [PATCH] Patch by Jeroen Demeyer to change include <vector.h> to
+- "vector.h", plus similar cases.
+-
+----
+- src/lrcalc.c   | 2 +-
+- src/maple.c    | 4 ++--
+- src/schublib.h | 2 +-
+- src/symfcn.c   | 6 +++---
+- src/symfcn.h   | 4 ++--
+- 5 files changed, 9 insertions(+), 9 deletions(-)
+-
+-diff --git a/src/lrcalc.c b/src/lrcalc.c
+-index aff3f75..60df49e 100644
+---- a/src/lrcalc.c
+-+++ b/src/lrcalc.c
+-@@ -8,7 +8,7 @@
+- #include <stdlib.h>
+- extern char *optarg;
+- 
+--#include <vectarg.h>
+-+#include "vectarg.h"
+- 
+- #include "symfcn.h"
+- #include "maple.h"
+-diff --git a/src/maple.c b/src/maple.c
+-index fdc0768..a5f4d14 100644
+---- a/src/maple.c
+-+++ b/src/maple.c
+-@@ -4,8 +4,8 @@
+-  */
+- 
+- #include <stdio.h>
+--#include <vector.h>
+--#include <hashtab.h>
+-+#include "vector.h"
+-+#include "hashtab.h"
+- #include "maple.h"
+- 
+- 
+-diff --git a/src/schublib.h b/src/schublib.h
+-index a8e8511..864850c 100644
+---- a/src/schublib.h
+-+++ b/src/schublib.h
+-@@ -1,7 +1,7 @@
+- #ifndef _SCHUBLIB_H
+- #define _SCHUBLIB_H
+- 
+--#include <hashtab.h>
+-+#include "hashtab.h"
+- 
+- hashtab *trans(vector *w, int vars, hashtab *res);
+- hashtab *monk(int i, hashtab *slc, int rank);
+-diff --git a/src/symfcn.c b/src/symfcn.c
+-index 4ffbe4b..fd5df5d 100644
+---- a/src/symfcn.c
+-+++ b/src/symfcn.c
+-@@ -5,9 +5,9 @@
+- 
+- #include <stdio.h>
+- 
+--#include <alloc.h>
+--#include <vector.h>
+--#include <hashtab.h>
+-+#include "alloc.h"
+-+#include "vector.h"
+-+#include "hashtab.h"
+- 
+- #include "symfcn.h"
+- 
+-diff --git a/src/symfcn.h b/src/symfcn.h
+-index b8543b1..29bb00d 100644
+---- a/src/symfcn.h
+-+++ b/src/symfcn.h
+-@@ -1,8 +1,8 @@
+- #ifndef _SYMFCN_H
+- #define _SYMFCN_H
+- 
+--#include <hashtab.h>
+--#include <vector.h>
+-+#include "hashtab.h"
+-+#include "vector.h"
+- 
+- int part_itr_sz(vector *part);
+- int part_itr_sub(vector *part, vector *outer);
+--- 
+-2.1.1.1.g1fb337f
+-
+diff --git a/src/sage/libs/lrcalc/lrcalc.pxd b/src/sage/libs/lrcalc/lrcalc.pxd
+deleted file mode 100644
+index 10b88db93f..0000000000
+--- a/src/sage/libs/lrcalc/lrcalc.pxd
++++ /dev/null
+@@ -1,77 +0,0 @@
+-# distutils: libraries = lrcalc
+-
+-cdef extern from "lrcalc/hashtab.h":
+-    ctypedef struct hashtab:
+-        pass
+-
+-    ctypedef struct hash_itr:
+-        pass
+-
+-    ctypedef unsigned long hashkey_t
+-    ctypedef int (*cmp_t) (void* a, void* b)
+-    ctypedef hashkey_t (*hash_t) (void* a)
+-
+-    hashtab* hash_new(cmp_t cm, hash_t hsh)
+-    void hash_free(hashtab *ht)
+-
+-    void* hash_lookup(hashtab *ht, void *key)
+-    void* hash_insert(hashtab *ht, void *key, void *value)
+-
+-    bint hash_good(hash_itr)
+-    void hash_first(hashtab* s, hash_itr itr)
+-    void hash_next(hash_itr itr)
+-    void* hash_key(hash_itr itr)
+-    void* hash_value(hash_itr itr)
+-    int hash_intvalue(hash_itr itr)
+-
+-cdef extern from "lrcalc/vector.h":
+-    ctypedef struct vector:
+-        size_t length
+-        int* array
+-
+-    vector* v_new(int length)
+-    void v_free(vector* v)
+-    void v_print(vector *v)
+-    int v_length(vector* v)
+-    int v_elem(vector* v, int i)
+-
+-    ctypedef struct vecpair:
+-        vector *first
+-        vector *second
+-
+-    vector* vp_first(vecpair* vp)
+-    vector* vp_second(vecpair* vp)
+-
+-cdef extern from "lrcalc/list.h":
+-    cdef struct _list:
+-        void **array
+-        size_t allocated
+-        size_t length
+-    void l_free(_list *lst)
+-
+-cdef extern from "lrcalc/symfcn.h":
+-    long long lrcoef_c "lrcoef"(vector* outer, vector* inner1, vector* inner2)
+-    hashtab* mult_c "mult"(vector *sh1, vector *sh2, int maxrows)
+-    hashtab* skew_c "skew"(vector *outer, vector *inner, int maxrows)
+-    hashtab* coprod_c "coprod"(vector *part, int all)
+-    void fusion_reduce_c "fusion_reduce"(hashtab* ht, int rows, int cols, int opt_zero)
+-    _list *quantum_reduce_c "quantum_reduce"(hashtab* ht, int rows, int col)
+-
+-    ctypedef struct skewtab:
+-        vector *outer
+-        vector *inner
+-        vector *conts
+-        int maxrows
+-        vector *conjugate
+-        int rows
+-        int cols
+-        int matrix[1]
+-
+-    skewtab *st_new(vector *outer, vector *inner, vector *conts, int maxrows)
+-    int st_next(skewtab *st)
+-    void st_print(skewtab *st)
+-    void st_free(skewtab *st)
+-
+-
+-cdef extern from "lrcalc/schublib.h":
+-    hashtab* mult_schubert_c "mult_schubert"(vector *sh1, vector *sh2, int rank)
+diff --git a/src/sage/libs/lrcalc/lrcalc.pyx b/src/sage/libs/lrcalc/lrcalc.py
+similarity index 65%
+rename from src/sage/libs/lrcalc/lrcalc.pyx
+rename to src/sage/libs/lrcalc/lrcalc.py
+index 1cf67dc15a..5834ab8370 100644
+--- a/src/sage/libs/lrcalc/lrcalc.pyx
++++ b/src/sage/libs/lrcalc/lrcalc.py
+@@ -187,180 +187,15 @@ AUTHORS:
+ #                  https://www.gnu.org/licenses/
+ # ****************************************************************************
+ 
+-from sage.rings.integer cimport Integer
+-from sage.structure.parent cimport Parent
+ from sage.combinat.partition import _Partitions
+ from sage.combinat.permutation import Permutation
+-from sage.combinat.skew_tableau import SkewTableau
+-
+-
+-cdef vector* iterable_to_vector(it):
+-    """
+-    Return an lrcalc vector (which is a list of integers) from a Python iterable.
+-
+-    TESTS::
+-
+-        sage: from sage.libs.lrcalc.lrcalc import test_iterable_to_vector
+-        sage: x = test_iterable_to_vector(Partition([3,2,1])); x   #indirect doctest
+-        [3, 2, 1]
+-    """
+-    cdef vector* v
+-    cdef list itr = list(it)
+-    cdef int n = len(itr)
+-    cdef int i
+-    v = v_new(n)
+-    for i in range(n):
+-        v.array[i] = int(itr[i])
+-    return v
+-
+-
+-cdef list vector_to_list(vector *v):
+-    """
+-    Converts a lrcalc vector to Python list.
+-
+-    TESTS::
+-
+-        sage: from sage.libs.lrcalc.lrcalc import test_iterable_to_vector
+-        sage: x = test_iterable_to_vector([]); x         #indirect doctest
+-        []
+-    """
+-    cdef int i, n
+-    n = v_length(v)
+-    cdef list result = [None]*n
+-    for i in range(n):
+-        result[i] = Integer(v_elem(v, i))
+-    return result
+-
+-
+-def test_iterable_to_vector(it):
+-    """
+-    A wrapper function for the cdef function ``iterable_to_vector``
+-    and ``vector_to_list``, to test that they are working correctly.
+-
+-    EXAMPLES::
+-
+-        sage: from sage.libs.lrcalc.lrcalc import test_iterable_to_vector
+-        sage: x = test_iterable_to_vector([3,2,1]); x
+-        [3, 2, 1]
+-    """
+-    cdef vector *v = iterable_to_vector(it)
+-    result = vector_to_list(v)
+-    v_free(v)
+-    return result
+-
+-
+-cdef skewtab_to_SkewTableau(skewtab *st):
+-    """
+-    A wrapper function which transforms the data set ``st`` used in
+-    ``lrcalc`` to a ``SkewTableau`` in Sage.
+-
+-    TESTS::
+-
+-        sage: from sage.libs.lrcalc.lrcalc import test_skewtab_to_SkewTableau
+-        sage: test_skewtab_to_SkewTableau([],[])
+-        []
+-    """
+-    inner = vector_to_list(st.inner)
+-    outer = vector_to_list(st.outer)
+-    return SkewTableau(expr=[[inner[y] for y in range(len(outer))],
+-                             [[st.matrix[x + y * st.cols] + 1
+-                                for x in range(inner[y], outer[y])]
+-                              for y in range(len(outer) - 1, -1, -1)]])
+-
+-
+-def test_skewtab_to_SkewTableau(outer, inner):
+-    """
+-    A wrapper function for the cdef function ``skewtab_to_SkewTableau``
+-    for testing purposes.
+-
+-    It constructs the first LR skew tableau of shape ``outer/inner``
+-    as an ``lrcalc`` ``skewtab``, and converts it to a
+-    :class:`SkewTableau`.
+-
+-    EXAMPLES::
+-
+-        sage: from sage.libs.lrcalc.lrcalc import test_skewtab_to_SkewTableau
+-        sage: test_skewtab_to_SkewTableau([3,2,1],[])
+-        [[1, 1, 1], [2, 2], [3]]
+-        sage: test_skewtab_to_SkewTableau([4,3,2,1],[1,1]).pp()
+-        .  1  1  1
+-        .  2  2
+-        1  3
+-        2
+-    """
+-    cdef vector* o = iterable_to_vector(outer)
+-    cdef vector* i = iterable_to_vector(inner+[0]*(len(outer)-len(inner)))
+-    cdef skewtab* st = st_new(o, i, NULL, 0)
+-    return skewtab_to_SkewTableau(st)
+-
+-
+-cdef dict sf_hashtab_to_dict(hashtab *ht):
+-    """
+-    Return a dictionary representing a Schur function. The keys are
+-    partitions and the values are integers <type 'sage.rings.integer.Integer'>.
+-
+-    EXAMPLES::
+-
+-        sage: from sage.libs.lrcalc.lrcalc import mult
+-        sage: sorted(mult([1],[1]).items())        #indirect doctest
+-        [([1, 1], 1), ([2], 1)]
+-        sage: assert isinstance(mult([1],[1]),dict)#indirect doctest
+-    """
+-    cdef hash_itr itr
+-    cdef dict result = {}
+-    cdef list p
+-    hash_first(ht, itr)
+-    while hash_good(itr):
+-        p = vector_to_list(<vector*> hash_key(itr))
+-        result[_Partitions(p)] = Integer(hash_intvalue(itr))
+-        hash_next(itr)
+-    return result
+-
+-
+-cdef dict schubert_hashtab_to_dict(hashtab *ht):
+-    """
+-    Return a dictionary corresponding to a Schubert polynomial whose keys
+-    are permutations and whose values are integers <type 'sage.rings.integer.Integer'>.
+-
+-    EXAMPLES::
+-
+-        sage: from sage.libs.lrcalc.lrcalc import mult_schubert
+-        sage: mult_schubert([3,2,1], [1,2,3])      #indirect doctest
+-        {[3, 2, 1]: 1}
+-    """
+-    cdef hash_itr itr
+-    cdef dict result = {}
+-    hash_first(ht, itr)
+-    while hash_good(itr):
+-        p = vector_to_list(<vector*> hash_key(itr))
+-        result[Permutation(p)] = Integer(hash_intvalue(itr))
+-        hash_next(itr)
+-    return result
+-
+-
+-cdef dict vp_hashtab_to_dict(hashtab *ht):
+-    """
+-    Return a dictionary corresponding to the coproduct of a Schur function whose keys are
+-    pairs of partitions and whose values are integers <type 'sage.rings.integer.Integer'>.
+-
+-    EXAMPLES::
+-
+-        sage: from sage.libs.lrcalc.lrcalc import coprod
+-        sage: coprod([1])      #indirect doctest
+-        {([1], []): 1}
+-    """
+-    cdef hash_itr itr
+-    cdef vecpair* vp
+-    cdef dict result = {}
+-    hash_first(ht, itr)
+-    while hash_good(itr):
+-        vp = <vecpair*> hash_key(itr)
+-        p1 = _Partitions(vector_to_list(vp_first(vp)))
+-        p2 = _Partitions(vector_to_list(vp_second(vp)))
+-        result[(p1, p2)] = Integer(hash_intvalue(itr))
+-        hash_next(itr)
+-    return result
++from sage.combinat.skew_tableau import SkewTableaux
++from sage.combinat.skew_partition import SkewPartition
++from sage.combinat.words.word import Word
++import lrcalc
+ 
++def _lrcalc_dict_to_sage(result):
++    return dict({_Partitions(i):k for i,k in result.items()})
+ 
+ def lrcoef_unsafe(outer, inner1, inner2):
+     r"""
+@@ -392,18 +227,7 @@ def lrcoef_unsafe(outer, inner1, inner2):
+         sage: lrcoef_unsafe([2,1,1,1,1], [2,1], [2,1])
+         0
+     """
+-    cdef long long result
+-    cdef vector *o
+-    cdef vector *i1
+-    cdef vector *i2
+-    o = iterable_to_vector(outer)
+-    i1 = iterable_to_vector(inner1)
+-    i2 = iterable_to_vector(inner2)
+-    result = lrcoef_c(o, i1, i2)
+-    v_free(o)
+-    v_free(i1)
+-    v_free(i2)
+-    return Integer(result)
++    return lrcalc.lrcoef(outer, inner1, inner2)
+ 
+ 
+ def lrcoef(outer, inner1, inner2):
+@@ -510,44 +334,21 @@ def mult(part1, part2, maxrows=None, level=None, quantum=None):
+     if quantum is not None and (level is None or maxrows is None):
+         raise ValueError('missing parameters maxrows or level')
+ 
+-    cdef vector* v1 = iterable_to_vector(part1)
+-    cdef vector* v2 = iterable_to_vector(part2)
+-    if maxrows is None:
+-        maxrows = 0
+-    cdef hashtab* ht = mult_c(v1, v2, int(maxrows))
+-    cdef hashtab* tab
+-    cdef dict result
+-
+     if quantum is None:
+         if level is not None:
+-            fusion_reduce_c(ht, int(maxrows), int(level), int(0))
+-        result = sf_hashtab_to_dict(ht)
+-        v_free(v1)
+-        v_free(v2)
+-        hash_free(ht)
+-        return result
++            return _lrcalc_dict_to_sage(lrcalc.mult_fusion(part1, part2, maxrows, level))
++        if maxrows is None:
++            maxrows = -1
++        return _lrcalc_dict_to_sage(lrcalc.mult(part1, part2, maxrows))
+ 
+     # Otherwise do quantum multiplication
+-    cdef _list *qlist
+-    cdef dict temp
+-    qlist = quantum_reduce_c(ht, int(maxrows), int(level))
+-    # The above call frees the memory associated with ht
+-    v_free(v1)
+-    v_free(v2)
+-
+-    cdef Parent P = quantum.parent()
+-    result = {}
+-    for i in range(qlist.length):
+-        tab = <hashtab*>(qlist.array[i])
+-        temp = sf_hashtab_to_dict(tab)
+-        for k in temp:
+-            result[k] = result.get(k, P.zero()) + quantum**i * temp[k]
+-        hash_free(tab)
+-    l_free(qlist)
+-    return result
+-
+-
+-def skew(outer, inner, maxrows=0):
++    mf = lrcalc.mult_fusion(part1, part2, maxrows, level)
++    q_degrees = [sum(int((v[i]+len(v)-i-1)/(len(v)+level)) for i in range(len(v))) for v in mf.keys()]
++    mq = list(lrcalc.mult_quantum(part1, part2, maxrows, level).items())
++    return dict({_Partitions(mq[i][0]):mq[i][1] * quantum**q_degrees[i] for i in range(len(mq))})
++
++
++def skew(outer, inner, maxrows=-1):
+     """
+     Compute the Schur expansion of a skew Schur function.
+ 
+@@ -572,14 +373,7 @@ def skew(outer, inner, maxrows=0):
+         sage: sorted(skew([2,1],[1]).items())
+         [([1, 1], 1), ([2], 1)]
+     """
+-    cdef vector* v1 = iterable_to_vector(outer)
+-    cdef vector* v2 = iterable_to_vector(inner)
+-    cdef hashtab* ht = skew_c(v1, v2, int(maxrows))
+-    result = sf_hashtab_to_dict(ht)
+-    v_free(v1)
+-    v_free(v2)
+-    hash_free(ht)
+-    return result
++    return _lrcalc_dict_to_sage(lrcalc.skew(outer, inner, maxrows))
+ 
+ 
+ def coprod(part, all=0):
+@@ -609,12 +403,8 @@ def coprod(part, all=0):
+         sage: sorted(coprod([2,1]).items())
+         [(([1, 1], [1]), 1), (([2], [1]), 1), (([2, 1], []), 1)]
+     """
+-    cdef vector* v1 = iterable_to_vector(part)
+-    cdef hashtab* ht = coprod_c(v1, int(all))
+-    result = vp_hashtab_to_dict(ht)
+-    v_free(v1)
+-    hash_free(ht)
+-    return result
++    result = lrcalc.coprod(part, all)
++    return dict({tuple(_Partitions(j) for j in i):k for i,k in result.items()})
+ 
+ 
+ def mult_schubert(w1, w2, rank=0):
+@@ -646,17 +436,11 @@ def mult_schubert(w1, w2, rank=0):
+          ([6, 4, 3, 1, 2, 5], 1), ([6, 5, 2, 1, 3, 4], 1),
+          ([7, 3, 4, 1, 2, 5, 6], 1), ([7, 4, 2, 1, 3, 5, 6], 1)]
+     """
+-    cdef vector* v1 = iterable_to_vector(w1)
+-    cdef vector* v2 = iterable_to_vector(w2)
+-    cdef hashtab* ht = mult_schubert_c(v1, v2, int(rank))
+-    result = schubert_hashtab_to_dict(ht)
+-    v_free(v1)
+-    v_free(v2)
+-    hash_free(ht)
+-    return result
++    result = lrcalc.schubmult(w1, w2, rank)
++    return dict({Permutation(list(i)):k for i,k in result.items()})
+ 
+ 
+-def lrskew(outer, inner, weight=None, maxrows=0):
++def lrskew(outer, inner, weight=None, maxrows=-1):
+     r"""
+     Iterate over the skew LR tableaux of shape ``outer / inner``.
+ 
+@@ -703,21 +487,23 @@ def lrskew(outer, inner, weight=None, maxrows=0):
+         sage: list(lrskew([3,2,1],[2], weight=[3,1]))
+         [[[None, None, 1], [1, 1], [2]]]
+     """
+-    cdef vector* o = iterable_to_vector(outer)
+-    cdef vector* i = iterable_to_vector(inner + [0]*(len(outer) - len(inner)))
+-    cdef skewtab* st = st_new(o, i, NULL, int(maxrows))
++    iterator = lrcalc.lr_iterator(outer, inner, maxrows)
++    shape = SkewPartition([outer, inner])
+ 
+     if weight is None:
+-        yield skewtab_to_SkewTableau(st)
+-        while st_next(st):
+-            yield skewtab_to_SkewTableau(st)
++        while True:
++            try:
++                word = Word([i+1 for i in next(iterator)])
++                yield SkewTableaux().from_shape_and_word(shape, word)
++            except StopIteration:
++                break
+     else:
+         wt = _Partitions(weight)
+-        r = skewtab_to_SkewTableau(st)
+-        if r.weight() == wt:
+-            yield r
+-        while st_next(st):
+-            r = skewtab_to_SkewTableau(st)
+-            if r.weight() == wt:
+-                yield r
+-    st_free(st)
++        while True:
++            try:
++                word = Word([i+1 for i in next(iterator)])
++                r = SkewTableaux().from_shape_and_word(shape, word)
++                if r.weight() == wt:
++                    yield r
++            except StopIteration:
++                break



More information about the arch-commits mailing list