#5184: [with patch, needs work] nonzero_positions is broken for sparse vectors
----------------------------+-----------------------------------------------
 Reporter:  jhpalmieri      |       Owner:  jhpalmieri
     Type:  defect          |      Status:  assigned  
 Priority:  major           |   Milestone:  sage-3.4.1
Component:  linear algebra  |    Keywords:            
----------------------------+-----------------------------------------------

Comment(by cwitty):

 Instead of tests like {{{if a != 0:}}}, it should use {{{if a:}}}.   The
 code is a little uglier and harder to understand, but it's much faster;
 these are approximations of the sorts of timing differences you would see:
 {{{
 sage: foo = QQbar(3)
 sage: timeit('bool(foo)')
 625 loops, best of 3: 1.24 µs per loop
 sage: timeit('foo != 0r')
 625 loops, best of 3: 100 µs per loop
 sage: foo = 3
 sage: timeit('bool(foo)')
 625 loops, best of 3: 286 ns per loop
 sage: timeit('foo != 0r')
 625 loops, best of 3: 4.2 µs per loop
 }}}

 (Also, in the places where you deleted "A dense a sparse", is it worth
 adding a note that says something like "(This is true even if one is
 sparse and the other is dense.)"?)

-- 
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/5184#comment:4>
Sage <http://sagemath.org/>
Sage - Open Source Mathematical Software: Building the Car Instead of 
Reinventing the Wheel

--~--~---------~--~----~------------~-------~--~----~
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