[SciPy-dev] Bug w.r.t. Addition of sparse matrices

Nils Wagner nwagner at mecha.uni-stuttgart.de
Mon Mar 6 06:59:22 EST 2006


Robert Cimrman wrote:
> 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.
>
> _______________________________________________
> Scipy-dev mailing list
> Scipy-dev at scipy.net
> http://www.scipy.net/mailman/listinfo/scipy-dev
>   
How do I change the precision ?

Nils




More information about the SciPy-Dev mailing list