#7199: inefficiency of creation of sparse matrices
------------------------------+---------------------------------------------
   Reporter:  zimmerma        |       Owner:  was       
       Type:  enhancement     |      Status:  new       
   Priority:  major           |   Milestone:  sage-4.1.3
  Component:  linear algebra  |    Keywords:            
Work_issues:                  |      Author:            
   Reviewer:                  |      Merged:            
------------------------------+---------------------------------------------
 The following was reported to me by David Monniaux.
 {{{
 sparseflag=True

 def essai1():
     m=identity_matrix(QQ,dimen,sparse=sparseflag)
     compound=m
     for i in xrange(count):
         compound = compound.stack(m)

 def essai2():
     m_rows=identity_matrix(QQ,dimen,sparse=sparseflag).rows()
     compound_l=[]
     for i in xrange(count):
         compound_l += m_rows
     m=Matrix(QQ,compound_l,sparse=sparseflag)

 def essai3():
     m=identity_matrix(QQ,dimen,sparse=sparseflag)
     compound=Matrix(QQ,m.nrows()*count,m.ncols(),sparse=sparseflag)
     for i in xrange(count):
         compound[m.nrows()*i:m.nrows()*(i+1),:] = m
 }}}
 I get with Sage 4.1.1 on a 2.83Ghz Core 2:
 {{{
 sage: count=200
 sage: dimen=30
 sage: timeit('essai1()',number=1)
 1 loops, best of 3: 33.1 s per loop
 sage: timeit('essai2()',number=1)
 1 loops, best of 3: 25.4 s per loop
 sage: timeit('essai3()')
 5 loops, best of 3: 820 ms per loop
 }}}

-- 
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/7199>
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 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-trac?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to