On 9/29/07, Mike Hansen <[EMAIL PROTECTED]> wrote:
> I've been recently doing some work which requires linear algebra over
> fraction fields of polynomial rings.  I found that this is _much_
> slower than it should be.
>
> sage: hlqp5 = [ symmetrica.hall_littlewood(p) for p in Partitions(5) ]
>
> sage: hlqp5_m = matrix([[ x.coefficient(p) for p in Partitions(5) ]
> for x in hlqp5])
>
> sage: hlqp5_m.parent()
> Full MatrixSpace of 7 by 7 dense matrices over Polynomial Ring in x
> over Integer Ring

There is something *extremely* fishy about the base ring here!  It's
a *multivariate* polynomial ring:

sage: type(hlqp5_m.base_ring())
<class 
'sage.rings.polynomial.multi_polynomial_ring.MPolynomialRing_polydict_domain'>

If you instead change the base to a single-variate polynomial ring,
then the speed is much more reasonable:

sage: s = hlqp5_m.change_ring(ZZ['x'])
sage: time w=s^(-1)
CPU times: user 0.10 s, sys: 0.00 s, total: 0.10 s

Even 8 works pretty quickly:

sage: hlqp8 = [ symmetrica.hall_littlewood(p) for p in Partitions(8) ]
sage: hlqp8_m = matrix([[ x.coefficient(p) for p in Partitions(8) ]
for x in hlqp8])
sage: s = hlqp8_m.change_ring(ZZ['x']); s
22 x 22 dense matrix over Univariate Polynomial Ring in x over Integer Ring
sage: time w=s^(-1)
CPU times: user 2.13 s, sys: 0.04 s, total: 2.17 s
Wall time: 2.29
sage: time t=s*s
CPU times: user 0.24 s, sys: 0.00 s, total: 0.24 s


>
> sage: time hlqp5_i = hlqp5_m^(-1)
> CPU times: user 1.06 s, sys: 0.19 s, total: 1.26 s
> Wall time: 1.42
>
> sage: prun hlqp5_i = hlqp5_m^(-1)
>          570758 function calls (570193 primitive calls) in 2.817 CPU seconds
>
>    Ordered by: internal time
>
>    ncalls  tottime  percall  cumtime  percall filename:lineno(function)
>      7234    0.184    0.000    0.586    0.000 pexpect.py:914(expect_list)
>      7234    0.166    0.000    1.302    0.000 expect.py:549(_eval_line)
>      7234    0.125    0.000    1.634    0.000 singular.py:325(eval)
>     14468    0.109    0.000    0.109    0.000 {posix.write}
>      4398    0.101    0.000    0.127    0.000
> multi_polynomial_element.py:277(__init__)
>      7269    0.099    0.000    0.296    0.000 pexpect.py:498(read_nonblocking)
>      7234    0.090    0.000    1.435    0.000 expect.py:637(eval)
> ...
>
>
> I'm not sure why the slow pexpect interface is being used, but I
> definitely thing it shouldn't be.  I haven't been able to track down
> where it is being introduced.  Does someone more familiar with this
> area know why this is happening?
>
> Thanks,
> Mike
>
> P.S.  Does SAGE already have an efficient way to obtain the inverse of
> a matrix that is known to be upper or lower triangular in advance?
>
> >
>


-- 
William Stein
Associate Professor of Mathematics
University of Washington
http://wstein.org

--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to sage-devel@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
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/
-~----------~----~----~----~------~----~------~--~---

Reply via email to