any(x,2) on sparse gives bad result
David Bateman
David.Bateman at motorola.com
Mon Jan 7 09:41:21 CST 2008
Kim Hansen wrote:
> I have attached a data file that shows a strange bug in any(). I have
> tried to create a more simple example, but I didn't have any luck.
>
> The bug exists in the Debian octave 3.0 package and in the current cvs version.
>
> ==============
> octave:1> load x
> octave:2> any(x,2)(10104,:)
> ans = Compressed Column Sparse (rows = 1, cols = 1, nnz = 0)
>
> octave:3> any(full(x),2)(10104,:)
> ans = 1
> octave:4> x(10104,:)
> ans =
>
> Compressed Column Sparse (rows = 1, cols = 71, nnz = 1)
>
> (1, 42) -> 1
>
> octave:5> whos x
> Variables in the current scope:
>
> Attr Name Size Bytes Class
> ==== ==== ==== ===== =====
> x 10226x71 8316 double
>
> Total is 669 elements using 8316 bytes
>
> octave:6>
> ==============
>
The issue is that as the sparse matrix is stored in a compressed column
format and so the inner loop of the sparse indexing is over the rows and
not the columns, the test macro in the any/all functions for dim = 2 can
not break, as it could in the case of dim = 1 or full matrices.
Therefore the attached patch is needed, and this fixes the issue for me.
That is
load x.gz
all (any(full(x),2) == full(any(x,2)))
ans = 1
Kim, keep those bug reports coming, as your finding a lot of issues with
the sparse code :-)
D.
--
David Bateman David.Bateman at motorola.com
Motorola Labs - Paris +33 1 69 35 48 04 (Ph)
Parc Les Algorithmes, Commune de St Aubin +33 6 72 01 06 33 (Mob)
91193 Gif-Sur-Yvette FRANCE +33 1 69 35 77 01 (Fax)
The information contained in this communication has been classified as:
[x] General Business Information
[ ] Motorola Internal Use Only
[ ] Motorola Confidential Proprietary
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: patch6
Url: https://www.cae.wisc.edu/pipermail/bug-octave/attachments/20080107/09e53b69/attachment.ksh
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: patch6.changelog
Url: https://www.cae.wisc.edu/pipermail/bug-octave/attachments/20080107/09e53b69/attachment-0001.ksh
More information about the Bug-octave
mailing list