summarylogtreecommitdiffstats
path: root/sagemath-lrcalc2.patch
blob: 0ae8f6c1d086e15e053086ec72b6be1aa5f28d82 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
diff --git a/build/pkgs/lrcalc/checksums.ini b/build/pkgs/lrcalc/checksums.ini
index 7a0e6a1b96..8b8620ba52 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
+tarball=liblrcalc-VERSION.tar.gz
+sha1=2a98661eb39c7ef526c932f7886fc3142fd639ab
+md5=7cfa8f67287f2b70a15a833b94bc24b6
+cksum=2250996027
+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..879b416e60 100644
--- a/build/pkgs/lrcalc/package-version.txt
+++ b/build/pkgs/lrcalc/package-version.txt
@@ -1 +1 @@
-1.2.p1
+2.1
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@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/build/pkgs/lrcalc/spkg-configure.m4 b/build/pkgs/lrcalc/spkg-configure.m4
index f2f8b74f8f..da66e31fbc 100644
--- a/build/pkgs/lrcalc/spkg-configure.m4
+++ b/build/pkgs/lrcalc/spkg-configure.m4
@@ -2,8 +2,7 @@ SAGE_SPKG_CONFIGURE([lrcalc], [
     AC_CHECK_HEADERS([lrcalc/schublib.h], [
           AC_SEARCH_LIBS([mult_poly_schubert], [lrcalc], [], [sage_spkg_install_lrcalc=yes])
     ], [sage_spkg_install_lrcalc=yes],
-    [[#ifndef _HASHTAB_H
-      #include <lrcalc/hashtab.h>
-      #include <lrcalc/vector.h>
+    [[#ifndef _IVECTOR_H
+      #include <lrcalc/ivector.h>
       #endif]])
 ])
diff --git a/build/pkgs/lrcalc/spkg-install.in b/build/pkgs/lrcalc/spkg-install.in
index d6665bfb42..a863950189 100644
--- a/build/pkgs/lrcalc/spkg-install.in
+++ b/build/pkgs/lrcalc/spkg-install.in
@@ -1,9 +1,5 @@
 cd src
 
-# Use newer version of config.guess and config.sub (see Trac #19725)
-cp "$SAGE_ROOT"/config/config.guess .
-cp "$SAGE_ROOT"/config/config.sub .
-
 sdh_configure
 sdh_make
 sdh_make_install
diff --git a/build/pkgs/lrcalc_python/SPKG.rst b/build/pkgs/lrcalc_python/SPKG.rst
new file mode 100644
index 0000000000..cff9d7d7fb
--- /dev/null
+++ b/build/pkgs/lrcalc_python/SPKG.rst
@@ -0,0 +1,22 @@
+lrcalc_python: Littlewood-Richardson calculator
+===============================================
+
+Description
+-----------
+
+Python bindings for the Littlewood-Richardson Calculator
+
+http://sites.math.rutgers.edu/~asbuch/lrcalc/
+
+License
+-------
+
+GNU General Public License V2+
+
+
+Upstream Contact
+----------------
+
+Anders S. Buch (asbuch@math.rutgers.edu)
+
+https://bitbucket.org/asbuch/lrcalc
diff --git a/build/pkgs/lrcalc_python/checksums.ini b/build/pkgs/lrcalc_python/checksums.ini
new file mode 100644
index 0000000000..bdfef8711e
--- /dev/null
+++ b/build/pkgs/lrcalc_python/checksums.ini
@@ -0,0 +1,5 @@
+tarball=lrcalc-VERSION.tar.gz
+sha1=3e9366d9e8b8beccec70b07d174b8f6683c01574
+md5=4ae444d12ed8e0dd770594ea3ef4a208
+cksum=2741305196
+upstream_url=https://pypi.io/packages/source/l/lrcalc/lrcalc-VERSION.tar.gz
diff --git a/build/pkgs/lrcalc_python/dependencies b/build/pkgs/lrcalc_python/dependencies
new file mode 100644
index 0000000000..63e5177ae0
--- /dev/null
+++ b/build/pkgs/lrcalc_python/dependencies
@@ -0,0 +1,5 @@
+$(PYTHON) lrcalc | $(PYTHON_TOOLCHAIN) cython
+
+----------
+All lines of this file are ignored except the first.
+It is copied by SAGE_ROOT/build/make/install into SAGE_ROOT/build/make/Makefile.
diff --git a/build/pkgs/lrcalc_python/install-requires.txt b/build/pkgs/lrcalc_python/install-requires.txt
new file mode 100644
index 0000000000..8b44d97f4b
--- /dev/null
+++ b/build/pkgs/lrcalc_python/install-requires.txt
@@ -0,0 +1 @@
+lrcalc ~=2.1
diff --git a/build/pkgs/lrcalc_python/package-version.txt b/build/pkgs/lrcalc_python/package-version.txt
new file mode 100644
index 0000000000..879b416e60
--- /dev/null
+++ b/build/pkgs/lrcalc_python/package-version.txt
@@ -0,0 +1 @@
+2.1
diff --git a/build/pkgs/lrcalc_python/spkg-install.in b/build/pkgs/lrcalc_python/spkg-install.in
new file mode 100644
index 0000000000..deba1bb42b
--- /dev/null
+++ b/build/pkgs/lrcalc_python/spkg-install.in
@@ -0,0 +1 @@
+cd src && sdh_pip_install .
diff --git a/build/pkgs/lrcalc_python/type b/build/pkgs/lrcalc_python/type
new file mode 100644
index 0000000000..a6a7b9cd72
--- /dev/null
+++ b/build/pkgs/lrcalc_python/type
@@ -0,0 +1 @@
+standard
diff --git a/build/pkgs/sagelib/dependencies b/build/pkgs/sagelib/dependencies
index 960eb95c1c..a68ac961f1 100644
--- a/build/pkgs/sagelib/dependencies
+++ b/build/pkgs/sagelib/dependencies
@@ -1,4 +1,4 @@
-FORCE $(SCRIPTS) arb boost_cropped $(BLAS) brial cliquer cypari cysignals cython ecl eclib ecm flint libgd gap giac givaro glpk gmpy2 gsl iml jinja2 jupyter_core lcalc lrcalc libbraiding libhomfly libpng linbox m4ri m4rie memory_allocator mpc mpfi mpfr $(MP_LIBRARY) ntl numpy pari pip pkgconfig planarity ppl pplpy pycygwin $(PYTHON) ratpoints rw sage_conf singular symmetrica zn_poly $(PCFILES) | $(PYTHON_TOOLCHAIN) sage_setup
+FORCE $(SCRIPTS) arb boost_cropped $(BLAS) brial cliquer cypari cysignals cython ecl eclib ecm flint libgd gap giac givaro glpk gmpy2 gsl iml jinja2 jupyter_core lcalc lrcalc_python libbraiding libhomfly libpng linbox m4ri m4rie memory_allocator mpc mpfi mpfr $(MP_LIBRARY) ntl numpy pari pip pkgconfig planarity ppl pplpy pycygwin $(PYTHON) ratpoints rw sage_conf singular symmetrica zn_poly $(PCFILES) | $(PYTHON_TOOLCHAIN) sage_setup
 
 ----------
 All lines of this file are ignored except the first.
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 b591081ec4..65db959944 100644
--- a/src/sage/libs/lrcalc/lrcalc.pyx
+++ b/src/sage/libs/lrcalc/lrcalc.py
@@ -187,180 +187,24 @@ 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
+from sage.combinat.skew_tableau import SkewTableaux
+from sage.combinat.skew_partition import SkewPartition
+from sage.rings.integer import Integer
+import lrcalc
 
-
-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.
+def _lrcalc_dict_to_sage(result):
+    r"""
+    Translate from lrcalc output format to Sage expected format.
 
     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 <class '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 <class '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 <class 'sage.rings.integer.Integer'>.
-
-    EXAMPLES::
-
-        sage: from sage.libs.lrcalc.lrcalc import coprod
-        sage: coprod([1])      #indirect doctest
-        {([1], []): 1}
+        sage: mult([2,1],[3,2,1],3) # indirect doctest
+        {[3, 3, 3]: 1, [4, 3, 2]: 2, [4, 4, 1]: 1, [5, 2, 2]: 1, [5, 3, 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
-
+    return {_Partitions(la):Integer(k) for la,k in result.items()}
 
 def lrcoef_unsafe(outer, inner1, inner2):
     r"""
@@ -392,18 +236,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 Integer(lrcalc.lrcoef(outer, inner1, inner2))
 
 
 def lrcoef(outer, inner1, inner2):
@@ -510,44 +343,24 @@ 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):
+    result = lrcalc.mult_quantum(part1, part2, maxrows, level, degrees=True)
+    P = quantum.parent()
+    output = {}
+    for i,k in result.items():
+        la = _Partitions(i[0])
+        output[la] = output.get(la, P.zero()) + k*quantum**(i[1])
+    return output
+
+
+def skew(outer, inner, maxrows=-1):
     """
     Compute the Schur expansion of a skew Schur function.
 
@@ -572,14 +385,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 +415,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 {tuple(_Partitions(mu) for mu in la):Integer(k) for la,k in result.items()}
 
 
 def mult_schubert(w1, w2, rank=0):
@@ -646,17 +448,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 {Permutation(list(la)):Integer(k) for la,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 +499,20 @@ 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)
+        ST = SkewTableaux()
+        for data in iterator:
+            yield ST.from_shape_and_word(shape, [i+1 for i in data])
     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)
+        ST = SkewTableaux()
+        for data in iterator:
+            m = max(data) + 1
+            w = [0] * m
+            for j in data:
+                w[j] += 1
+            if w == wt:
+                yield ST.from_shape_and_word(shape, [i+1 for i in data])