Closed rwst closed 9 years ago
Changed keywords from gap, bignum, expect, pexpect to gap, bignum, expect, pexpect, libgap
Description changed:
---
+++
@@ -18,4 +18,14 @@
TypeError: unable to convert x (=<integer 301...000 (2566 digits)>) to an integer
-Alternatively, this ticket may discuss abandoning the GAP expect interface for such big number results and use libpari instead.
+The way to go would be to replace gap.eval
with libgap.eval
and it's faster, too:
+
+ +sage: timeit('Integer(gap.eval("Stirling1(100,2)"))') +625 loops, best of 3: 419 µs per loop +sage: timeit('libgap.eval("Stirling1(100,2)").sage()') +625 loops, best of 3: 125 µs per loop +sage: timeit('libgap.eval("Stirling1(1000,2)").sage()') +125 loops, best of 3: 6.45 ms per loop +
+
Description changed:
---
+++
@@ -28,4 +28,12 @@
sage: timeit('libgap.eval("Stirling1(1000,2)").sage()')
125 loops, best of 3: 6.45 ms per loop
+Addendum: even faster would be to use (n-1)!*H(n-1)
for stirling(n,2)
, dependent on #16671:
+ +sage: harmonic_number(99)*factorial(99)==stirling_number1(100,2) +True +sage: timeit('harmonic_number(99)*factorial(99)') +625 loops, best of 3: 56.9 µs per loop +
+
Changed keywords from gap, bignum, expect, pexpect, libgap to gap, bignum, expect, pexpect, libgap, stirling
Description changed:
---
+++
@@ -35,5 +35,7 @@
True
sage: timeit('harmonic_number(99)*factorial(99)')
625 loops, best of 3: 56.9 µs per loop
+sage: timeit('harmonic_number(999)*factorial(999)')
+625 loops, best of 3: 119 µs per loop
Dependencies: #16380
Also with #16380 (which I've added as a dependency because it's not been put into a release yet), we don't have to worry about the startup time of libgap anymore (which was really annoying). +1 to doing this.
This is blocked by:
sage: ans=libgap.eval("UnorderedTuples(['a','b','c'],2)")
sage: type(ans)
<type 'sage.libs.gap.element.GapElement_List'>
sage: a=ans.sage()
---------------------------------------------------------------------------
NotImplementedError Traceback (most recent call last)
<ipython-input-4-43379484318b> in <module>()
----> 1 a=ans.sage()
/home/ralf/sage/local/lib/python2.7/site-packages/sage/libs/gap/element.so in sage.libs.gap.element.GapElement_List.sage (build/cythonized/sage/libs/gap/element.c:14661)()
/home/ralf/sage/local/lib/python2.7/site-packages/sage/libs/gap/element.so in sage.libs.gap.element.GapElement_List.sage (build/cythonized/sage/libs/gap/element.c:14661)()
/home/ralf/sage/local/lib/python2.7/site-packages/sage/libs/gap/element.so in sage.libs.gap.element.GapElement.sage (build/cythonized/sage/libs/gap/element.c:8749)()
See #16750
Changed dependencies from #16380 to #16380, #16750
OK, now that strings get to GAP, back they get as GapElement_List
of chars:
sage: ans = libgap.eval("UnorderedTuples(['a', 'b', 'c'],2)"); ans
[ "aa", "ab", "ac", "bb", "bc", "cc" ]
sage: type(ans[0])
<type 'sage.libs.gap.element.GapElement_List'>
sage: ans.sage()
[["'a'", "'a'"],
["'a'", "'b'"],
["'a'", "'c'"],
["'b'", "'b'"],
["'b'", "'c'"],
["'c'", "'c'"]]
Shouldn't lists of chars be converted to strings?
Author: Ralf Stephan
Changed dependencies from #16380, #16750 to #16380
Merged: #16750
Branch pushed to git repo; I updated commit sha1. New commits:
240cc10 | 16719 reviewer's patch: attempt to fix previous patch |
Branch pushed to git repo; I updated commit sha1. New commits:
47f0796 | Merge branch 'develop' into t/16719/replace_gap_eval_with_libgap_eval_in_combinat_combinat_py |
7cc26d5 | Improve GAP String handling |
6fe1fc5 | Treat the empty GAP list as list and not as string |
6a4892d | Merge branch 't/16750/libgap_fails_converting_string_gapelements_to_sage' into t/16719/replace_gap_eval_with_libgap_eval_in_combinat_combinat_py |
a1269fb | 16719: unordered_tuples() distinguishes now between set types |
It felt more natural to give tuples of chars as string, but tuples of char+string as list of strings. If the latter had been the original behaviour the GAP T_CHAR hassle wouldn't have been necessary.
Please review.
Changed dependencies from #16380 to none
Branch pushed to git repo; I updated commit sha1. New commits:
e82786b | Merge branch 'develop' into t/16719/replace_gap_eval_with_libgap_eval_in_combinat_combinat_py |
Note that this will conflict with #13982 for unordered_tuples
(FYI I handled GAP's output as strings differently).
Changed merged from #16750 to none
Dependencies: #16750
I wouldn't mind removing the unordered tuples bit from this patch, especially for speed reasons, and choice of algorithm. It's just that I don't like it that you simply remove that doctest that results in ['aa', 'ab', 'ac', 'bb', 'bc', 'cc']
. I think you should support it.
Branch pushed to git repo; I updated commit sha1. New commits:
5b156ad | 16719: revert change to unordered_tuples(), handled by 13982 |
For bell_number()
, I'm making the change at #17157, so you can remove that piece.
Changed branch from u/rws/replace_gap_eval_with_libgap_eval_in_combinat_combinat_py to u/jdemeyer/ticket/16719
Changed dependencies from #16750 to #17157
Reviewer: Jeroen Demeyer
Changed branch from u/jdemeyer/ticket/16719 to u/vbraun/ticket/16719
The reviewer commits look good to me. I've added a patch to make the calls to my beautiful library interface less ugly ;-)
New commits:
9f4777d | Beautify libgap calls |
Changed reviewer from Jeroen Demeyer to Jeroen Demeyer, Volker Braun
Branch pushed to git repo; I updated commit sha1 and set ticket back to needs_review. Last 10 new commits:
34c9b4c | Changes from the reviewers. |
b47af6a | A minor tweaking of the doc. |
53a9d7e | Families return output based on order of variable names. Fixed coercion issue. |
339b71d | Fixed some typos. |
3ce3f6a | Merge branch 'public/algebras/weyl_clifford-15300' of git://trac.sagemath.org/sage into clifford |
8698275 | lifting bilinear forms onto exterior algebras |
a002f4b | Some tweaks to lifted_bilinear_form and fixed doctest. |
ff27bdc | further fixes |
330617c | Merge commit 'ff27bdc5d87967d0e7fd5c1305cef4340db816c7' into ticket/17157 |
d6698e2 | Merge already-closed #17157 to resolve conflict |
Changed branch from u/vbraun/ticket/16719 to d6698e2
As first reported in #15625 (comment:7) with
lucas_number1
, the same problem is encountered with gap evaluation of Stirling numbers:The way to go would be to replace
gap.eval
withlibgap.eval
and it's faster, too:Addendum: even faster would be to use
(n-1)!*H(n-1)
forstirling(n,2)
, dependent on #16671:Depends on #17157
CC: @vbraun
Component: combinatorics
Keywords: gap, bignum, expect, pexpect, libgap, stirling
Author: Ralf Stephan
Branch/Commit:
d6698e2
Reviewer: Jeroen Demeyer, Volker Braun
Issue created by migration from https://trac.sagemath.org/ticket/16719