#18231: constructing matrices is very slow
------------------------------+----------------------------
   Reporter:  vdelecroix      |            Owner:
       Type:  defect          |           Status:  new
   Priority:  major           |        Milestone:  sage-6.7
  Component:  linear algebra  |         Keywords:
  Merged in:                  |          Authors:
  Reviewers:                  |  Report Upstream:  N/A
Work issues:                  |           Branch:
     Commit:                  |     Dependencies:
   Stopgaps:                  |
------------------------------+----------------------------
 The problem is in the code which looks like the following
 {{{
 def test1():
     K = QuadraticField(2)
     for _ in range(100):
         i = randint(2,3)
         j = randint(2,3)
         m = matrix(K, i, j, range(i*j))
 }}}
 It causes the various matrix spaces to rebuilt almost each time! If we
 compare with
 {{{
 def test2():
     K = QuadraticField(2)
     M = {(i,j): MatrixSpace(K,i,j) for i in range(2,4) for j in
 range(2,4)}
     for _ in range(100):
         i = randint(2,3)
         j = randint(2,3)
         m = M[i,j](range(i*j))
 }}}
 then we got
 {{{
 sage: %timeit test1()
 10 loops, best of 3: 55 ms per loop
 sage: %timeit test2()
 100 loops, best of 3: 6.49 ms per loop
 }}}

 This is one of the reason why the creation of Polyhedron is so slow (see
 #18213).

--
Ticket URL: <http://trac.sagemath.org/ticket/18231>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica, 
and MATLAB

-- 
You received this message because you are subscribed to the Google Groups 
"sage-trac" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sage-trac.
For more options, visit https://groups.google.com/d/optout.

Reply via email to