On 5/1/07, Nick Alexander <ncalexan@xxxxxxxxxxxx> wrote:
>
> This is from a heavily hacked sage 2.3, so this might no longer be the
> case. (How do I run sage 2.5 on sage.math without building it myself?)
>
> Below is a snip from `prun'. Notice that add and sub are called about
> as frequently as mul, but are significantly slower! Any thoughts?
>
> The calculations at hand are taking place in Integers(3**6)['x',
> 'y']. I think that negates any "translation to Singular" speedups,
> since Singular doesn't handle that ring. Maybe this was all pyrexed?
Some quick remarks:
(1) Multivariate polynomial arithmetic in SAGE in the generic case is still
fairly dumb and involves manipulating Python lists.
(2) Singular *is* capable of handling the ring Integers(3**6)['x,y'].
Check it out (ok, I use 3**5 below):
sage: r = singular.ring(3^5, '(x,y)', 'dp')
sage: r
// characteristic : 241
// number of vars : 2
// block 1 : ordering dp
// : names x y
// block 2 : ordering C
sage: singular('(x+y)^10')
x^10+10*x^9*y+45*x^8*y^2+120*x^7*y^3-31*x^6*y^4+11*x^5*y^5-31*x^4*y^6+120*x^3*y^7+45*x^2*y^8+10*x*y^9+y^10
sage: R.<x,y> = Integers(3^5)[x,y]
sage: (x+y)^10
y^10 + 10*x*y^9 + 45*x^2*y^8 + 120*x^3*y^7 + 210*x^4*y^6 + 9*x^5*y^5 +
210*x^6*y^4 + 120*x^7*y^3 + 45*x^8*y^2 + 10*x^9*y + x^10
So singular seems to be capable of *arithmetic* modulo n for any n.
It just doesn't do
Groebner basis modulo n for n composite.
(3) SAGE-2.5 will have the first version of an optimized wrapper for
arithmetic using the Singular
C++ library directly, which Martin Albrecht wrote. It only supports
QQ and GF(p) though. Here's
how to use it in SAGE-2.5:
sage: from sage.rings.multi_polynomial_libsingular import
MPolynomialRing_libsingular
sage: P.<x,y> = MPolynomialRing_libsingular(QQ,2)
sage: f = (x+y)^10
f
sage: f
x^10 + 10*x^9*y + 45*x^8*y^2 + 120*x^7*y^3 + 210*x^6*y^4 + 252*x^5*y^5
+ 210*x^4*y^6 + 120*x^3*y^7 + 45*x^2*y^8 + 10*x*y^9 + y^10
sage: time g=f^10
CPU times: user 0.00 s, sys: 0.00 s, total: 0.00 s
Wall time: 0.04
sage: time v=[f*f for _ in range(10^4)]
CPU times: user 0.15 s, sys: 0.01 s, total: 0.16 s
Wall time: 0.25
You might be able to work with this over QQ, and reduce every once in
a while, or just
add a reduce-mod-n method. (??)
4) Maybe Martin could add support for polynomials over Z/nZ to his
libsingular interface,
or at least discuss what might be involved.
> Nick
>
> PS. I can provide the code if need be; it's not elegant :)
>
> PPS. Random element for multipolynomial rings is not implemented.
>
> 747166 function calls in 50.847 CPU seconds
>
> Ordered by: internal time
>
> ncalls tottime percall cumtime percall filename:lineno(function)
> 1054 19.022 0.018 19.109 0.018
> multi_polynomial_element.py:174(_add_)
> 1054 9.233 0.009 11.052 0.010
> multi_polynomial_element.py:178(_sub_)
> 1040 8.502 0.008 13.388 0.013
> multi_polynomial_element.py:182(_mul_)
> 137436 3.721 0.000 3.721 0.000
> {sage.rings.integer_mod.IntegerMod}
> 2086 1.994 0.001 1.994 0.001 {hash}
> 137436 1.884 0.000 6.726 0.000
> integer_mod_ring.py:434(__call__)
> 32952 1.824 0.000 2.021 0.000
> multi_polynomial_ring.py:677(greater_tuple_dp)
>
> >
>
--
William Stein
Associate Professor of Mathematics
University of Washington
http://www.williamstein.org
--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to sage-devel@xxxxxxxxxxxxxxxx
To unsubscribe from this group, send email to
sage-devel-unsubscribe@xxxxxxxxxxxxxxxx
For more options, visit this group at http://groups.google.com/group/sage-devel
URLs: http://sage.scipy.org/sage/ and http://modular.math.washington.edu/sage/
-~----------~----~----~----~------~----~------~--~---
|