incorrect sign when subtracting from sparse(0)

David Bateman adb014 at gmail.com
Thu Jan 3 16:32:13 CST 2008


David Bateman wrote:
> Thomas Kasper wrote:
>> Bug report for Octave 3.0.0 configured for i686-pc-linux-gnu
>>
>> Description:
>> -----------
>>
>>   subtraction of a sparse matrix from a sparse scalar with value 0
>>   results in a wrong sign
>>
>> Repeat-By:
>> ---------
>>
>>   octave:1> sparse (0) - sparse (1)
>>   ans = Compressed Column Sparse (rows = 1, cols = 1, nnz = 1)
>>
>>   (1, 1) ->  1
>>
>>   % the same for a matrix-valued op2
>>   octave:2> s = sprand (4,1,.5)
>>   s =
>>
>>   Compressed Column Sparse (rows = 4, cols = 1, nnz = 2)
>>
>>     (2, 1) ->  0.96695
>>     (3, 1) ->  0.26477
>>
>>   octave:3> sparse (0) - s
>>   ans =
>>
>>   Compressed Column Sparse (rows = 4, cols = 1, nnz = 2)
>>
>>     (2, 1) ->  0.96695
>>     (3, 1) ->  0.26477
>>
> 
> 
> I believe the attached patch should fix it, but have to do a complete
> rebuild of Octave to check it..
> 
> D.
>

Ok, in fact you also need a patch to MSparse.cc as my previous patch
only fixes cases like

s = 1i * sparse(4,1,.5);
sparse(0) - s

The attached patch completely fixes the issue for me.

D.

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: patch4
Url: https://www.cae.wisc.edu/pipermail/bug-octave/attachments/20080103/f8ce7c98/attachment-0002.ksh 
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: patch4.changelog
Url: https://www.cae.wisc.edu/pipermail/bug-octave/attachments/20080103/f8ce7c98/attachment-0003.ksh 


More information about the Bug-octave mailing list