#11657: the vector(...) function is extremely slow
-----------------------------------------+----------------------------------
   Reporter:  was                        |          Owner:  jason, was          
     
       Type:  defect                     |         Status:  needs_review        
     
   Priority:  minor                      |      Milestone:  sage-4.7.2          
     
  Component:  linear algebra             |       Keywords:                      
     
Work_issues:                             |       Upstream:  N/A                 
     
   Reviewer:  Rob Beezer, William Stein  |         Author:  William Stein, Rob 
Beezer
     Merged:                             |   Dependencies:                      
     
-----------------------------------------+----------------------------------
Changes (by newvalueoldvalue):

  * status:  needs_info => needs_review
  * reviewer:  => Rob Beezer, William Stein
  * author:  Rob Beezer => William Stein, Rob Beezer


Old description:

> I was shocked by this:
> {{{
>
> sage: timeit('vector(ZZ,100)')
> 625 loops, best of 3: 302 µs per loop
> sage: timeit('(ZZ^100)(0)')
> 625 loops, best of 3: 24.9 µs per loop
> sage: timeit('(ZZ^100).zero_vector()')
> 625 loops, best of 3: 21.8 µs per loop
> }}}
>
> I didn't realize that the special case of the zero vector is incredibly
> slow for the {{{vector}}} function.  This needs to be fixed.
>
> '''Apply''':
>   1.  [attachment:trac_11657-zero-vector-speedup.patch]

New description:

 I was shocked by this:
 {{{

 sage: timeit('vector(ZZ,100)')
 625 loops, best of 3: 302 µs per loop
 sage: timeit('(ZZ^100)(0)')
 625 loops, best of 3: 24.9 µs per loop
 sage: timeit('(ZZ^100).zero_vector()')
 625 loops, best of 3: 21.8 µs per loop
 }}}

 I didn't realize that the special case of the zero vector is incredibly
 slow for the {{{vector}}} function.  This needs to be fixed.

 '''Apply''':
   1.  [attachment:trac_11657-rewrite.patch]
   1.  [attachment:trac_11657-zero-vector-edits.patch]

--

Comment:

 "rewrite" patch has positive review from me.

 "edits" patch addresses all four comments above.  Needs review.

 Combination of two patches passes all tests.  Timings are now very similar
 for all four ways to get a zero vector - within about 3 microseconds
 difference in overhead.

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