[Scipy-tickets] [SciPy] #316: adding sparse matrices sometimes gives wrong result

SciPy scipy-tickets at scipy.net
Mon Dec 4 09:42:41 CST 2006


#316: adding sparse matrices sometimes gives wrong result
---------------------------------+------------------------------------------
 Reporter:  martin_wiechert      |        Owner:  somebody
     Type:  defect               |       Status:  new     
 Priority:  normal               |    Milestone:          
Component:  scipy.sparse         |      Version:  devel   
 Severity:  critical             |   Resolution:          
 Keywords:  sparse, wrong value  |  
---------------------------------+------------------------------------------
Comment (by martin_wiechert):

 Apparently the wrong dense representation seen above comes from an (I
 suppose) illegal sparse representation of a + a.T
 {{{
 >>> (a + a.T)
 <4x4 sparse matrix of type '<type 'numpy.float64'>'
         with 7 stored elements (space for 10)
         in Compressed Sparse Column format>
 >>> (a + a.T).indptr
 array([0, 3, 4, 5, 7])
 >>> (a + a.T).rowind
 array([0, 3, 0, 1, 2, 0, 3, 0, 0, 0])
 >>> (a + a.T).data
 array([ 1., -1.,  1.,  2.,  2., -1.,  2.,  0.,  0.,  0.])
 }}}
 column zero has row indices 0,3,0, i.e. the top left entry is present
 twice. Indeed, the corresponding data entries sum to the correct value.

 Sam Zhang has reported an analogous issue with coo matrices on the mailing
 list.

-- 
Ticket URL: <http://projects.scipy.org/scipy/scipy/ticket/316#comment:1>
SciPy <http://www.scipy.org/>
SciPy is open-source software for mathematics, science, and engineering.


More information about the Scipy-tickets mailing list