rref returns wrong results for sparse matrices

Jaroslav Hajek highegg at gmail.com
Mon Mar 3 03:30:07 CST 2008


I've tracked this problem down to the statement
	A ([pivot, r], c:cols) = A ([r, pivot], c:cols);

which apparently confuses Octave when pivot == r. The attached
changeset is a quickfix for this; however, according to what John
observed there may be bugs buried more deeply in liboctave.

On Mon, Mar 3, 2008 at 8:49 AM, John W. Eaton <jwe at bevo.che.wisc.edu> wrote:
> On  2-Mar-2008, Nils Bluthgen wrote:
>
>  | Bug report for Octave 3.0.0 configured for i386-apple-darwin8.9.1
>  |
>  | Description:
>  | -----------
>  |
>  | Calculation of the reduced row echelon form with rref.m gives
>  | different results for sparse and full matrices.
>  |
>  | Repeat-By:
>  | ---------
>  |   A=[1 2 3 4; 2 3 4 5; 2 3 4 2]
>  | rref(A)
>  | full(rref(sparse(A)))
>
>  In watching what rref is doing with sparse matrices, I noticed this
>  strange behaivor:
>
>   octave:11> A = sparse ([1, 1.5, 2, 2.5; 1, 2, 3, 4; 2, 3, 4, 2])
>   A =
>
>   Compressed Column Sparse (rows = 3, cols = 4, nnz = 12)
>
>     (1, 1) ->  1
>     (2, 1) ->  1
>     (3, 1) ->  2
>     (1, 2) ->  1.5000
>     (2, 2) ->  2
>     (3, 2) ->  3
>     (1, 3) ->  2
>     (2, 3) ->  3
>     (3, 3) ->  4
>     (1, 4) ->  2.5000
>     (2, 4) ->  4
>     (3, 4) ->  2
>
>   octave:12> A([2,3],1:4) = A([2,3],1:4) - A([2,3],1) * A(1,1:4)
>   A =
>
>   Compressed Column Sparse (rows = 3, cols = 4, nnz = 8)
>
>     (1, 1) ->  1
>     (1, 2) ->  1.5000
>     (2, 2) ->  0.50000
>     (1, 3) ->  2
>     (2, 3) ->  1
>     (1, 4) ->  2.5000
>     (2, 4) ->  1.5000
>     (3, 4) -> -3
>
>
>  Is that normal?  I would expect the output to always be column-major
>  ordering.
>
>  I also see nnz being greater than the number of elements in the
>  matrix, so that doesn't seem right.
>
>  I'm not all that familiar with the sparse matrix code in Octave, so I
>  think someone else will have to fix this.
>
>  jwe
>
>
> _______________________________________________
>  Bug-octave mailing list
>  Bug-octave at octave.org
>  https://www.cae.wisc.edu/mailman/listinfo/bug-octave
>



-- 
RNDr. Jaroslav Hajek
computing expert
Aeronautical Research and Test Institute (VZLU)
Prague, Czech Republic
url: www.highegg.matfyz.cz
-------------- next part --------------
A non-text attachment was scrubbed...
Name: rref-qfix.diff
Type: text/x-patch
Size: 1214 bytes
Desc: not available
Url : https://www.cae.wisc.edu/pipermail/bug-octave/attachments/20080303/78c6fb67/attachment-0001.bin 


More information about the Bug-octave mailing list