[SciPy-user] Addition of sparse matrices

Ed Schofield schofield at ftw.at
Tue Mar 7 02:52:43 CST 2006


Nils Wagner wrote:
> I am sorry but I cannot resolve my problem w.r.t. to addition of sparse 
> matrices.
> I tried astype('d') and astype('D').
> Please can you exemplify how to fix it.
>   
I agree there's a bug with adding double precision csr matrices.  I
tried last night to find out what's wrong, but didn't find it.  The
double precision FORTRAN function dcscadd is being called correctly. 
Travis, Robert, do you have any idea what's going on?  Adding a zero CSC
or CSR matrix also introduces an error of the order of 1E-8.  Nils, if
they don't have time, could you please file a bug report?  You can work
around it for now by using complex data types and then casting back to
double type.  For example, this works:

>>> (A_csr.astype('D') + B_csr.astype('D')).astype('d')[0,0] - C[0,0]
0.0

-- Ed



More information about the SciPy-user mailing list