Opened 10 years ago
Closed 10 years ago
#6628 closed enhancement (fixed)
[with patch, positive review] Singular functions via libSingular
Reported by: | malb | Owned by: | malb |
---|---|---|---|
Priority: | major | Milestone: | sage-4.1.2 |
Component: | commutative algebra | Keywords: | singular, libsingular, commutative algebra |
Cc: | burcin | Merged in: | Sage 4.1.2.alpha0 |
Authors: | Michael Brickenstein, Martin Albrecht | Reviewers: | Alex Ghitza |
Report Upstream: | Work issues: | ||
Branch: | Commit: | ||
Dependencies: | Stopgaps: |
Description
The attached patch implements the following:
sage: P = PolynomialRing(GF(127),10,'x') sage: I = Ideal(P.random_element() for _ in range(3000)) sage: from sage.libs.singular.function import singular_function, lib sage: groebner = singular_function('groebner') sage: %time groebner(I) CPU times: user 0.07 s, sys: 0.00 s, total: 0.08 s Wall time: 0.08 s [1]
For comparison, the Singular pexpect interface needs almost two seconds for the same task (due to string parsing on both ends, IPC, etc.)
sage: %time I.groebner_basis() CPU times: user 0.96 s, sys: 0.24 s, total: 1.21 s Wall time: 1.92 s [1]
This patch requires an updated Singular SPKG (see below).
Attachments (2)
Change History (18)
comment:1 Changed 10 years ago by
- This patch depends on #6596
- The updated SPKG is available at http://sage.math.washington.edu/home/malb/spkgs/singular-3-1-0-4-20090723.spkg
comment:2 Changed 10 years ago by
- Cc burcin added
comment:3 Changed 10 years ago by
Burcin, I just replaced the patch to fix a doctest failure.
comment:4 Changed 10 years ago by
Btw. this also works now:
sage: from sage.libs.singular.function import singular_function, lib sage: groebner = singular_function('groebner') sage: groebner? Type: SingularLibraryFunction Base Class: <type 'sage.libs.singular.function.SingularLibraryFunction'> String Form: groebner (singular function) Namespace: Interactive File: /usr/local/sage-4.1/local/lib/python2.6/site-packages/sage/libs/singular/function.so Docstring: groebner -------- Procedure from library `standard.lib' (*note standard_lib::). *Syntax:* `groebner (' ideal_expression `)' `groebner (' module_expression `)' `groebner (' ideal_expression`,' int_expression `)' `groebner (' module_expression`,' int_expression `)' ...
comment:5 Changed 10 years ago by
Hi! It looks very promosing. However, I have difficulties to apply the patch. Using sage-4.1.0 and the updated singular spkg:
I tried it with and without the refactoring patch, also using a fresh installation:
sage -hg import ~/Downloads/libsingular_functions.patch applying /Users/michael/Downloads/libsingular_functions.patch patching file module_list.py Hunk #1 FAILED at 441 1 out of 1 hunks FAILED -- saving rejects to file module_list.py.rej unable to find 'sage/libs/singular/polynomial.pyx' for patching 1 out of 1 hunks FAILED -- saving rejects to file sage/libs/singular/polynomial.pyx.rej patching file sage/libs/singular/singular-cdefs.pxi Hunk #3 FAILED at 207 Hunk #4 succeeded at 215 with fuzz 2 (offset -43 lines). Hunk #7 FAILED at 853 2 out of 7 hunks FAILED -- saving rejects to file sage/libs/singular/singular-cdefs.pxi.rej patching file sage/libs/singular/singular.pxd Hunk #1 FAILED at 0 Hunk #2 FAILED at 26 2 out of 2 hunks FAILED -- saving rejects to file sage/libs/singular/singular.pxd.rej patching file sage/libs/singular/singular.pyx Hunk #1 FAILED at 24 Hunk #2 succeeded at 514 with fuzz 2 (offset -15 lines). Hunk #3 FAILED at 593 2 out of 3 hunks FAILED -- saving rejects to file sage/libs/singular/singular.pyx.rej patching file sage/rings/polynomial/multi_polynomial_libsingular.pyx Hunk #1 FAILED at 1906 Hunk #2 FAILED at 2019 2 out of 2 hunks FAILED -- saving rejects to file sage/rings/polynomial/multi_polynomial_libsingular.pyx.rej
Michael
comment:6 Changed 10 years ago by
Hi Michael, this is strange, here is what works for me
- I installed the new Singular SPKG
hg qimport http://trac.sagemath.org/sage_trac/raw-attachment/ticket/6596/libsingular_refactoring.patch
hg qimport http://trac.sagemath.org/sage_trac/raw-attachment/ticket/6628/libsingular_functions.patch
sage -b
I have no failed hunks etc. with that.
comment:7 Changed 10 years ago by
I am happy with the refactoring of my code :-). I played with it and I like it. From the Singular side, this nontrivial patch looks fine.
comment:8 Changed 10 years ago by
Here some different timings with even better factor: opposite kind of example: very tiny input, output and almost nothing to compute, replaces some singular interpreter call via pexpect with libsingular kernel function call
from sage.libs.singular import function as sf intersect=sf.SingularKernelFunction("intersect") sage: P.<x,y,z>=QQ[] sage: j=P.ideal(x,z) sage: i=P.ideal(x,y) sage: timeit("z=i.intersection(j)") 125 loops, best of 3: 5.12 ms per loop sage: timeit("z=intersect(i,j)") 625 loops, best of 3: 60.9 µs per loop
comment:9 Changed 10 years ago by
It seems this patch makes docbuild choke because
groebner --------
is contained in one docstring.
comment:10 Changed 10 years ago by
fixed in updated patch.
comment:11 Changed 10 years ago by
On IRC:
[13:02] <mvngu> malb: The package singular-3-1-0-4-20090723.spkg compiles OK on t2!
comment:12 Changed 10 years ago by
- Reviewers set to Alex Ghitza
- Summary changed from [with patch, needs review] Singular functions via libSingular to [with patch, positive review] Singular functions via libSingular
This stuff is great! I've attached a small referee patch that fixes some very minor typos.
I will note that line 280 of singular-cdefs.pxi
is not entirely confidence-inspiring, but I believe the best way to test and refine this stuff is to get it into Sage and start using it a lot.
Note to the release manager: as pointed out above, one must first merge the new Singular spkg, and the patch(es) at #6596.
comment:13 follow-up: ↓ 14 Changed 10 years ago by
The referee patch looks good. I think the next step would be to port stuff in multi_polynomial_ideal.py
to use this new stuff and see what happens.
comment:14 in reply to: ↑ 13 Changed 10 years ago by
Replying to malb:
The referee patch looks good. I think the next step would be to port stuff in
multi_polynomial_ideal.py
to use this new stuff and see what happens.
Indeed. I'm expecting awesomeness (more Singular functionality readily exposed in Sage), speed, and the occasional bug fix.
I'll try to have a look at #6596 soon, but it's a bit bigger, and it will probably take a few days.
comment:15 Changed 10 years ago by
regarding 280: I was a little bit confused, as I thought it would be the same type in idrec and sleftv. But it's indeed void* in sleftv, so the code is correct, but the comment is wrong. Nothing dangerous, you can remove the warning. Michael
comment:16 Changed 10 years ago by
- Merged in set to Sage 4.1.2.alpha0
- Resolution set to fixed
- Status changed from new to closed
Merged both patches.