sparse indexing issue
David Bateman
David.Bateman at motorola.com
Mon Dec 17 10:58:42 CST 2007
Thomas Kasper wrote:
> Bug report for Octave 2.9.19+ configured for i686-pc-linux-gnu
>
> Description:
> -----------
> row and column reproduction via index operations do not seem
> to work properly for sparse matrices
>
> Repeat-By:
> ---------
>
> octave:1> a = sprand (1, 10, .5)
> a =
>
> Compressed Column Sparse (rows = 1, cols = 10, nnz = 3)
>
> (1, 5) -> 0.18672
> (1, 6) -> 0.76007
> (1, 10) -> 0.21645
>
> octave:2> a([1,1],:)
> ans =
>
> Compressed Column Sparse (rows = 2, cols = 10, nnz = 3)
>
> (1, 5) -> 0.18672
> (1, 6) -> 0.76007
> (1, 10) -> 0.21645
>
> % expected result would be:
> octave:3> sparse (full (a)([1,1],:))
> ans =
>
> Compressed Column Sparse (rows = 2, cols = 10, nnz = 6)
>
> (1, 5) -> 0.18672
> (2, 5) -> 0.18672
> (1, 6) -> 0.76007
> (2, 6) -> 0.76007
> (1, 10) -> 0.21645
> (2, 10) -> 0.21645
>
> % For columns I get:
> octave:4> a = sprand (10,1,.5)
> a =
>
> Compressed Column Sparse (rows = 10, cols = 1, nnz = 4)
>
> (1, 1) -> 0.86530
> (4, 1) -> 0.14741
> (5, 1) -> 0.84609
> (9, 1) -> 0.54913
>
> octave:5> a(:,[1,1])
> ans =
>
> Compressed Column Sparse (rows = 10, cols = 2, nnz = 2)
>
> (1, 1) -> 0.86530
> (1, 2) -> 0.86530
>
> % instead of:
> octave:6> sparse (full (a)(:,[1,1]))
> ans =
>
> Compressed Column Sparse (rows = 10, cols = 2, nnz = 8)
>
> (1, 1) -> 0.86530
> (4, 1) -> 0.14741
> (5, 1) -> 0.84609
> (9, 1) -> 0.54913
> (1, 2) -> 0.86530
> (4, 2) -> 0.14741
> (5, 2) -> 0.84609
> (9, 2) -> 0.54913
>
> octave:7>
>
>
Ok, I can confirm that this is a bug and inconsistent with matlab.. I
will take a go at fixing it..
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
More information about the Bug-octave
mailing list