#11589: faster zero matrix creation
------------------------------+---------------------------------------------
   Reporter:  malb            |          Owner:  jason, was                 
       Type:  enhancement     |         Status:  needs_review               
   Priority:  major           |      Milestone:  sage-4.7.2                 
  Component:  linear algebra  |       Keywords:                             
Work_issues:                  |       Upstream:  N/A                        
   Reviewer:                  |         Author:  Martin Albrecht, Simon King
     Merged:                  |   Dependencies:                             
------------------------------+---------------------------------------------

Comment(by malb):

 Here are timings on my machine (Macbook Pro, i7):

 __no patch__

 {{{
 #!python
 sage: for n in (50,500,1000): timeit('A=matrix(GF(2),%d,%d)'%(n,n))
 ....:
 625 loops, best of 3: 98.1 µs per loop
 625 loops, best of 3: 115 µs per loop
 625 loops, best of 3: 130 µs per loop

 sage: for n in (50,500,1000): timeit('A=matrix(GF(3),%d,%d)'%(n,n))
 ....:
 625 loops, best of 3: 93.3 µs per loop
 625 loops, best of 3: 538 µs per loop
 125 loops, best of 3: 2.41 ms per loop

 sage: for n in (50,500,1000): timeit('A=matrix(GF(625,"a"),%d,%d)'%(n,n))
 ....:
 625 loops, best of 3: 189 µs per loop
 125 loops, best of 3: 3.7 ms per loop
 25 loops, best of 3: 14.1 ms per loop
 }}}

 __first only__

 {{{
 #!python
 sage: for n in (50,500,1000): timeit('A=matrix(GF(2),%d,%d)'%(n,n))
 ....:
 625 loops, best of 3: 104 µs per loop
 625 loops, best of 3: 108 µs per loop
 625 loops, best of 3: 112 µs per loop

 sage: for n in (50,500,1000): timeit('A=matrix(GF(3),%d,%d)'%(n,n))
 ....:
 625 loops, best of 3: 95.5 µs per loop
 625 loops, best of 3: 442 µs per loop
 625 loops, best of 3: 1.48 ms per loop

 sage: for n in (50,500,1000): timeit('A=matrix(GF(625,"a"),%d,%d)'%(n,n))
 ....:
 625 loops, best of 3: 184 µs per loop
 125 loops, best of 3: 3.7 ms per loop
 25 loops, best of 3: 13.8 ms per loop
 }}}

 __with both__

 {{{
 #!python
 sage: for n in (50,500,1000): timeit('A=matrix(GF(2),%d,%d)'%(n,n))
 ....:
 625 loops, best of 3: 94.5 µs per loop
 625 loops, best of 3: 98.9 µs per loop
 625 loops, best of 3: 108 µs per loop

 sage: for n in (50,500,1000): timeit('A=matrix(GF(3),%d,%d)'%(n,n))
 ....:
 625 loops, best of 3: 95 µs per loop
 625 loops, best of 3: 438 µs per loop
 625 loops, best of 3: 1.49 ms per loop

 sage: for n in (50,500,1000): timeit('A=matrix(GF(625,"a"),%d,%d)'%(n,n))
 ....:
 625 loops, best of 3: 176 µs per loop
 125 loops, best of 3: 1.74 ms per loop
 125 loops, best of 3: 6.24 ms per loop
 }}}

 My take: it's definitely faster for large-ish matrices and undecided for
 small matrices, i.e. my timings for 50x50 are rather unstable.

-- 
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/11589#comment:12>
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