On Jul 30, 2:22 pm, Niles <nil...@gmail.com> wrote:
> On Jul 30, 7:36 am, mario <mario.pern...@gmail.com> wrote:
>
> > I have not tried using other rings; can you give me an example to try?
>
> Sure!  The patch works over any commutative ring that sage supports;
> here are a couple:
>
> sage: M.<a,b,c,d> = MPowerSeriesRing(GF(11),4); M
> Multivariate Power Series Ring in a, b, c, d over Finite Field of size
> 11
> sage: p = 3 + a + 7*b + 2*c^2 - 5*a^2*d - b^4 - 5*c*d^3 + 5*c^5 - c^8
> + 2*a^5*b^2*c^2 + M(0).O(10)
> sage: %time p^(-30);
>
> sage: P.<x,y,z> = PolynomialRing(ZZ,3); P
> Multivariate Polynomial Ring in x, y, z over Integer Ring
> sage: H.<f,g,h,k> = MPowerSeriesRing(P,4); H
> Multivariate Power Series Ring in f, g, h, k over Multivariate
> Polynomial Ring in x, y, z over Integer Ring
> sage: q = 1 + H(-x*y - y^2 - 4*y*z + 3*z^2 + 1)*h + H(x*y + 3*x*z +
> y)*k + H(-x^2 + y^2 + x*z - 2*z^2 + z)*f + H(-x*y + 4*x*z - z^2 +
> 2*x)*h*k + H(-y^2 + 2*z^2 + 12*y - 1)*f*g*h^2 + H(-x*y - 12*z^2 -
> y)*f^2*g^2 + H(1 + 6*z)*f*k^3 + H(0).O(5)
> sage: %time q^(-1);
>
> Also, it might make more sense to compare your code with sage's
> multivariate polynomial arithmetic directly; the multivariate power
> series patch is mostly just a wrapper for the polynomial arithmetic,
> and I haven't (yet) made any attempt to optimize it.  Here are the
> commands to construct some relevant polynomial rings:
>
> sage: Q.<x,y,z,w,v> = PolynomialRing(GF(7),5); Q
> Multivariate Polynomial Ring in x, y, z, w, v over Finite Field of
> size 7
> sage: R.<a,b,c> = PolynomialRing(RR,3); R
> Multivariate Polynomial Ring in a, b, c over Real Field with 53 bits
> of precision
>

With GF rmpoly.sage I tried your example with
GF(11)
(3+a+7*b+2*c^2-5*a^2*d-b^4-5*c*d^3+5*c^5-c^8+2*a^5*b^2*c^2+M(0).O(10)
rmpoly.sage 0.17s  MPowerSeriesRing 0.19s
and 5 examples with GF(7):
rmpoly.sage  MPowerSeriesRing
(1 + 2*a + 3*b + 4*d + L(0).O(16))^-5
0.16               0.09
(1 + a^3 + b^3 + c^4 + d^4 + L(0).O(15))^-20
0.01               0.03
(1 + a + b + a*b + a^2 + b^2 + Z(0).O(30))^-20
0.37               0.22
(1 + a + 2*b - a*b + 3*a^2 - b^2 + L(0).O(30))^-20
0.43               0.26
(1+a+12*b-10*a*b+13*a^2-7*b^2+L(0).O(30))^-20     0.35
0.23

so for power series on GF rmpoly is slower.

With real fields I tried the last five examples; with enough precision
it is OK (precision 100,53,53,100,170
used respectively in example 1,2,3,4,5)


rmpoly cannot do your example H.<f,g,h,k> = MPowerSeriesRing(P,4)

rmpoly cannot compete with Sage polynomials, although it is not so
bad; here is a Fateman test
sage: R.<x,y,z,t> = QQ[]
n = 15
sage: p1 = (1+x+y+z+t)^n
sage: p2 = p1 + 1
sage: time h = p1*p2
CPU times: user 9.82 s, sys: 0.01 s, total: 9.83 s
Wall time: 9.83 s

rmpoly.sage takes 47.8s, rmpoly.py19.9s

with R.<x,y,z,t> = PolynomialRing(GF(7),4) and n=20 Sage takes 0.7s,
rmpoly.sage 13.6s


To summarize rmpoly is faster than Sage only on power series on QQ;
I guess that a C library dedicated to power series would
be a few times faster than rmpoly power series on QQ .

Mario

-- 
To post to this group, send an email to sage-devel@googlegroups.com
To unsubscribe from this group, send an email to 
sage-devel+unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URL: http://www.sagemath.org

Reply via email to