[SciPy-dev] Bug w.r.t. Addition of sparse matrices
Robert Cimrman
cimrman3 at ntc.zcu.cz
Mon Mar 6 06:49:10 EST 2006
Nils Wagner wrote:
> The addition of sparse matrices results in wrong results (see add.py for
> details).
>
> Nils
>
>
> ------------------------------------------------------------------------
>
> from scipy import *
> from scipy.sparse import *
> A = rand(3,3)
> B = rand(3,3)
> A_csr = csr_matrix(A)
> B_csr = csr_matrix(B)
> C_csr = A_csr+B_csr
> C = A + B
> print C[0,0], C_csr[0,0], 'should be zero',C[0,0]-C_csr[0,0]
I think it works ok:
$ python add.py
0.393709556483 0.393709570169 should be zero -1.36865185851e-08
1e-8 is the float precision... Try using doubles.
r.
More information about the SciPy-Dev
mailing list