Dear Martin,
On Nov 5, 11:27 pm, Martin Albrecht <[EMAIL PROTECTED]>
wrote:
<snip>
> > So, i could use weightKB(G, d, <intvec of degree weights>) via the
> > interface and get the exponent vectors from there. But this involves a
> > lot of communication between Sage and Singular and therefore is slow.
>
> But this one returns all the information you need at once, doesn't it? If so,
> I'd call it, then get the result as a string and perform string parsing on
> the result. Sometimes it also makes sense to have Singular pre-process the
> data for you such that it is easier to parse.
Thank you for that hint!
By "a lot of communication", I meant the following:
I = <some singular ideal>
sz=len(I)
for n from 1<=n<...:
I[sz+n] = ...
I = I.groebner()
M = I.weightKB(15,'intvec(1,2,3,4,...)')
for x in M:
<do something with list(x.expvec())
As far as i understood from the Singular log, the operation "I[sz
+n]=bla" means to create a new variable sage1001 (or whatever number),
assign sz+n to it, create a new variable sage1002, assign "bla" to it,
perform I.name()[sage1001]=sage1002, and perhaps kill the new
variables (which sometimes is incomplete, as Singular has some memory
leaks). And similar things happen when doing "for x in M".
Now, I do kind of the following:
singular.eval('ideal I = ...')
sz=int(singular('ncols(I)'))
for n from 1<=n<...:
singular.eval('I[%d]=%s'%(sz+n,str(...)))
singular.eval('I=groebner(I)')
singular.eval('def M = weightKB(I,15,intvec(1,2,3,4))')
s=<make Singular print the exponent vectors of lead(M) in a nice
form>
M=<list of list of integers, obtained from parsing s>
The first version is conceptually nicer (everything is a Sage object),
but the second version turned out to be much quicker.
One question concerning the loop "for n from 1<=n ..":
Would it make sense to only create a list of command strings,
afterwards join them with ';' and say singular.eval only once for that
large string? Then, we have only one big data package to send through
the interface, rather than many small data packages.
> This depends on the GB you have. If you just need it in a commutative
> polynomial ring you can call Ideal.groebner_basis('libsingular:std') or
> Ideal.groebner_basis('libsingular:slimgb') on your ideal. If your idea has to
> be a singular object (because it is e.g. in a non-commutative ring) it is
> probably better to stick to Singular for this task as the communication
> overhead would probably kill all your Cython speedups.
This is good to know! I didn't met libsingular before; where can i
read about it?
Unfortunately I deal with non-commutative rings ("SuperCommutative"),
but i hope i will remember your hint for the future!
Yours sincerely
Simon
--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/sage-support
URLs: http://sage.math.washington.edu/sage/ and http://sage.scipy.org/sage/
-~----------~----~----~----~------~----~------~--~---