incorrect sign when subtracting from sparse(0)
John W. Eaton
jwe at bevo.che.wisc.edu
Thu Jan 3 17:06:00 CST 2008
On 3-Jan-2008, David Bateman wrote:
| 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.
I applied this to cvs trunk and the 3.0 branch.
Thanks.
jwe
More information about the Bug-octave
mailing list